Disable auto repeat for non standard keys?

drago01 drago01 at gmail.com
Mon Jun 30 02:46:34 PDT 2008


Hi,
There are some keyboards (mostly on laptops) that have keys that do
not send a release event but keep sending keypress events when
pressed.
In X they do not work because the server expects an keyrelease event
which never comes.

Matthew Garrett sent me a patch to test, which disables autorepeat for
keycodes > 146 and sends the down and up event.
It works fine on my laptop (my volume keys are now working fine).

Patch is attached, any comments/other suggestions?

---------------------
diff -upNr xf86-input-keyboard-1.3.0.orign/src/kbd.c
xf86-input-keyboard-1.3.0/src/kbd.c
--- xf86-input-keyboard-1.3.0.orign/src/kbd.c	2008-03-20
19:55:18.000000000 +0100
+++ xf86-input-keyboard-1.3.0/src/kbd.c	2008-06-29 14:27:12.000000000 +0200
@@ -793,7 +793,7 @@ sunKeyboards:
   /*
    * check for an autorepeat-event
    */
-  if (down && KeyPressed(keycode)) {
+  if (down && KeyPressed(keycode) && keycode < 146) {
       int num = keycode >> 3;
       int bit = 1 << (keycode & 7);

@@ -806,11 +806,26 @@ sunKeyboards:
    if (UsePrefix) {
       xf86PostKeyboardEvent(device,
               keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], TRUE);
-      xf86PostKeyboardEvent(device, keycode, down);
+      if (keycode < 146) {
+	      xf86PostKeyboardEvent(device, keycode, down);
+      } else if (down) {
+	      /* If it's a key down event, send a down and up. Otherwise
+		 drop it */
+	      xf86PostKeyboardEvent(device, keycode, TRUE);
+	      xf86PostKeyboardEvent(device, keycode, FALSE);
+      }
       xf86PostKeyboardEvent(device,
               keyc->modifierKeyMap[keyc->maxKeysPerModifier*7], FALSE);
    } else {
-      xf86PostKeyboardEvent(device, keycode, down);
+      if (keycode < 146) {
+	      xf86PostKeyboardEvent(device, keycode, down);
+      } else if (down) {
+	      /* If it's a key down event, send a down and up. Otherwise
+		 drop it */
+	      xf86PostKeyboardEvent(device, keycode, TRUE);
+	      xf86PostKeyboardEvent(device, keycode, FALSE);
+      }
+
    }
 }



More information about the xorg mailing list