1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * HID driver for Rakk devices 4 * 5 * Copyright (c) 2026 Karl Cayme 6 * 7 * The Rakk Dasig X gaming mouse has a faulty HID report descriptor that 8 * declares USAGE_MAXIMUM = 3 (buttons 1-3) while actually sending 5 button 9 * bits (REPORT_COUNT = 5). This causes the kernel to ignore side buttons 10 * (buttons 4 and 5). This driver fixes the descriptor so all 5 buttons 11 * are properly recognized across 3 modes (wired, dongle, and Bluetooth). 12 */ 13 14 #include <linux/device.h> 15 #include <linux/hid.h> 16 #include <linux/module.h> 17 #include "hid-ids.h" 18 19 /* 20 * The faulty byte is at offset 17 in the report descriptor for all three 21 * connection modes (USB direct, wireless dongle, and Bluetooth). 22 * 23 * Bytes 16-17 are: 0x29 0x03 (USAGE_MAXIMUM = 3) 24 * The fix changes byte 17 to 0x05 (USAGE_MAXIMUM = 5). 25 * 26 * Original descriptor bytes 0-17: 27 * 05 01 09 02 a1 01 85 01 09 01 a1 00 05 09 19 01 29 03 28 * ^^ 29 * Should be 0x05 to declare 5 buttons instead of 3. 30 */ 31 #define RAKK_RDESC_USAGE_MAX_OFFSET 17 32 #define RAKK_RDESC_USAGE_MAX_ORIG 0x03 33 #define RAKK_RDESC_USAGE_MAX_FIXED 0x05 34 #define RAKK_RDESC_USB_SIZE 193 35 #define RAKK_RDESC_DONGLE_SIZE 150 36 #define RAKK_RDESC_BT_SIZE 89 37 38 static const __u8 *rakk_report_fixup(struct hid_device *hdev, __u8 *rdesc, 39 unsigned int *rsize) 40 { 41 if (((*rsize == RAKK_RDESC_USB_SIZE && 42 hdev->product == USB_DEVICE_ID_TELINK_RAKK_DASIG_X) || 43 (*rsize == RAKK_RDESC_DONGLE_SIZE && 44 hdev->product == USB_DEVICE_ID_TELINK_RAKK_DASIG_X_DONGLE) || 45 (*rsize == RAKK_RDESC_BT_SIZE && 46 hdev->product == USB_DEVICE_ID_TELINK_RAKK_DASIG_X_BT)) && 47 rdesc[RAKK_RDESC_USAGE_MAX_OFFSET] == RAKK_RDESC_USAGE_MAX_ORIG) { 48 hid_info(hdev, "fixing Rakk Dasig X button count (3 -> 5)\n"); 49 rdesc[RAKK_RDESC_USAGE_MAX_OFFSET] = RAKK_RDESC_USAGE_MAX_FIXED; 50 } 51 52 return rdesc; 53 } 54 55 static const struct hid_device_id rakk_devices[] = { 56 { HID_USB_DEVICE(USB_VENDOR_ID_TELINK, 57 USB_DEVICE_ID_TELINK_RAKK_DASIG_X) }, 58 { HID_USB_DEVICE(USB_VENDOR_ID_TELINK, 59 USB_DEVICE_ID_TELINK_RAKK_DASIG_X_DONGLE) }, 60 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_TELINK, 61 USB_DEVICE_ID_TELINK_RAKK_DASIG_X_BT) }, 62 { } 63 }; 64 MODULE_DEVICE_TABLE(hid, rakk_devices); 65 66 static struct hid_driver rakk_driver = { 67 .name = "rakk", 68 .id_table = rakk_devices, 69 .report_fixup = rakk_report_fixup, 70 }; 71 module_hid_driver(rakk_driver); 72 73 MODULE_DESCRIPTION("HID driver for Rakk Dasig X mouse - fix side button support"); 74 MODULE_LICENSE("GPL"); 75 MODULE_AUTHOR("Karl Cayme"); 76