File: AMIGA.2570
From: pk@pid.UUCP (Pushpa Kumar)
Newsgroups: net.micro.amiga
Subject: Bugs in key mapping
Date: 24 Mar 86 12:54:18 GMT
Organization: P & I Design, Inc. Atlanta
Lines: 460

        There appears to be a bug in the keymapping routines when more than
one qualifier is applied to a key.  I have setup a test program to illustrate
this problem.

        In the test program keys 1, 2 ,3, & 4 only have been mapped.
Key 4 + SHIFT is used to exit from the program.

The setup is as follows:

key   key type   qualifiers     expected code output      code actually output
---   --------   ----------     --------------------      --------------------

1     0x05       NOQUAL         'a'                       'a'
                 SHIFT          'b'                       'b'
                 CTRL           'c'                       'b'
                 CTRL + SHIFT   'd'                       'd'
                                                        
2     0x43       NOQUAL         "2 + noqual"              "2 + noqual"
                 SHIFT          "2 + shift"               "2 + shift" 
                 ALT            "2 + alt"                 "2 + shift"
                 SHIFT + ALT    "2 + shift + alt"         "t2 + a"

3     0x47       NOQUAL         "3 + noqual"              "3 + noqual"
                 SHIFT          "3 + shift"               "3 + shift"
                 ALT            "3 + alt"                 "3 + shift"
                 CTRL           "3 + ctrl"                "3 + shift"
                 ALT + SHIFT    "3 + alt + shift"         "t3 + a"
                 CTRL + ALT     "3 + ctrl + alt"          "t3 + a"
                 CTRL + SHIFT   "3 + ctrl + shift"        "t3 + a"
                 CTRL + ALT     "3 + ctrl + alt + shift"  "lt3 + c"
                      + SHIFT

4     0x01       NOQUAL         '4'                       '4'
                 SHIFT          '$'                       '$'



I have several questions regarding the keymapping setup:

1) Are the qualifiers for keytype 0x47 in the right order? It isn't very clear
   what the order should be in the case when more than one qualifier is used.  
   The ordering above for key 3 (keytype 0x47) is per table 4-7 of
   the Console Device chapter in RKM vol 1.

2) The Console Device chapter also refers to routines:
            . GetKeyMap()
            . SetKeyMap()

   Where are these documented?  I can't find any reference to them under
   console.doc in RKM vol 2.  I did find CDAskKeyMap and CDSetKeyMap.
   
   Are the routines GetKeyMap() & SetKeyMap() in some special library?
   I got linker error messages when I tried to use them.  So I had to use the
   CD_ASKKEYMAP & CD_SETKEYMAP commands instead.

3) The documentation says that " the high keytype table covers the raw    
   keycodes from hex 40-67, and contains 38 (decimal) bytes".
   Shouldn't that be 40 (decimal) bytes ?

4) Also why doesn't Chk_Abort() work in this program ?

I hope you Amiga Experts out there can provide the answers and maybe a fix to
the keymapping problem.  

There is also a bug in Lattice C that I might as well include in this article.
I stumbled on it when dumping out the default Amiga keymap.

      UBYTE *p;
      int    len, i;

      /* The expression on the RHS of the assignment statement below is
       * evaluated correctly
       */
      len = *p + *(p+2) + 4;       

      /* The same expression when used in a "for" statement does not work 
       */
      for (i = 1; i <= (*p + *(p+2) +4); i++)
        {
        }

      /* But the statement below works fine
       */
      for (i = 1; i <= len; i++)
        {
        }



The keymapping test program follows in keymap_test.h and keymap_test.c
-- 
Pushpa Kumar 
akgua!pid!pk
404/952-1572 (voice)
