HID: Implement horizontal wheel handling for A4 Tech X5-005D
authorPavel Troller <patrol@sinus.cz>
Mon, 29 Oct 2007 10:13:46 +0000 (11:13 +0100)
committerJiri Kosina <jkosina@suse.cz>
Mon, 28 Jan 2008 13:51:19 +0000 (14:51 +0100)
This mouse distinguishes horizontal wheel from vertical by a special "pseudo
event" GenericDesktop.00b8, with values of 0 for vertical and 8 for horizontal
wheel. Because this event is supplied by the parser too late, we need to delay
a wheel event, wait for this one and send either REL_WHEEL or REL_HWHEEL to
input depending on the event value.

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

index 8c4c908177fa6dfdccebc52d17d213fe11f60490..de270b16bde37ac4c4182d9016295c271f5aa5f5 100644 (file)
@@ -902,9 +902,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        map_key(BTN_1);
        }
 
-       if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5)) &&
-                (usage->type == EV_REL) && (usage->code == REL_WHEEL))
-                       set_bit(REL_HWHEEL, bit);
+       if ((device->quirks & (HID_QUIRK_2WHEEL_MOUSE_HACK_7 | HID_QUIRK_2WHEEL_MOUSE_HACK_5 |
+                       HID_QUIRK_2WHEEL_MOUSE_HACK_B8)) && (usage->type == EV_REL) &&
+                       (usage->code == REL_WHEEL))
+               set_bit(REL_HWHEEL, bit);
 
        if (((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_5) && (usage->hid == 0x00090005))
                || ((device->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_7) && (usage->hid == 0x00090007)))
@@ -1002,6 +1003,19 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
                return;
        }
 
+       if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
+                       (usage->type == EV_REL) &&
+                       (usage->code == REL_WHEEL)) {
+               hid->delayed_value = value;
+               return;
+       }
+
+       if ((hid->quirks & HID_QUIRK_2WHEEL_MOUSE_HACK_B8) &&
+                       (usage->hid == 0x000100b8)) {
+               input_event(input, EV_REL, value ? REL_HWHEEL : REL_WHEEL, hid->delayed_value);
+               return;
+       }
+
        if ((hid->quirks & HID_QUIRK_INVERT_HWHEEL) && (usage->code == REL_HWHEEL)) {
                input_event(input, usage->type, usage->code, -value);
                return;
index 3304b0ab39f7547c550a7ba2a4388d9275884374..836b06a8617373306bc2ad8255c9b5d62b50317b 100644 (file)
@@ -19,6 +19,7 @@
 
 #define USB_VENDOR_ID_A4TECH           0x09da
 #define USB_DEVICE_ID_A4TECH_WCP32PU   0x0006
+#define USB_DEVICE_ID_A4TECH_X5_005D   0x000a
 
 #define USB_VENDOR_ID_AASHIMA          0x06d6
 #define USB_DEVICE_ID_AASHIMA_GAMEPAD  0x0025
@@ -371,6 +372,7 @@ static const struct hid_blacklist {
 } hid_blacklist[] = {
 
        { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU, HID_QUIRK_2WHEEL_MOUSE_HACK_7 },
+       { USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D, HID_QUIRK_2WHEEL_MOUSE_HACK_B8 },
        { USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE, HID_QUIRK_2WHEEL_MOUSE_HACK_5 },
 
        { USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RECEIVER, HID_QUIRK_BAD_RELATIVE_KEYS },
index 833f2af8aab9d9dbe95a0a173bdc4a4f75d986c3..991bbcdc1ca707e0bf5beddf3d52b3155797eba8 100644 (file)
@@ -281,6 +281,7 @@ struct hid_item {
 #define HID_QUIRK_LOGITECH_IGNORE_DOUBLED_WHEEL        0x00400000
 #define HID_QUIRK_LOGITECH_EXPANDED_KEYMAP     0x00800000
 #define HID_QUIRK_IGNORE_HIDINPUT              0x01000000
+#define HID_QUIRK_2WHEEL_MOUSE_HACK_B8         0x02000000
 
 /*
  * Separate quirks for runtime report descriptor fixup
@@ -456,6 +457,8 @@ struct hid_device {                                                 /* device report descriptor */
 
        void *driver_data;
 
+       __s32 delayed_value;                                            /* For A4 Tech mice hwheel quirk */
+
        /* device-specific function pointers */
        int (*hidinput_input_event) (struct input_dev *, unsigned int, unsigned int, int);
        int (*hid_open) (struct hid_device *);