]>
Commit | Line | Data |
---|---|---|
85455dd9 RM |
1 | /* |
2 | * HID driver for Redragon keyboards | |
3 | * | |
4 | * Copyright (c) 2017 Robert Munteanu | |
5 | * SPDX-License-Identifier: GPL-2.0+ | |
6 | */ | |
7 | ||
8 | /* | |
9 | * This program is free software; you can redistribute it and/or modify it | |
10 | * under the terms of the GNU General Public License as published by the Free | |
11 | * Software Foundation; either version 2 of the License, or (at your option) | |
12 | * any later version. | |
13 | */ | |
14 | ||
15 | #include <linux/device.h> | |
16 | #include <linux/hid.h> | |
17 | #include <linux/module.h> | |
18 | ||
19 | #include "hid-ids.h" | |
20 | ||
21 | ||
22 | /* | |
23 | * The Redragon Asura keyboard sends an incorrect HID descriptor. | |
24 | * At byte 100 it contains | |
25 | * | |
26 | * 0x81, 0x00 | |
27 | * | |
28 | * which is Input (Data, Arr, Abs), but it should be | |
29 | * | |
30 | * 0x81, 0x02 | |
31 | * | |
32 | * which is Input (Data, Var, Abs), which is consistent with the way | |
33 | * key codes are generated. | |
34 | */ | |
35 | ||
36 | static __u8 *redragon_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |
37 | unsigned int *rsize) | |
38 | { | |
39 | if (*rsize >= 102 && rdesc[100] == 0x81 && rdesc[101] == 0x00) { | |
40 | dev_info(&hdev->dev, "Fixing Redragon ASURA report descriptor.\n"); | |
41 | rdesc[101] = 0x02; | |
42 | } | |
43 | ||
44 | return rdesc; | |
45 | } | |
46 | ||
85455dd9 RM |
47 | static const struct hid_device_id redragon_devices[] = { |
48 | {HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_REDRAGON_ASURA)}, | |
49 | {} | |
50 | }; | |
51 | ||
52 | MODULE_DEVICE_TABLE(hid, redragon_devices); | |
53 | ||
54 | static struct hid_driver redragon_driver = { | |
55 | .name = "redragon", | |
56 | .id_table = redragon_devices, | |
dc9b8e85 | 57 | .report_fixup = redragon_report_fixup |
85455dd9 RM |
58 | }; |
59 | ||
60 | module_hid_driver(redragon_driver); | |
61 | ||
62 | MODULE_LICENSE("GPL"); |