Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

HID: elecom: extend to fix the descriptor for DEFT trackballs

The ELECOM DEFT trackballs report only five buttons, when the device
actually has 8. Change the descriptor so that the HID driver can see all of
them.

For completeness and future reference, I included a side-by-side diff of
the part of the descriptor that is being edited.

Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

authored by

Diego Elio Pettenò and committed by
Jiri Kosina
0bb7a37f f4b65b95

+61 -11
+4 -2
drivers/hid/Kconfig
··· 275 275 - Trio Linker Plus II 276 276 277 277 config HID_ELECOM 278 - tristate "ELECOM BM084 bluetooth mouse" 278 + tristate "ELECOM HID devices" 279 279 depends on HID 280 280 ---help--- 281 - Support for the ELECOM BM084 (bluetooth mouse). 281 + Support for ELECOM devices: 282 + - BM084 Bluetooth Mouse 283 + - DEFT Trackball (Wired and wireless) 282 284 283 285 config HID_ELO 284 286 tristate "ELO USB 4000/4500 touchscreen"
+2
drivers/hid/hid-core.c
··· 1891 1891 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) }, 1892 1892 { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) }, 1893 1893 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 1894 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) }, 1895 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) }, 1894 1896 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) }, 1895 1897 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) }, 1896 1898 { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
+53 -9
drivers/hid/hid-elecom.c
··· 1 1 /* 2 - * HID driver for Elecom BM084 (bluetooth mouse). 3 - * Removes a non-existing horizontal wheel from 4 - * the HID descriptor. 5 - * (This module is based on "hid-ortek".) 6 - * 2 + * HID driver for ELECOM devices. 7 3 * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com> 4 + * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com> 5 + * Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu> 8 6 */ 9 7 10 8 /* ··· 21 23 static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc, 22 24 unsigned int *rsize) 23 25 { 24 - if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) { 25 - hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n"); 26 - rdesc[47] = 0x00; 26 + switch (hdev->product) { 27 + case USB_DEVICE_ID_ELECOM_BM084: 28 + /* The BM084 Bluetooth mouse includes a non-existing horizontal 29 + * wheel in the HID descriptor. */ 30 + if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) { 31 + hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n"); 32 + rdesc[47] = 0x00; 33 + } 34 + break; 35 + case USB_DEVICE_ID_ELECOM_DEFT_WIRED: 36 + case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS: 37 + /* The DEFT trackball has eight buttons, but its descriptor only 38 + * reports five, disabling the three Fn buttons on the top of 39 + * the mouse. 40 + * 41 + * Apply the following diff to the descriptor: 42 + * 43 + * Collection (Physical), Collection (Physical), 44 + * Report ID (1), Report ID (1), 45 + * Report Count (5), -> Report Count (8), 46 + * Report Size (1), Report Size (1), 47 + * Usage Page (Button), Usage Page (Button), 48 + * Usage Minimum (01h), Usage Minimum (01h), 49 + * Usage Maximum (05h), -> Usage Maximum (08h), 50 + * Logical Minimum (0), Logical Minimum (0), 51 + * Logical Maximum (1), Logical Maximum (1), 52 + * Input (Variable), Input (Variable), 53 + * Report Count (1), -> Report Count (0), 54 + * Report Size (3), Report Size (3), 55 + * Input (Constant), Input (Constant), 56 + * Report Size (16), Report Size (16), 57 + * Report Count (2), Report Count (2), 58 + * Usage Page (Desktop), Usage Page (Desktop), 59 + * Usage (X), Usage (X), 60 + * Usage (Y), Usage (Y), 61 + * Logical Minimum (-32768), Logical Minimum (-32768), 62 + * Logical Maximum (32767), Logical Maximum (32767), 63 + * Input (Variable, Relative), Input (Variable, Relative), 64 + * End Collection, End Collection, 65 + */ 66 + if (*rsize == 213 && rdesc[13] == 5 && rdesc[21] == 5) { 67 + hid_info(hdev, "Fixing up Elecom DEFT Fn buttons\n"); 68 + rdesc[13] = 8; /* Button/Variable Report Count */ 69 + rdesc[21] = 8; /* Button/Variable Usage Maximum */ 70 + rdesc[29] = 0; /* Button/Constant Report Count */ 71 + } 72 + break; 27 73 } 28 74 return rdesc; 29 75 } 30 76 31 77 static const struct hid_device_id elecom_devices[] = { 32 - { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084)}, 78 + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) }, 79 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) }, 80 + { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) }, 33 81 { } 34 82 }; 35 83 MODULE_DEVICE_TABLE(hid, elecom_devices);
+2
drivers/hid/hid-ids.h
··· 358 358 359 359 #define USB_VENDOR_ID_ELECOM 0x056e 360 360 #define USB_DEVICE_ID_ELECOM_BM084 0x0061 361 + #define USB_DEVICE_ID_ELECOM_DEFT_WIRED 0x00fe 362 + #define USB_DEVICE_ID_ELECOM_DEFT_WIRELESS 0x00ff 361 363 362 364 #define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34 363 365 #define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004