USBHID: report descriptor fix for MacBook JIS keyboard
authorTomoya Adachi <adachi@il.is.s.u-tokyo.ac.jp>
Wed, 3 Oct 2007 21:27:49 +0000 (23:27 +0200)
committerJiri Kosina <jkosina@suse.cz>
Sun, 14 Oct 2007 11:40:01 +0000 (13:40 +0200)
This patch fixes the problem, that Japanese MacBook doesn't recognize some keys
like '\'(yen, or backslash), '|'(pipe), and '_'(underscore).

It is due to that MacBook JIS keyboard (jp106) sends wrong report descriptor.
It saids "logical maximum = 0x65", so Keyboard.0089 is mapped to Key.Unknown,
while it should be accepted as Key.Yen.

Signed-off-by: Tomoya Adachi <adachi@il.is.s.u-tokyo.ac.jp>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/usbhid/hid-quirks.c
include/linux/hid.h

index 91abac6a30cdfdcc1d1284a2ee24167f9d5d2d95..a0d6f081ee5cec767b615c0ba08c87994546a4ba 100644 (file)
@@ -624,6 +624,8 @@ static const struct hid_rdesc_blacklist {
        { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER, HID_QUIRK_RDESC_LOGITECH },
        { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_S510_RECEIVER_2, HID_QUIRK_RDESC_LOGITECH },
 
+       { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS, HID_QUIRK_RDESC_MACBOOK_JIS },
+
        { USB_VENDOR_ID_PETALYNX, USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE, HID_QUIRK_RDESC_PETALYNX },
 
        { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1, HID_QUIRK_RDESC_SWAPPED_MIN_MAX },
@@ -937,6 +939,18 @@ static void usbhid_fixup_cypress_descriptor(unsigned char *rdesc, int rsize)
                printk(KERN_INFO "Fixing up Cypress report descriptor\n");
 }
 
+/*
+ * MacBook JIS keyboard has wrong logical maximum
+ */
+static void usbhid_fixup_macbook_descriptor(unsigned char *rdesc, int rsize)
+{
+       if (rsize >= 60 && rdesc[53] == 0x65
+                       && rdesc[59] == 0x65) {
+               printk(KERN_INFO "Fixing up MacBook JIS keyboard report descriptor\n");
+               rdesc[53] = rdesc[59] = 0xe7;
+       }
+}
+
 
 static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned rsize)
 {
@@ -951,6 +965,9 @@ static void __usbhid_fixup_report_descriptor(__u32 quirks, char *rdesc, unsigned
 
        if (quirks & HID_QUIRK_RDESC_PETALYNX)
                usbhid_fixup_petalynx_descriptor(rdesc, rsize);
+
+       if (quirks & HID_QUIRK_RDESC_MACBOOK_JIS)
+               usbhid_fixup_macbook_descriptor(rdesc, rsize);
 }
 
 /**
index eb42e10e3c86d6f50640524327408c66e4c3f9d7..35f5384a465bb4b212c893dd117da692ffe6322f 100644 (file)
@@ -286,6 +286,7 @@ struct hid_item {
 #define HID_QUIRK_RDESC_LOGITECH               0x00000002
 #define HID_QUIRK_RDESC_SWAPPED_MIN_MAX                0x00000004
 #define HID_QUIRK_RDESC_PETALYNX               0x00000008
+#define HID_QUIRK_RDESC_MACBOOK_JIS            0x00000010
 
 /*
  * This is the global environment of the parser. This information is