aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-saitek.c
diff options
context:
space:
mode:
authorJiri Kosina <jkosina@suse.cz>2012-03-20 08:18:05 -0400
committerJiri Kosina <jkosina@suse.cz>2012-03-20 08:18:05 -0400
commit4a247a4119ee932e06e985e0a95a13c3eed4715b (patch)
tree42b6a7c9edf2f40c7b645a493d63bdb67e5f7100 /drivers/hid/hid-saitek.c
parent77aa8e65f0e20c294907a9fa8af92a3dbe0e0a51 (diff)
parent4d5df5d11e8027c11c1079205757527cbaade62d (diff)
Merge branch 'upstream' into for-linus
Conflicts: drivers/hid/Makefile
Diffstat (limited to 'drivers/hid/hid-saitek.c')
-rw-r--r--drivers/hid/hid-saitek.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/drivers/hid/hid-saitek.c b/drivers/hid/hid-saitek.c
new file mode 100644
index 000000000000..45aea77bb611
--- /dev/null
+++ b/drivers/hid/hid-saitek.c
@@ -0,0 +1,70 @@
1/*
2 * HID driver for Saitek devices, currently only the PS1000 (USB gamepad).
3 * Fixes the HID report descriptor by removing a non-existent axis and
4 * clearing the constant bit on the input reports for buttons and d-pad.
5 * (This module is based on "hid-ortek".)
6 *
7 * Copyright (c) 2012 Andreas Hübner
8 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version.
15 */
16
17#include <linux/device.h>
18#include <linux/hid.h>
19#include <linux/module.h>
20#include <linux/kernel.h>
21
22#include "hid-ids.h"
23
24static __u8 *saitek_report_fixup(struct hid_device *hdev, __u8 *rdesc,
25 unsigned int *rsize)
26{
27 if (*rsize == 137 && rdesc[20] == 0x09 && rdesc[21] == 0x33
28 && rdesc[94] == 0x81 && rdesc[95] == 0x03
29 && rdesc[110] == 0x81 && rdesc[111] == 0x03) {
30
31 hid_info(hdev, "Fixing up Saitek PS1000 report descriptor\n");
32
33 /* convert spurious axis to a "noop" Logical Minimum (0) */
34 rdesc[20] = 0x15;
35 rdesc[21] = 0x00;
36
37 /* clear constant bit on buttons and d-pad */
38 rdesc[95] = 0x02;
39 rdesc[111] = 0x02;
40
41 }
42 return rdesc;
43}
44
45static const struct hid_device_id saitek_devices[] = {
46 { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_PS1000)},
47 { }
48};
49
50MODULE_DEVICE_TABLE(hid, saitek_devices);
51
52static struct hid_driver saitek_driver = {
53 .name = "saitek",
54 .id_table = saitek_devices,
55 .report_fixup = saitek_report_fixup
56};
57
58static int __init saitek_init(void)
59{
60 return hid_register_driver(&saitek_driver);
61}
62
63static void __exit saitek_exit(void)
64{
65 hid_unregister_driver(&saitek_driver);
66}
67
68module_init(saitek_init);
69module_exit(saitek_exit);
70MODULE_LICENSE("GPL");