Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!ucbcad!ucbvax!hoser.berkeley.edu!bryce From: bryce@hoser.berkeley.edu (Bryce Nesbitt) Newsgroups: comp.sys.amiga Subject: Re: to RAWKEY or not to RAWKEY Summary: A clear explanation, and source code. Message-ID: <22235@ucbvax.BERKELEY.EDU> Date: 19 Dec 87 04:30:53 GMT References: <552@oscvax.UUCP> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: bryce@hoser.berkeley.edu (Bryce Nesbitt) Organization: The Logic Foundation Lines: 94 In article <552@oscvax.UUCP> rico@oscvax.UUCP (Rico Mariani) writes: >All this talk about the whys and wherefores of RAWKEY has >seriously confused me... To summarize your keyboard options: RAWKEY is rarely useful. It provides physical key locations, but gives you no idea what those keys might mean. (The tables in the manuals give the default values, but these are useless in the real world.) Don't use this unless you know what you are getting into. VANILLAKEY gives you the keys, converted. It does not give any of the special keys like cursor-up or HELP. When you get an "a" from this option you know it means "a", period. This is the best option provided you don't need the special keys. RAWKEY+DeadKeyConvert() gives you all of the "VANILLA" keys, plus access to the special keys. The early versions of the Intuition manual don't mention VANILLAKEY. It works exactly like RAWKEY except, of course, it converts the keys for you. Two tests any text-using program should pass: * Use "setmap usa2" to set a Dvorak keyboard. Run your program, it should pick up the changes. * Type "ALT-K" then "a". You should see an umlaut a. >I want to know when the key that is in the position that >the 'A' key normally is in (I don't care if the guy's using >DVORAK or whatever, the position is what's important) goes >down and when it goes up. That's all. RAWKEY is your option. It will return the position of any key pressed or released while your window is active. Since the user may press or release a key after clicking out of your window, you will need to handle the cases of key-up without key-down and key-down without key-up. >Can I use the code field from an intuition RAWKEY directly without >commiting a cardinal programming sin? Yes, provided that the application is *not* a text-oriented one. Text editors, terminal programs, etc. *must* use one of the other options. /* * DeadKeyConvert(). From the Amiga Enhancer Manual. * * Takes an Intuition RAWKEY message and processes it. * The result will be "cooked" keys and key conversions in * your buffer. See the console.device chapter for what * the special key sequences look like. * * returns -2 if not RAWKEY, -1 if the buffer overflowed, or * the number of characters converted if all was ok. * */ long DeadKeyConvert(msg,kbuffer,kbsize,kmap) struct IntuiMessage *msg; UBYTE *kbuffer; long kbsize; struct KeyMap *kmap; { static struct InputEvent ievent = {NULL, IECLASS_RAWKEY,0,0,0}; if (msg->Class != RAWKEY) return(-2); /* pack message into an input event */ ievent.ie_Code =msg->Code; ievent.ie_Qualifier =msg->Qualifier; /* get previous codes from location pointed to by IAddress * this "magic" pointer is valid intil the IntiiMessage is * replied */ ievent.ie_position.ie_addr =*((APTR*)msg->IAddress); return(RawKeyConvert(&ievent,buffer,kbsize,kmap)); } See comp.{sources,binaries}.amiga for a complete stand-alone example. |\ /| . Ack! (NAK, SOH, EOT) {o O} . bryce@hoser.berkeley.EDU -or- ucbvax!hoser!bryce (or try "cogsci") (") U "Your theory is crazy... but not crazy enought to be true." -Niels Bohr