Skip to contentSkip to conversation

HID: add driver for EWEADN G5 mice

PATCH New Liang Haowen 1 participant 1 message Nov 1 HID

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 HID: add driver for EWEADN G5 mice

EWEADN G5 mice (YJX-CHIP receivers 0xa8a5:2255, replacement units and the wired mouse 0xa8a4:2255) send motion and buttons in a 9-byte vendor report on interface 0. The report descriptor the firmware ships does not describe that data: the 0xa8a5 receivers declare vendor usages with no mouse mapping, and the 0xa8a4 units declare a standard mouse report the firmware then does not send. Either way the stock input path produces no pointer events, and there is no Linux driver from the vendor.

The report itself is a plain mouse report: buttons, int16 dx and dy, an int8 wheel. Replace the descriptor at parse time with one that describes exactly that report, so hid-core can parse the frames with no custom event handling. The keyboard and vendor-configuration interfaces bind to this driver too and keep their own descriptors untouched.

Both device IDs bind with the fixed-up descriptor, and motion events flow through the stock input path. This also makes the userspace relay used until now (github.com/NB-Group/g5moused) unnecessary.

---
Changes in v3, from the review of v2:

- Include "hid-ids.h": the id_table uses USB_VENDOR_ID_YJXCHIP and USB_DEVICE_ID_YJXCHIP_MOUSE, and nothing else pulls that header in, so the driver does not build without it.

- Drop the custom probe callback: it duplicated what the HID bus default already does for drivers without a probe, like the other fixup-only drivers.

Changes in v2, from the review of v1:

- Bind all interfaces of the composite device instead of returning -ENODEV for the non-mouse ones: hid-generic steps aside for any registered driver whose id_table matches, so rejecting them left the keyboard and vendor-configuration interfaces with no driver at all. Only the mouse interface gets the fixed-up descriptor now; the others keep their own.

- Guard the USB interface lookup with hid_is_usb(): a virtual HID device created through /dev/uhid can claim BUS_USB with matching vendor and product IDs, and casting its parent would dereference memory that is not a usb_interface.

- Use the USB_VENDOR_ID_YJXCHIP macro for the original receiver.

---
 drivers/hid/Kconfig      |   9 ++++
 drivers/hid/Makefile     |   1 +
 drivers/hid/hid-eweadn.c | 109 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 119 insertions(+)
 create mode 100644 drivers/hid/hid-eweadn.c
drivers/hid/Kconfig +9 -0
index 2481bc0..3946f75 100644
@@ -380,6 +380,15 @@ config HID_EVISION
 	applying customization using userspace programs.
 	Support for some EVision devices requiring report descriptor fixups.
 
+config HID_EWEADN
+	tristate "EWEADN G5 mice support"
+	depends on USB_HID
+	help
+	Support for EWEADN G5 wireless mice (YJX-CHIP 0xa8a5:2255 receivers,
+	0xa8a4 replacement units and the wired mouse). The stock report
+	descriptor does not describe the reports the firmware sends, so
+	the pointer is dead without this fixup.
+
 config HID_EZKEY
 	tristate "Ezkey BTC 8193 keyboard"
 	help
drivers/hid/Makefile +1 -0
index 43a8eb0..2db5b5d 100644
@@ -51,6 +51,7 @@ obj-$(CONFIG_HID_ELAN)		+= hid-elan.o
 obj-$(CONFIG_HID_ELECOM)	+= hid-elecom.o
 obj-$(CONFIG_HID_ELO)		+= hid-elo.o
 obj-$(CONFIG_HID_EVISION)	+= hid-evision.o
+obj-$(CONFIG_HID_EWEADN)	+= hid-eweadn.o
 obj-$(CONFIG_HID_EZKEY)		+= hid-ezkey.o
 obj-$(CONFIG_HID_FT260)		+= hid-ft260.o
 obj-$(CONFIG_HID_GEMBIRD)	+= hid-gembird.o
drivers/hid/hid-eweadn.c new file +109 -0

109 lines not on this page · raw message

Signature · 1 line
2.55.0