Fix modifier keys for Redragon Asura Keyboard
RFC PATCH v2 1/1 Fix modifier keys for Redragon Asura Keyboard
Changelog:
- v2: modifier keys work, some combinations are still troublesome
The microdia family of keyboards uses a non-standard way of sending modifier keys.
The down event always sets the first bit to 0x04 and the second keycode to a custom value For instance, left shift sends the following bits
04 02 00 00 00 00 00 00
while left control sends
04 01 00 00 00 00 00 00
As a result all modifier keys are mapped to left shift and the keyboard is non-functional in that respect. To solve the problem, we capture the raw data in raw_event and manually genereate the correct input events.
The keyboard functions mostly as expected now, with only a few minor issues;
- two USB devices are detected instead of 1
- some key combinations are not triggered - e.g. left shift + left ctrl + p. However, the same combination is recognized with the right shift key.
The printk calls will be removed for the final submission.
Tested on Kernel 4.11.4.
--- drivers/hid/Kconfig | 7 +++ drivers/hid/Makefile | 2 +- drivers/hid/hid-core.c | 1 + drivers/hid/hid-ids.h | 3 + drivers/hid/hid-microdia.c | 147 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 drivers/hid/hid-microdia.c
drivers/hid/Kconfig +7 -0
@@ -521,6 +521,13 @@ config HID_MAYFLASH Say Y here if you have HJZ Mayflash PS3 game controller adapters and want to enable force feedback support. +config HID_MICRODIA + tristate "Microdia based keyboards" + depends on HID + default !EXPERT + ---help--- + Support for Microdia based keyboards such as the Redragon Asura. + config HID_MICROSOFT tristate "Microsoft non-fully HID-compliant devices" depends on HID
drivers/hid/Makefile +1 -1
@@ -59,6 +59,7 @@ obj-$(CONFIG_HID_LOGITECH_DJ) += hid-logitech-dj.o obj-$(CONFIG_HID_LOGITECH_HIDPP) += hid-logitech-hidpp.o obj-$(CONFIG_HID_MAGICMOUSE) += hid-magicmouse.o obj-$(CONFIG_HID_MAYFLASH) += hid-mf.o +obj-$(CONFIG_HID_MICRODIA) += hid-microdia.o obj-$(CONFIG_HID_MICROSOFT) += hid-microsoft.o obj-$(CONFIG_HID_MONTEREY) += hid-monterey.o obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o
@@ -116,4 +117,3 @@ obj-$(CONFIG_USB_KBD) += usbhid/ obj-$(CONFIG_I2C_HID) += i2c-hid/ -obj-$(CONFIG_INTEL_ISH_HID) += intel-ish-hid/
drivers/hid/hid-core.c +1 -0
@@ -1974,6 +1974,7 @@ static const struct hid_device_id hid_have_special_driver[] = { { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICOLCD_BOOTLOADER) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_LUXAFOR) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICRODIA, USB_DEVICE_ID_REDRAGON_ASURA) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_KEYBOARD) }, { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV) },
drivers/hid/hid-ids.h +3 -0
@@ -1127,4 +1127,7 @@#define USB_VENDOR_ID_UGTIZER 0x2179#define USB_DEVICE_ID_UGTIZER_TABLET_GP0610 0x0053 +#define USB_VENDOR_ID_MICRODIA 0x0c45 +#define USB_DEVICE_ID_REDRAGON_ASURA 0x760b +#endif
drivers/hid/hid-microdia.c new file +147 -0
147 lines not on this page · raw message
Signature · 1 line
2.13.1
A message that is not in the archive (sent off-list or not yet received): CAAZ5spAeoQ0sycktP7zpoTRMb42EGS2=8ZODzmNi3=80MB-CzA@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAAZ5spAV3tKc-52W4snYq3XRsw9uZ-ikDvAss3dSEk9hnFTitQ@mail.gmail.com
A message that is not in the archive (sent off-list or not yet received): CAAZ5spBy_wzOYgZ42nuet-vp_FR1UHxyzz1fj8qdMqd0-DYuig@mail.gmail.com
Hi Michel,
Quoted 8 lines · Michel Hermier
Are you sure it is the correct way to do it? I mean I looked a little to
the hid descriptor and it seemed to be correct, at least the part that
describe key modifiers. So it smell more like a hid parser bug, forgetting
to consume/declare one byte before the modifiers bits.
I am not sure about the correctness of the approach, thus the RFC :-)
It was also quite easy for me to discover the behaviour when using a new module, but with the existing code base I find it harder to navigate.
Can you point me to where the hid codes are parsed? Is it hidinput_setkeycode in hid-input.c?
Thanks,
Robert