Skip to content

Commit 0bb7a37

Browse files
FlameeyesJiri Kosina
authored andcommitted
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>
1 parent f4b65b9 commit 0bb7a37

4 files changed

Lines changed: 61 additions & 11 deletions

File tree

drivers/hid/Kconfig

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,12 @@ config HID_EMS_FF
275275
- Trio Linker Plus II
276276

277277
config HID_ELECOM
278-
tristate "ELECOM BM084 bluetooth mouse"
278+
tristate "ELECOM HID devices"
279279
depends on HID
280280
---help---
281-
Support for the ELECOM BM084 (bluetooth mouse).
281+
Support for ELECOM devices:
282+
- BM084 Bluetooth Mouse
283+
- DEFT Trackball (Wired and wireless)
282284

283285
config HID_ELO
284286
tristate "ELO USB 4000/4500 touchscreen"

drivers/hid/hid-core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1891,6 +1891,8 @@ static const struct hid_device_id hid_have_special_driver[] = {
18911891
{ HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_WN) },
18921892
{ HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, USB_DEVICE_ID_DREAM_CHEEKY_FA) },
18931893
{ 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) },
18941896
{ HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
18951897
{ HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) },
18961898
{ HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },

drivers/hid/hid-elecom.c

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/*
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.
73
* 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>
86
*/
97

108
/*
@@ -23,15 +21,61 @@
2321
static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
2422
unsigned int *rsize)
2523
{
26-
if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) {
27-
hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n");
28-
rdesc[47] = 0x00;
24+
switch (hdev->product) {
25+
case USB_DEVICE_ID_ELECOM_BM084:
26+
/* The BM084 Bluetooth mouse includes a non-existing horizontal
27+
* wheel in the HID descriptor. */
28+
if (*rsize >= 48 && rdesc[46] == 0x05 && rdesc[47] == 0x0c) {
29+
hid_info(hdev, "Fixing up Elecom BM084 report descriptor\n");
30+
rdesc[47] = 0x00;
31+
}
32+
break;
33+
case USB_DEVICE_ID_ELECOM_DEFT_WIRED:
34+
case USB_DEVICE_ID_ELECOM_DEFT_WIRELESS:
35+
/* The DEFT trackball has eight buttons, but its descriptor only
36+
* reports five, disabling the three Fn buttons on the top of
37+
* the mouse.
38+
*
39+
* Apply the following diff to the descriptor:
40+
*
41+
* Collection (Physical), Collection (Physical),
42+
* Report ID (1), Report ID (1),
43+
* Report Count (5), -> Report Count (8),
44+
* Report Size (1), Report Size (1),
45+
* Usage Page (Button), Usage Page (Button),
46+
* Usage Minimum (01h), Usage Minimum (01h),
47+
* Usage Maximum (05h), -> Usage Maximum (08h),
48+
* Logical Minimum (0), Logical Minimum (0),
49+
* Logical Maximum (1), Logical Maximum (1),
50+
* Input (Variable), Input (Variable),
51+
* Report Count (1), -> Report Count (0),
52+
* Report Size (3), Report Size (3),
53+
* Input (Constant), Input (Constant),
54+
* Report Size (16), Report Size (16),
55+
* Report Count (2), Report Count (2),
56+
* Usage Page (Desktop), Usage Page (Desktop),
57+
* Usage (X), Usage (X),
58+
* Usage (Y), Usage (Y),
59+
* Logical Minimum (-32768), Logical Minimum (-32768),
60+
* Logical Maximum (32767), Logical Maximum (32767),
61+
* Input (Variable, Relative), Input (Variable, Relative),
62+
* End Collection, End Collection,
63+
*/
64+
if (*rsize == 213 && rdesc[13] == 5 && rdesc[21] == 5) {
65+
hid_info(hdev, "Fixing up Elecom DEFT Fn buttons\n");
66+
rdesc[13] = 8; /* Button/Variable Report Count */
67+
rdesc[21] = 8; /* Button/Variable Usage Maximum */
68+
rdesc[29] = 0; /* Button/Constant Report Count */
69+
}
70+
break;
2971
}
3072
return rdesc;
3173
}
3274

3375
static const struct hid_device_id elecom_devices[] = {
34-
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084)},
76+
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
77+
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRED) },
78+
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_DEFT_WIRELESS) },
3579
{ }
3680
};
3781
MODULE_DEVICE_TABLE(hid, elecom_devices);

drivers/hid/hid-ids.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,8 @@
358358

359359
#define USB_VENDOR_ID_ELECOM 0x056e
360360
#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
361363

362364
#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34
363365
#define USB_DEVICE_ID_DREAM_CHEEKY_WN 0x0004

0 commit comments

Comments
 (0)