[AD] Keypad behaviour

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I came across a problem with the linux keyboard code.  If you have
numlock off and press a numpad key, e.g. KEY_4_PAD, key[KEY_LEFT] will
be set.  When you release KEY_4_PAD, key[KEY_LEFT] will not be unset.

This bug can be solved without too much trouble, but I was wondering if
we should just take out this misfeature of rerouting the numpad keys to
other keys depending on whether the numlock is on or not.  All
pckeys.c-based drivers will have this feature (e.g. DOS & Windows) but X
doesn't.  I'm not proposing the change pckeys.c, but just to remove the
feature from the linux driver.  Patch attached.

Peter

Index: src/linux/lkeybd.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/linux/lkeybd.c,v
retrieving revision 1.10
diff -u -r1.10 lkeybd.c
--- src/linux/lkeybd.c	30 Oct 2004 14:19:53 -0000	1.10
+++ src/linux/lkeybd.c	30 Oct 2004 14:46:59 -0000
@@ -142,14 +142,7 @@
 };
 
 #define NUM_PAD_KEYS 17
-static int pad_arrow_codes[NUM_PAD_KEYS] = {
-        __allegro_KEY_INSERT, __allegro_KEY_END, __allegro_KEY_DOWN, __allegro_KEY_PGDN,
-        __allegro_KEY_LEFT, __allegro_KEY_5_PAD, __allegro_KEY_RIGHT, __allegro_KEY_HOME,
-        __allegro_KEY_UP, __allegro_KEY_PGUP, __allegro_KEY_PLUS_PAD, __allegro_KEY_MINUS_PAD,
-	__allegro_KEY_ASTERISK, __allegro_KEY_SLASH_PAD, __allegro_KEY_ENTER_PAD, 0/*__allegro_KEY_COMMA_PAD*/,
-	__allegro_KEY_DEL
-};
-static char pad_asciis[NUM_PAD_KEYS] = "0123456789+-*/\r,.";
+static char pad_asciis_numlock[NUM_PAD_KEYS] = "0123456789+-*/\r,.";
 static char pad_asciis_no_numlock[NUM_PAD_KEYS] = { 
 	-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 
 	'+', '-', '*', '/', '\r', -1, -1
@@ -162,6 +155,7 @@
         unsigned int code, mycode, press;
         int ascii;
         int map;
+	int val;
         struct kbentry kbe;
 
         ASSERT(buf || bytes_read==0);
@@ -249,17 +243,13 @@
                                 break;
                         case KT_PAD:
                                 ascii = -1;
-                                if (_key_shifts & __allegro_KB_NUMLOCK_FLAG) {
-                                        int val = KVAL(kbe.kb_value);
-                                        if ((val >= 0) && (val < NUM_PAD_KEYS))
-                                                ascii = pad_asciis[val];
-                                } else {
-					int val = KVAL(kbe.kb_value);
-					if ((val >= 0) && (val < NUM_PAD_KEYS) && pad_arrow_codes[val]) {
-					    	ascii = pad_asciis_no_numlock[val];
-						mycode = pad_arrow_codes[val];
-					}
-                                }
+				val = KVAL(kbe.kb_value);
+				if ((val >= 0) && (val < NUM_PAD_KEYS)) {
+					if (_key_shifts & __allegro_KB_NUMLOCK_FLAG)
+                                                ascii = pad_asciis_numlock[val];
+					else
+						ascii = pad_asciis_no_numlock[val];
+				}
                                 break;
                         case KT_SPEC:
                                 if (mycode == __allegro_KEY_ENTER) {



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/