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