diff options
author | Olivier Scherler <oscherler@ithink.ch> | 2013-07-27 13:20:02 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2013-07-29 05:49:29 -0400 |
commit | cb2c9e3f92480a292670e2cc261723ce4de8059e (patch) | |
tree | 4d10b5d17b78f124b9eeba66c3fcd1e4cc8722c9 | |
parent | dfc450b55d6b9215da27c5dc2c5f3ca1865575a6 (diff) |
HID: Add new driver for non-compliant Xin-Mo devices.
The driver currently only supports the Dual Arcade controller.
It fixes the negative axis event values (the devices sends -2) to match the
logical axis minimum of the HID report descriptor (the report announces -1).
It is needed because hid-input discards out of bounds values.
Signed-off-by: Olivier Scherler <oscherler@ithink.ch>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r-- | drivers/hid/Kconfig | 8 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 3 | ||||
-rw-r--r-- | drivers/hid/hid-xinmo.c | 72 |
5 files changed, 85 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 14ef6ab69790..3d7c9f67b6d7 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -743,6 +743,14 @@ config HID_WIIMOTE | |||
743 | To compile this driver as a module, choose M here: the | 743 | To compile this driver as a module, choose M here: the |
744 | module will be called hid-wiimote. | 744 | module will be called hid-wiimote. |
745 | 745 | ||
746 | config HID_XINMO | ||
747 | tristate "Xin-Mo non-fully compliant devices" | ||
748 | depends on HID | ||
749 | ---help--- | ||
750 | Support for Xin-Mo devices that are not fully compliant with the HID | ||
751 | standard. Currently only supports the Xin-Mo Dual Arcade. Say Y here | ||
752 | if you have a Xin-Mo Dual Arcade controller. | ||
753 | |||
746 | config HID_ZEROPLUS | 754 | config HID_ZEROPLUS |
747 | tristate "Zeroplus based game controller support" | 755 | tristate "Zeroplus based game controller support" |
748 | depends on HID | 756 | depends on HID |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 6f687287e212..a959f4aecaf5 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -110,6 +110,7 @@ obj-$(CONFIG_HID_TIVO) += hid-tivo.o | |||
110 | obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o | 110 | obj-$(CONFIG_HID_TOPSEED) += hid-topseed.o |
111 | obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o | 111 | obj-$(CONFIG_HID_TWINHAN) += hid-twinhan.o |
112 | obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o | 112 | obj-$(CONFIG_HID_UCLOGIC) += hid-uclogic.o |
113 | obj-$(CONFIG_HID_XINMO) += hid-xinmo.o | ||
113 | obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o | 114 | obj-$(CONFIG_HID_ZEROPLUS) += hid-zpff.o |
114 | obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o | 115 | obj-$(CONFIG_HID_ZYDACRON) += hid-zydacron.o |
115 | obj-$(CONFIG_HID_WACOM) += hid-wacom.o | 116 | obj-$(CONFIG_HID_WACOM) += hid-wacom.o |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index a1b248cea5b0..627fea6593a3 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1751,6 +1751,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1751 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, | 1751 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH) }, |
1752 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, | 1752 | { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) }, |
1753 | { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, | 1753 | { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) }, |
1754 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, | ||
1754 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, | 1755 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) }, |
1755 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, | 1756 | { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) }, |
1756 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, | 1757 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 02885319c10a..83622f89fa4b 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -885,6 +885,9 @@ | |||
885 | #define USB_VENDOR_ID_XAT 0x2505 | 885 | #define USB_VENDOR_ID_XAT 0x2505 |
886 | #define USB_DEVICE_ID_XAT_CSR 0x0220 | 886 | #define USB_DEVICE_ID_XAT_CSR 0x0220 |
887 | 887 | ||
888 | #define USB_VENDOR_ID_XIN_MO 0x16c0 | ||
889 | #define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE 0x05e1 | ||
890 | |||
888 | #define USB_VENDOR_ID_XIROKU 0x1477 | 891 | #define USB_VENDOR_ID_XIROKU 0x1477 |
889 | #define USB_DEVICE_ID_XIROKU_SPX 0x1006 | 892 | #define USB_DEVICE_ID_XIROKU_SPX 0x1006 |
890 | #define USB_DEVICE_ID_XIROKU_MPX 0x1007 | 893 | #define USB_DEVICE_ID_XIROKU_MPX 0x1007 |
diff --git a/drivers/hid/hid-xinmo.c b/drivers/hid/hid-xinmo.c new file mode 100644 index 000000000000..6153e50d9721 --- /dev/null +++ b/drivers/hid/hid-xinmo.c | |||
@@ -0,0 +1,72 @@ | |||
1 | /* | ||
2 | * HID driver for Xin-Mo devices, currently only the Dual Arcade controller. | ||
3 | * Fixes the negative axis event values (the devices sends -2) to match the | ||
4 | * logical axis minimum of the HID report descriptor (the report announces | ||
5 | * -1). It is needed because hid-input discards out of bounds values. | ||
6 | * (This module is based on "hid-saitek" and "hid-lg".) | ||
7 | * | ||
8 | * Copyright (c) 2013 Olivier Scherler | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License as published by the Free | ||
14 | * Software Foundation; either version 2 of the License, or (at your option) | ||
15 | * any later version. | ||
16 | */ | ||
17 | |||
18 | #include <linux/device.h> | ||
19 | #include <linux/hid.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/kernel.h> | ||
22 | |||
23 | #include "hid-ids.h" | ||
24 | |||
25 | /* | ||
26 | * Fix negative events that are out of bounds. | ||
27 | */ | ||
28 | static int xinmo_event(struct hid_device *hdev, struct hid_field *field, | ||
29 | struct hid_usage *usage, __s32 value) | ||
30 | { | ||
31 | switch (usage->code) { | ||
32 | case ABS_X: | ||
33 | case ABS_Y: | ||
34 | case ABS_Z: | ||
35 | case ABS_RX: | ||
36 | if (value < -1) { | ||
37 | input_event(field->hidinput->input, usage->type, | ||
38 | usage->code, -1); | ||
39 | return 1; | ||
40 | } | ||
41 | break; | ||
42 | } | ||
43 | |||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static const struct hid_device_id xinmo_devices[] = { | ||
48 | { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) }, | ||
49 | { } | ||
50 | }; | ||
51 | |||
52 | MODULE_DEVICE_TABLE(hid, xinmo_devices); | ||
53 | |||
54 | static struct hid_driver xinmo_driver = { | ||
55 | .name = "xinmo", | ||
56 | .id_table = xinmo_devices, | ||
57 | .event = xinmo_event | ||
58 | }; | ||
59 | |||
60 | static int __init xinmo_init(void) | ||
61 | { | ||
62 | return hid_register_driver(&xinmo_driver); | ||
63 | } | ||
64 | |||
65 | static void __exit xinmo_exit(void) | ||
66 | { | ||
67 | hid_unregister_driver(&xinmo_driver); | ||
68 | } | ||
69 | |||
70 | module_init(xinmo_init); | ||
71 | module_exit(xinmo_exit); | ||
72 | MODULE_LICENSE("GPL"); | ||