Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!dlyons From: dlyons@Apple.COM (David A. Lyons) Newsgroups: comp.sys.apple2 Subject: Re: SetVector and Keyboard Interrupts Keywords: SetVector, Keyboard Interrupts Message-ID: <42395@apple.Apple.COM> Date: 27 Jun 90 06:12:36 GMT References: <266201eb.2a84@petunia.CalPoly.EDU> Organization: Apple Computer Inc, Cupertino, CA Lines: 45 In article <266201eb.2a84@petunia.CalPoly.EDU> rbannon@mira.acs.calpoly.edu.UUCP (Roy Bannon) writes: > I am trying to write a interrupt handler for the keyboard. I want to make >the function keys on the extended keyboard do something. Here's the problem >in a nutshell. I install my handler with SetVector and it returns fine. The >problem is that after its installed and the interrupts are enabled, IntSource, >I don't get an interrupt with every key press. I put a brk instruction as the >first line of code, and it doesn't break until several keys have been pressed, >and then doesn't break again for several more chars. Anybody got any ideas? >Anybody at all? Any and all help greatly appreciated. > >Thanks, >Roy >rbannon@cosmos.acs.calpoly.edu I couldn't see what was going wrong for you until I tried it, but now it makes sense: you were sitting in an environment that was polling for keys, and it was stealing most of them *before* the keyboard-interrupt mechanism got a chance to see them. "Keyboard interrupts" are currently implemented with a heartbeat task that checks for a keypress once every 1/60th of a second & calls the Keyboard Interrupt vector (with the appropriate environment set up) when it sees a key has actually been pressed. (Of course, you shouldn't *assume* that IntSource handles keyboard interrupts this way--some day it might work differently.) Anyway, there's another obstacle in your way: SetVector is not going to give you permanent ownership of keyboard interrupts. You'll lose them whenever the Event Manager is started up or shut down. I don't see a clean way around this, but I can think of at least one hacky way: patch SetVector to check for vector number $000f, handle all the others by passing control to the Real SetVector code, and handle $f by keeping the passed handler for your own use & giving YOUR address to the real SetVector. When your handler is called, you can call the Real vector if you don't want the keypress. Of course, there are no guarantees about doing weird patching like this. -- David A. Lyons, Apple Computer, Inc. | DAL Systems Apple II Developer Technical Support | P.O. Box 875 America Online: Dave Lyons | Cupertino, CA 95015-0875 GEnie: D.LYONS2 or DAVE.LYONS CompuServe: 72177,3233 Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons My opinions are my own, not Apple's.