[PATCH 03/16] dmx: switch lnx-input and usb-input over to xkb-only.

Peter Hutterer peter.hutterer at who-t.net
Wed Sep 9 23:54:09 PDT 2009


kbd*Convert are nearly identical, it just asks for merging. Not today
though.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 hw/dmx/input/lnx-keyboard.c |   17 +++++++++++------
 hw/dmx/input/usb-keyboard.c |   13 +++++++++----
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/hw/dmx/input/lnx-keyboard.c b/hw/dmx/input/lnx-keyboard.c
index 744b6ac..939a32f 100644
--- a/hw/dmx/input/lnx-keyboard.c
+++ b/hw/dmx/input/lnx-keyboard.c
@@ -167,6 +167,7 @@
 #include "xf86Keymap.h"
 #endif
 #include <linux/keyboard.h>
+#include <xkbsrv.h>
 
 #define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
 #define NUM_STATE_ENTRIES (256/32)
@@ -660,7 +661,7 @@ static void kbdLinuxConvert(DevicePtr pDev,
                             BLOCK block)
 {
     GETPRIV;
-    KeySymsPtr     pKeySyms = &priv->pKeyboard->key->curKeySyms;
+    XkbSrvInfoPtr  xkbi = priv->pKeyboard->key->xkbInfo;
     int            type;
     KeySym         keySym   = NoSymbol;
     int            keyCode;
@@ -673,10 +674,14 @@ static void kbdLinuxConvert(DevicePtr pDev,
     keyCode = (scanCode & 0x7f) + MIN_KEYCODE;
 
     /* Handle repeats */
-    
-    if (keyCode >= pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
-        keySym = pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
-                               * pKeySyms->mapWidth];
+
+    if (keyCode >= xkbi->desc->min_key_code &&
+        keyCode <= xkbi->desc->max_key_code) {
+
+        int effectiveGroup = XkbGetEffectiveGroup(xkbi,
+                                                  &xkbi->state,
+                                                  scanCode);
+        keySym = XkbKeySym(xkbi->desc, scanCode, effectiveGroup);
 #if 0
         switch (keySym) {
         case XK_Num_Lock:
@@ -690,7 +695,7 @@ static void kbdLinuxConvert(DevicePtr pDev,
             break;
         }
 #endif
-        
+
         /* If key is already down, ignore or autorepeat */
         if (type == KeyPress && kbdLinuxKeyDown(priv, keyCode)) {
             KbdFeedbackClassRec *feed = priv->pKeyboard->kbdfeed;
diff --git a/hw/dmx/input/usb-keyboard.c b/hw/dmx/input/usb-keyboard.c
index 12ca8ab..c4667a3 100644
--- a/hw/dmx/input/usb-keyboard.c
+++ b/hw/dmx/input/usb-keyboard.c
@@ -85,6 +85,7 @@
  * part of the Xserver tree.  All calls to the dmx* layer are #defined
  * here for the .c file.  The .h file will also have to be edited. */
 #include "usb-keyboard.h"
+#include <xkbsrv.h>
 
 #define GETPRIV       myPrivate *priv                            \
                       = ((DMXLocalInputInfoPtr)(pDev->devicePrivate))->private
@@ -296,7 +297,7 @@ static void kbdUSBConvert(DevicePtr pDev,
                           BLOCK block)
 {
     GETPRIV;
-    KeySymsPtr     pKeySyms = &priv->pDevice->key->curKeySyms;
+    XkbSrvInfoPtr  xkbi = priv->pKeyboard->key->xkbInfo;
     int            type;
     int            keyCode;
     KeySym         keySym   = NoSymbol;
@@ -308,9 +309,13 @@ static void kbdUSBConvert(DevicePtr pDev,
 
     /* Handle repeats */
 
-    if (keyCode >= pKeySyms->minKeyCode && keyCode <= pKeySyms->maxKeyCode) {
-        keySym = pKeySyms->map[(keyCode - pKeySyms->minKeyCode)
-                               * pKeySyms->mapWidth];
+    if (keyCode >= xkbi->desc->min_key_code &&
+        keyCode <= xkbi->desc->max_key_code) {
+
+        int effectiveGroup = XkbGetEffectiveGroup(xkbi,
+                                                  &xkbi->state,
+                                                  scanCode);
+        keySym = XkbKeySym(xkbi->desc, scanCode, effectiveGroup);
 #if 0
         switch (keySym) {
         case XK_Num_Lock:
-- 
1.6.3.rc1.2.g0164.dirty



More information about the xorg-devel mailing list