Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwvax!astroatc!nicmad!madnix!jason From: jason@madnix.UUCP (Jason Blochowiak) Newsgroups: comp.sys.apple2 Subject: Re: SetVector and Keyboard Interrupts Keywords: SetVector, Keyboard Interrupts Message-ID: <1415@madnix.UUCP> Date: 3 Jul 90 16:59:13 GMT References: <266201eb.2a84@petunia.CalPoly.EDU> <42395@apple.Apple.COM> Reply-To: jason@madnix.UUCP (Jason Blochowiak) Organization: ARP Software, Madison, WI Lines: 50 In article <42395@apple.Apple.COM> dlyons@Apple.COM (David A. Lyons) writes: >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. [Problems with >> SetVector, etc., deleted] >>Roy - rbannon@cosmos.acs.calpoly.edu > [Deleted Dave mentioning the way key pseudo-interrupts are dealt with] > [ and about SetVector patches only being valid between Evt Mgr status changes] > [...] 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. Oooh, ick! Then wouldn't it also be necessary to watch for EMStartUp & EMShutDown calls, so that any app that relied on the vector patches being purged on EMShutDown wouldn't cause a post-run crash? My somewhat hackish approach to nabbing keypresses for FKeys GS is to patch PostEvent. If the event being posted is a keyDownEvt or autoKeyEvt, then I nab the keycode (and the modifiers), and call an internal routine called CheckKey. If CheckKey says that it doesn't want the keypress, then the patch lets the call go through. If it did want the keypress, then I munge the stack myself and return to the caller as if the thing was successfully posted. A coupla' caveats: This will only work for things that use the Evt Mgr. Actually, FKeys GS only works with desktop applications - because the specific PostEvent code is called during an interrupt (or at least I have to assume it is), it'd be a really bad time to run a whole bunch of code, not to mention the machine state... So, CheckKey, if it determines that it wants the keypress, sets some internal variables, and a Run Queue entry actually runs the appropriate FKey. It'd probably be simpler for you to actually buy FKeys GS and write your own FKey than it would for you to write all the support code, etc., that I had to. This is, quite honestly, less of a sales pitch than it is a "Warning: Wheel has already been invented" type message. Disclaimer: I wrote FKeys GS, and sold it to Softdisk G-S. I'd give you the source code if I wouldn't be decapitated for doing so... >David A. Lyons, Apple Computer, Inc. | DAL Systems >Internet/BITNET: dlyons@apple.com UUCP: ...!ames!apple!dlyons -- Jason Blochowiak - jason@madnix.UUCP or, try: astroatc!nicmad!madnix!jason@spool.cs.wisc.edu "Education, like neurosis, begins at home." - Milton R. Saperstein