* [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters
@ 2020-11-21 20:54 YOSHIOKA Takuma
2020-11-21 20:54 ` [PATCH 2/2] HID: elecom: add support for EX-G M-XGL20DLBK wireless mouse YOSHIOKA Takuma
2020-11-25 13:28 ` [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters Jiri Kosina
0 siblings, 2 replies; 5+ messages in thread
From: YOSHIOKA Takuma @ 2020-11-21 20:54 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: YOSHIOKA Takuma, linux-input, linux-kernel
The report descriptor for EX-G wireless mouse (M-XGL20DLBK) is a bit
different from that for trackball mice such as DEFT. For such mouse, the
current `mouse_button_fixup` cannot be used as is, because it uses
hard-coded indices for a report descriptor.
Add parameters to `mouse_button_fixup` function, in order to support
fixing report descriptors for more models.
Signed-off-by: YOSHIOKA Takuma <lo48576@hard-wi.red>
---
drivers/hid/hid-elecom.c | 41 ++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c
index 8c712d4bc075..233188100884 100644
--- a/drivers/hid/hid-elecom.c
+++ b/drivers/hid/hid-elecom.c
@@ -11,6 +11,7 @@
* Copyright (c) 2017 Diego Elio Pettenò <flameeyes@flameeyes.eu>
* Copyright (c) 2017 Alex Manoussakis <amanou@gnu.org>
* Copyright (c) 2017 Tomasz Kramkowski <tk@the-tk.com>
+ * Copyright (c) 2020 YOSHIOKA Takuma <lo48576@hard-wi.red>
*/
/*
@@ -29,25 +30,26 @@
* report descriptor but it does not appear that these enable software to
* control what the extra buttons map to. The only simple and straightforward
* solution seems to involve fixing up the report descriptor.
- *
- * Report descriptor format:
- * Positions 13, 15, 21 and 31 store the button bit count, button usage minimum,
- * button usage maximum and padding bit count respectively.
*/
#define MOUSE_BUTTONS_MAX 8
static void mouse_button_fixup(struct hid_device *hdev,
__u8 *rdesc, unsigned int rsize,
+ unsigned int button_bit_count,
+ unsigned int padding_bit,
+ unsigned int button_report_size,
+ unsigned int button_usage_maximum,
int nbuttons)
{
- if (rsize < 32 || rdesc[12] != 0x95 ||
- rdesc[14] != 0x75 || rdesc[15] != 0x01 ||
- rdesc[20] != 0x29 || rdesc[30] != 0x75)
+ if (rsize < 32 || rdesc[button_bit_count] != 0x95 ||
+ rdesc[button_report_size] != 0x75 ||
+ rdesc[button_report_size + 1] != 0x01 ||
+ rdesc[button_usage_maximum] != 0x29 || rdesc[padding_bit] != 0x75)
return;
hid_info(hdev, "Fixing up Elecom mouse button count\n");
nbuttons = clamp(nbuttons, 0, MOUSE_BUTTONS_MAX);
- rdesc[13] = nbuttons;
- rdesc[21] = nbuttons;
- rdesc[31] = MOUSE_BUTTONS_MAX - nbuttons;
+ rdesc[button_bit_count + 1] = nbuttons;
+ rdesc[button_usage_maximum + 1] = nbuttons;
+ rdesc[padding_bit + 1] = MOUSE_BUTTONS_MAX - nbuttons;
}
static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -65,13 +67,28 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
case USB_DEVICE_ID_ELECOM_M_XT3URBK:
case USB_DEVICE_ID_ELECOM_M_XT3DRBK:
case USB_DEVICE_ID_ELECOM_M_XT4DRBK:
- mouse_button_fixup(hdev, rdesc, *rsize, 6);
+ /*
+ * Report descriptor format:
+ * 12: button bit count
+ * 30: padding bit count
+ * 14: button report size
+ * 20: button usage maximum
+ */
+ mouse_button_fixup(hdev, rdesc, *rsize, 12, 30, 14, 20, 6);
break;
case USB_DEVICE_ID_ELECOM_M_DT1URBK:
case USB_DEVICE_ID_ELECOM_M_DT1DRBK:
case USB_DEVICE_ID_ELECOM_M_HT1URBK:
case USB_DEVICE_ID_ELECOM_M_HT1DRBK:
- mouse_button_fixup(hdev, rdesc, *rsize, 8);
+ /*mouse_button_fixup(hdev, rdesc, *rsize, 13, 15, 21, 31, 8);*/
+ /*
+ * Report descriptor format:
+ * 12: button bit count
+ * 30: padding bit count
+ * 14: button report size
+ * 20: button usage maximum
+ */
+ mouse_button_fixup(hdev, rdesc, *rsize, 12, 30, 14, 20, 8);
break;
}
return rdesc;
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] HID: elecom: add support for EX-G M-XGL20DLBK wireless mouse
2020-11-21 20:54 [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters YOSHIOKA Takuma
@ 2020-11-21 20:54 ` YOSHIOKA Takuma
2020-11-25 13:28 ` [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters Jiri Kosina
1 sibling, 0 replies; 5+ messages in thread
From: YOSHIOKA Takuma @ 2020-11-21 20:54 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires
Cc: YOSHIOKA Takuma, linux-input, linux-kernel
Enables three buttons (Fn1, Fn2, and Fn3) on the ELECOM M-XGL20DLBK
wireless mouse.
While this mouse is EX-G brand, report descriptor is a bit different
from EX-G trackball mouse. To enable extra buttons, report should be
rewritten in a similar way to trackballs, but with different position
parameters.
Signed-off-by: YOSHIOKA Takuma <lo48576@hard-wi.red>
---
drivers/hid/hid-elecom.c | 11 +++++++++++
drivers/hid/hid-ids.h | 1 +
drivers/hid/hid-quirks.c | 1 +
3 files changed, 13 insertions(+)
diff --git a/drivers/hid/hid-elecom.c b/drivers/hid/hid-elecom.c
index 233188100884..3bd7207de2e8 100644
--- a/drivers/hid/hid-elecom.c
+++ b/drivers/hid/hid-elecom.c
@@ -64,6 +64,16 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
rdesc[47] = 0x00;
}
break;
+ case USB_DEVICE_ID_ELECOM_M_XGL20DLBK:
+ /*
+ * Report descriptor format:
+ * 20: button bit count
+ * 28: padding bit count
+ * 22: button report size
+ * 14: button usage maximum
+ */
+ mouse_button_fixup(hdev, rdesc, *rsize, 20, 28, 22, 14, 8);
+ break;
case USB_DEVICE_ID_ELECOM_M_XT3URBK:
case USB_DEVICE_ID_ELECOM_M_XT3DRBK:
case USB_DEVICE_ID_ELECOM_M_XT4DRBK:
@@ -96,6 +106,7 @@ static __u8 *elecom_report_fixup(struct hid_device *hdev, __u8 *rdesc,
static const struct hid_device_id elecom_devices[] = {
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
+ { HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XGL20DLBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index d69842f79fc6..a29f4dacf640 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -388,6 +388,7 @@
#define USB_VENDOR_ID_ELECOM 0x056e
#define USB_DEVICE_ID_ELECOM_BM084 0x0061
+#define USB_DEVICE_ID_ELECOM_M_XGL20DLBK 0x00e6
#define USB_DEVICE_ID_ELECOM_M_XT3URBK 0x00fb
#define USB_DEVICE_ID_ELECOM_M_XT3DRBK 0x00fc
#define USB_DEVICE_ID_ELECOM_M_XT4DRBK 0x00fd
diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c
index 7a2be0205dfd..9355d92c6f14 100644
--- a/drivers/hid/hid-quirks.c
+++ b/drivers/hid/hid-quirks.c
@@ -361,6 +361,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
#endif
#if IS_ENABLED(CONFIG_HID_ELECOM)
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
+ { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XGL20DLBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3URBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT3DRBK) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_M_XT4DRBK) },
--
2.29.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters
2020-11-21 20:54 [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters YOSHIOKA Takuma
2020-11-21 20:54 ` [PATCH 2/2] HID: elecom: add support for EX-G M-XGL20DLBK wireless mouse YOSHIOKA Takuma
@ 2020-11-25 13:28 ` Jiri Kosina
2020-11-25 14:33 ` Takuma YOSHIOKA
1 sibling, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2020-11-25 13:28 UTC (permalink / raw)
To: YOSHIOKA Takuma; +Cc: Benjamin Tissoires, linux-input, linux-kernel
On Sun, 22 Nov 2020, YOSHIOKA Takuma wrote:
> The report descriptor for EX-G wireless mouse (M-XGL20DLBK) is a bit
> different from that for trackball mice such as DEFT. For such mouse, the
> current `mouse_button_fixup` cannot be used as is, because it uses
> hard-coded indices for a report descriptor.
>
> Add parameters to `mouse_button_fixup` function, in order to support
> fixing report descriptors for more models.
I have applied both patches, thank you.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters
2020-11-25 13:28 ` [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters Jiri Kosina
@ 2020-11-25 14:33 ` Takuma YOSHIOKA
2020-11-25 16:41 ` Jiri Kosina
0 siblings, 1 reply; 5+ messages in thread
From: Takuma YOSHIOKA @ 2020-11-25 14:33 UTC (permalink / raw)
To: Jiri Kosina; +Cc: Benjamin Tissoires, linux-input, linux-kernel
On 2020/11/22 5:54, YOSHIOKA Takuma wrote:
> case USB_DEVICE_ID_ELECOM_M_DT1URBK:
> case USB_DEVICE_ID_ELECOM_M_DT1DRBK:
> case USB_DEVICE_ID_ELECOM_M_HT1URBK:
> case USB_DEVICE_ID_ELECOM_M_HT1DRBK:
> - mouse_button_fixup(hdev, rdesc, *rsize, 8);
> + /*mouse_button_fixup(hdev, rdesc, *rsize, 13, 15, 21, 31, 8);*/
I'm very very sorry, I noticed that I've forgotten to remove this commented-out line...
This "13, 15, 21, 31" line should be removed completely.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters
2020-11-25 14:33 ` Takuma YOSHIOKA
@ 2020-11-25 16:41 ` Jiri Kosina
0 siblings, 0 replies; 5+ messages in thread
From: Jiri Kosina @ 2020-11-25 16:41 UTC (permalink / raw)
To: Takuma YOSHIOKA; +Cc: Benjamin Tissoires, linux-input, linux-kernel
On Wed, 25 Nov 2020, Takuma YOSHIOKA wrote:
> > case USB_DEVICE_ID_ELECOM_M_DT1URBK:
> > case USB_DEVICE_ID_ELECOM_M_DT1DRBK:
> > case USB_DEVICE_ID_ELECOM_M_HT1URBK:
> > case USB_DEVICE_ID_ELECOM_M_HT1DRBK:
> > - mouse_button_fixup(hdev, rdesc, *rsize, 8);
> > + /*mouse_button_fixup(hdev, rdesc, *rsize, 13, 15, 21, 31, 8);*/
>
> I'm very very sorry, I noticed that I've forgotten to remove this commented-out line...
> This "13, 15, 21, 31" line should be removed completely.
No worries, I've dropped that one already. Thanks,
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-11-25 16:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-21 20:54 [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters YOSHIOKA Takuma
2020-11-21 20:54 ` [PATCH 2/2] HID: elecom: add support for EX-G M-XGL20DLBK wireless mouse YOSHIOKA Takuma
2020-11-25 13:28 ` [PATCH 1/2] HID: elecom: rewrite report based on model specific parameters Jiri Kosina
2020-11-25 14:33 ` Takuma YOSHIOKA
2020-11-25 16:41 ` Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.