[comp.sys.amiga] to RAWKEY or not to RAWKEY

rico@oscvax.UUCP (Rico Mariani) (12/16/87)

All this talk about the whys and wherefores of RAWKEY has
seriously confused me so I'm going to ask a direct question:

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.  I don't want any
escape sequences.  I don't want any accents.  I only want
to know about the current state of the 'A' key.  I don't
care (in fact I prefer) if I stop getting messages when my
window isn't active.

Can I use the code field from an intuition RAWKEY directly without
commiting a cardinal programming sin?  If no then what the #@$!%
am I supposed to do?

	Somebody talk to me  (any subject will do :-) )
	   -Rico
-- 
		...{watmath|allegra|decvax|ihnp4|linus}!utzoo!oscvax!rico
		or oscvax!rico@gpu.toronto.EDU   if you're lucky

[NSA food: terrorist, cryptography, DES, drugs, CIA, secret, decode]
[CSIS food: supermailbox, tuna, fiberglass coffins, Mirabel, microfiche]
[Cat food: Nine Lives, Cat Chow, Meow Mix, Crave]

bryce@hoser.berkeley.edu (Bryce Nesbitt) (12/19/87)

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

carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (12/21/87)

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 so I'm going to ask a direct question:
>
>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.  I don't want any
>escape sequences.  I don't want any accents.  I only want
>to know about the current state of the 'A' key.  I don't
>care (in fact I prefer) if I stop getting messages when my
>window isn't active.
>
>Can I use the code field from an intuition RAWKEY directly without
>commiting a cardinal programming sin?  If no then what the #@$!%
>am I supposed to do?


   If all you care about is whether a key in a particular physical
position of the keyboard is pressed, then RAWKEY is OK.  As long
as you keep in mind, in your documentation and prompts (if any)
that a US RAW 'A' key value will not necessarily be an 'A' in Italy
or Germany etc.  For instance, in Germany, their Z is where our Y key
is, and their Y is where our Z key is.  So if they pressed 'Z', your
program would get a different RAWKEY than when we press 'Z' in the US.

   Most of the foreign keyboards have keys in different positions, especially
punctuation symbols.  And many have additional keys.  And in Europe, there
are even key differences between A1000's and A500/2000's.

   Please use KeyToy (on the 1.2 Enhancer Extras disk for the 1000, newer
version that draws extra keys on the A500/A2000 Extras disk for A500/2000).
Try each version on appropriate machine and pick out keys that return
the same raw values on all currently existing foreign keyboards, paying
particular attention to Germany (pretty large % of Amiga sales).

-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CATS   >>Commodore Amiga Technical Support<<
                     UUCP  ...{allegra,ihnp4,rutgers}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

darin@laic.UUCP (Darin Johnson) (12/22/87)

> >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.

Yes, but will this work on the 2000's?  There are some commercial
games that I know of that work on 500's, 1000's, but not on the
2000's.  To me it seems that this is due to using RAWKEY, but I may be wrong.

How would someone go about getting the physical key location without
using VANILLAKEY but still be portable to the new machines?  A common 
key grouping (hjkl) could end up very awkward to someone with a usa2 keymap.
-- 
Darin Johnson (..sun!sunncal!leadsv!laic!darin)
	This space available for use...

carolyn@cbmvax.UUCP (Carolyn Scheppner CATS) (12/24/87)

In article <121@laic.UUCP> darin@laic.UUCP (Darin Johnson) writes:
>> >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.
>
>Yes, but will this work on the 2000's?  There are some commercial
>games that I know of that work on 500's, 1000's, but not on the
>2000's.  To me it seems that this is due to using RAWKEY, but I may be wrong.

   No - when you use RAWKEY, the keyboard is still being read by the system
software which has no problem with any of the slightly different keyboards.
The things that don't work with some keyboards are straight-to-the-hardware
programs that bypassed the OS and were doing their own keyboard handshaking.


>How would someone go about getting the physical key location without
>using VANILLAKEY but still be portable to the new machines?  A common 
>key grouping (hjkl) could end up very awkward to someone with a usa2 keymap.

   Not sure if I understand you.  I gather you want to use, for instance,
a physically close group of keys for something like a directional keypad.

   For instance, you want them to use the keys where OUR H-J-K-L are,
you want to read raw key position (RAWKEY) but you also want to know
what their keycaps say so you can tell them "Use the X-X-X-X keys to..."
You could open the console device with unit=-1 and use the GetKeyMap
command to see what their keycaps are.  OR, just feed all the raw values
you are interested in to RawKeyConvert (ConsoleDevice function) and
see what you get back.  That would be easier.


   OR - Are you asking How Can I Get All of the Keys in an Internationally
Compatible Manner (and deal with them as ascii characters regardless of
their position) ?

   Answer to this is either use the console.device, or use RAWKEY and
DeadKeyConvert() routine (as shown in Enhancer manual and 1.2 ReadMes).

 
  
-- 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Carolyn Scheppner -- CATS   >>Commodore Amiga Technical Support<<
                     UUCP  ...{allegra,ihnp4,rutgers}!cbmvax!carolyn 
                     PHONE 215-431-9180
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=