HID: support for logitech cordless desktop LX500 special mapping
authorRyo Dairiki <ryo-dairiki@users.sourceforge.net>
Mon, 25 Jun 2007 08:31:12 +0000 (10:31 +0200)
committerJiri Kosina <jkosina@suse.cz>
Mon, 9 Jul 2007 12:13:36 +0000 (14:13 +0200)
This keyboard has wireless mouse which has left, middle, right buttons and
2-dimensional scrolling wheel.  Unfornetuly, this wheel reports side scrolling
events and 11 or 12 button events at the same time.

I've wrote a patch to fix this mapping.  I'm not sure if this mapping is proper
for buttons, because , for example, there is no entry for "burn cd" in input.h.

The patch also supress 11 and 12 button events from mouse when you scroll the
wheel left and right.  With this patch, only side scrolling events are
reported.  (This mouse has only 4 buttons and 2D wheel. There is no such
buttons like 11 and 12.)

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-input.c
drivers/hid/usbhid/hid-quirks.c
include/linux/hid.h

index 1b8b3334140830121f1869521220c242188b6c22..60de16a83c3ecc333938d1fc24692670d2bf237b 100644 (file)
@@ -60,6 +60,19 @@ static const unsigned char hid_keyboard[256] = {
        150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk
 };
 
+/* extended mapping for certain Logitech hardware (Logitech cordless desktop LX500) */
+#define LOGITECH_EXPANDED_KEYMAP_SIZE 80
+static int logitech_expanded_keymap[LOGITECH_EXPANDED_KEYMAP_SIZE] = {
+         0,216,  0,213,175,156,  0,  0,  0,  0,
+       144,  0,  0,  0,  0,  0,  0,  0,  0,212,
+       174,167,152,161,112,  0,  0,  0,154,  0,
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+         0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
+         0,  0,  0,  0,  0,183,184,185,186,187,
+       188,189,190,191,192,193,194,  0,  0,  0
+};
+
 static const struct {
        __s32 x;
        __s32 y;
@@ -378,6 +391,21 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                                        }
                        }
 
+                       /* Special handling for Logitech Cordless Desktop */
+                       if (field->application != HID_GD_MOUSE) {
+                               if (device->quirks & HID_QUIRK_LOGITECH_EXPANDED_KEYMAP) {
+                                       int hid = usage->hid & HID_USAGE;
+                                       if (hid < LOGITECH_EXPANDED_KEYMAP_SIZE && logitech_expanded_keymap[hid] != 0)
+                                               code = logitech_expanded_keymap[hid];
+                               }
+                       } else {
+                               if (device->quirks & HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL) {
+                                       int hid = usage->hid & HID_USAGE;
+                                       if (hid == 7 || hid == 8)
+                                               goto ignore;
+                               }
+                       }
+
                        map_key(code);
                        break;
 
index a75c236fcafce32d82bd10f4b91a194118b95379..5614a70f564fb04d9ddc006e3561736166953f72 100644 (file)
 #define USB_DEVICE_ID_LOGITECH_WHEEL   0xc294
 #define USB_DEVICE_ID_S510_RECEIVER    0xc50c
 #define USB_DEVICE_ID_S510_RECEIVER_2  0xc517
+#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500  0xc512
 #define USB_DEVICE_ID_MX3000_RECEIVER  0xc513
 #define USB_DEVICE_ID_DINOVO_EDGE      0xc714
 
@@ -422,6 +423,8 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR, HID_QUIRK_IGNORE },
        { USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302, HID_QUIRK_IGNORE },
 
+       { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500, HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL | HID_QUIRK_LOGITECH_EXPANDED_KEYMAP },
+
        { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_MIGHTYMOUSE, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
 
        { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS },
index 4daf5eea78a156bce36663f9c48d48b269782643..44b64f0d0555b5e528bc61deafd6f0255acb70a7 100644 (file)
@@ -274,6 +274,8 @@ struct hid_item {
 #define HID_QUIRK_DUPLICATE_USAGES             0x00080000
 #define HID_QUIRK_RESET_LEDS                   0x00100000
 #define HID_QUIRK_HIDINPUT                     0x00200000
+#define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL        0x00400000
+#define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP     0x00800000
 
 /*
  * Separate quirks for runtime report descriptor fixup