]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
HID: fix horizontal wheel for ms comfort mouse 4500
authorAri Savolainen <ari.m.savolainen@gmail.com>
Mon, 11 Jul 2011 18:42:52 +0000 (21:42 +0300)
committerJiri Kosina <jkosina@suse.cz>
Tue, 12 Jul 2011 08:31:56 +0000 (10:31 +0200)
Microsoft comfort mouse 4500 report descriptor contains duplicate
usages for horizontal wheel. This patch fixes the wrong mapping
caused by that.

Signed-off-by: Ari Savolainen <ari.m.savolainen@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-ids.h
drivers/hid/hid-microsoft.c

index 8c00e4a261a938c64a5ee715bea80946f8788bbc..2c8594767191dfd521cb57dab4c95ff16e3a4b5d 100644 (file)
 #define USB_DEVICE_ID_MS_PRESENTER_8K_BT       0x0701
 #define USB_DEVICE_ID_MS_PRESENTER_8K_USB      0x0713
 #define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K      0x0730
+#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500    0x076c
 
 #define USB_VENDOR_ID_MOJO             0x8282
 #define USB_DEVICE_ID_RETRO_ADAPTER    0x3201
index df91791f88d32b5374cdfaee258dd98af89a5e57..e5c699b6c6f30656e8150a012eac160fccfd26e6 100644 (file)
 
 #include "hid-ids.h"
 
-#define MS_HIDINPUT    0x01
-#define MS_ERGONOMY    0x02
-#define MS_PRESENTER   0x04
-#define MS_RDESC       0x08
-#define MS_NOGET       0x10
+#define MS_HIDINPUT            0x01
+#define MS_ERGONOMY            0x02
+#define MS_PRESENTER           0x04
+#define MS_RDESC               0x08
+#define MS_NOGET               0x10
+#define MS_DUPLICATE_USAGES    0x20
 
 /*
  * Microsoft Wireless Desktop Receiver (Model 1028) has
@@ -109,6 +110,18 @@ static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi,
        return 0;
 }
 
+static int ms_input_mapped(struct hid_device *hdev, struct hid_input *hi,
+               struct hid_field *field, struct hid_usage *usage,
+               unsigned long **bit, int *max)
+{
+       unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
+
+       if (quirks & MS_DUPLICATE_USAGES)
+               clear_bit(usage->code, *bit);
+
+       return 0;
+}
+
 static int ms_event(struct hid_device *hdev, struct hid_field *field,
                struct hid_usage *usage, __s32 value)
 {
@@ -183,6 +196,8 @@ static const struct hid_device_id ms_devices[] = {
                .driver_data = MS_ERGONOMY },
        { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0),
                .driver_data = MS_NOGET },
+       { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500),
+               .driver_data = MS_DUPLICATE_USAGES },
 
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT),
                .driver_data = MS_PRESENTER },
@@ -195,6 +210,7 @@ static struct hid_driver ms_driver = {
        .id_table = ms_devices,
        .report_fixup = ms_report_fixup,
        .input_mapping = ms_input_mapping,
+       .input_mapped = ms_input_mapped,
        .event = ms_event,
        .probe = ms_probe,
 };