The USB Powerbooks with ISO keyboards have the KEY_GRAVE/KEY_102ND
keys reversed.

This was already the case for ADB keyboards, see adbhid_input_register(). 
I tried to reuse the hidinput_pb_setup() function as shown in the patch
below. But this does not change anything. Only the change in
hidinput_configure_usage() in the HID_UP_KEYBOARD case does actually
correct the keycodes.

Where is the correct place to fix this up?


---
 drivers/usb/input/hid-core.c  |    7 +++++--
 drivers/usb/input/hid-input.c |   30 +++++++++++++++++++++++++-----
 drivers/usb/input/hid.h       |    1 +
 3 files changed, 31 insertions(+), 7 deletions(-)

Index: linux-2.6.19-rc3/drivers/usb/input/hid-core.c
===================================================================
--- linux-2.6.19-rc3.orig/drivers/usb/input/hid-core.c
+++ linux-2.6.19-rc3/drivers/usb/input/hid-core.c
@@ -27,8 +27,8 @@
 #include <linux/input.h>
 #include <linux/wait.h>
 
-#undef DEBUG
-#undef DEBUG_DATA
+#define DEBUG
+#define DEBUG_DATA
 
 #include <linux/usb.h>
 
@@ -1776,6 +1776,9 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_POWERBOOK_HAS_FN },
        { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_POWERBOOK_HAS_FN },
 
+       { USB_VENDOR_ID_APPLE, 0x0215, HID_QUIRK_POWERBOOK_ISO_KEYBOARD },
+       { USB_VENDOR_ID_APPLE, 0x0218, HID_QUIRK_POWERBOOK_ISO_KEYBOARD },
+
        { USB_VENDOR_ID_PANJIT, 0x0001, HID_QUIRK_IGNORE },
        { USB_VENDOR_ID_PANJIT, 0x0002, HID_QUIRK_IGNORE },
        { USB_VENDOR_ID_PANJIT, 0x0003, HID_QUIRK_IGNORE },
Index: linux-2.6.19-rc3/drivers/usb/input/hid-input.c
===================================================================
--- linux-2.6.19-rc3.orig/drivers/usb/input/hid-input.c
+++ linux-2.6.19-rc3/drivers/usb/input/hid-input.c
@@ -31,7 +31,7 @@
 #include <linux/kernel.h>
 #include <linux/usb/input.h>
 
-#undef DEBUG
+#define DEBUG
 
 #include "hid.h"
 
@@ -121,6 +121,12 @@ static struct hidinput_key_translation p
        { }
 };
 
+static struct hidinput_key_translation powerbook_iso_keyboard[] = {
+       { KEY_GRAVE,    KEY_102ND },
+       { KEY_102ND,    KEY_GRAVE },
+       { }
+};
+
 static int usbhid_pb_fnmode = 1;
 module_param_named(pb_fnmode, usbhid_pb_fnmode, int, 0644);
 MODULE_PARM_DESC(pb_fnmode,
@@ -198,7 +204,7 @@ static int hidinput_pb_event(struct hid_
        return 0;
 }
 
-static void hidinput_pb_setup(struct input_dev *input)
+static void hidinput_pb_setup(struct input_dev *input, int iso)
 {
        struct hidinput_key_translation *trans;
 
@@ -210,6 +216,12 @@ static void hidinput_pb_setup(struct inp
 
        for (trans = powerbook_numlock_keys; trans->from; trans++)
                set_bit(trans->to, input->keybit);
+
+       if (iso) {
+               printk(" swapping keys, you wish.. ");
+               for (trans = powerbook_iso_keyboard; trans->from; trans++)
+                       set_bit(trans->to, input->keybit);
+       }
 }
 #else
 static inline int hidinput_pb_event(struct hid_device *hid, struct input_dev 
*input,
@@ -218,7 +230,7 @@ static inline int hidinput_pb_event(stru
        return 0;
 }
 
-static inline void hidinput_pb_setup(struct input_dev *input)
+static inline void hidinput_pb_setup(struct input_dev *input, int iso)
 {
 }
 #endif
@@ -230,6 +242,7 @@ static void hidinput_configure_usage(str
        struct hid_device *device = input->private;
        int max = 0, code;
        unsigned long *bit = NULL;
+       unsigned char swap_key;
 
        field->hidinput = hidinput;
 
@@ -253,7 +266,14 @@ static void hidinput_configure_usage(str
 
                        if ((usage->hid & HID_USAGE) < 256) {
                                if (!hid_keyboard[usage->hid & HID_USAGE]) goto 
ignore;
-                               map_key_clear(hid_keyboard[usage->hid & 
HID_USAGE]);
+                               swap_key = usage->hid & HID_USAGE;
+                               if (device->quirks & 
HID_QUIRK_POWERBOOK_ISO_KEYBOARD) {
+                                       if (swap_key == 100)
+                                               swap_key = 53;
+                                       else if (swap_key == 53)
+                                               swap_key = 100;
+                               }
+                               map_key_clear(hid_keyboard[swap_key]);
                        } else
                                map_key(KEY_UNKNOWN);
 
@@ -489,7 +509,7 @@ static void hidinput_configure_usage(str
                                case 0x003:
                                        /* The fn key on Apple PowerBooks */
                                        map_key_clear(KEY_FN);
-                                       hidinput_pb_setup(input);
+                                       hidinput_pb_setup(input, device->quirks 
& HID_QUIRK_POWERBOOK_ISO_KEYBOARD);
                                        break;
 
                                default:    goto ignore;
Index: linux-2.6.19-rc3/drivers/usb/input/hid.h
===================================================================
--- linux-2.6.19-rc3.orig/drivers/usb/input/hid.h
+++ linux-2.6.19-rc3/drivers/usb/input/hid.h
@@ -260,6 +260,7 @@ struct hid_item {
 #define HID_QUIRK_POWERBOOK_HAS_FN             0x00001000
 #define HID_QUIRK_POWERBOOK_FN_ON              0x00002000
 #define HID_QUIRK_INVERT_HWHEEL                        0x00004000
+#define HID_QUIRK_POWERBOOK_ISO_KEYBOARD       0x00008000
 
 /*
  * This is the global environment of the parser. This information is

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to