diff options
author | David Herrmann <dh.herrmann@googlemail.com> | 2011-07-05 07:45:09 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-07-11 08:30:22 -0400 |
commit | 02fb72a06ae1ed55b4373a4c678f25d70fd65902 (patch) | |
tree | ddb12e5aae98bf7667cecdad5bdad0f106cea09e /drivers/hid | |
parent | fb51b44385a0ded0d629d5cf4a2095f80fb01b56 (diff) |
HID: wiimote: Register wiimote hid driver stub
The wiimote uses a fake HID protocol. Hence, we need to prevent
HIDINPUT and HIDDEV from parsing wiimote data and instead parse
raw hid events.
Add VID/PID to hid-core so the special driver is loaded on new
wiimotes.
Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r-- | drivers/hid/hid-core.c | 1 | ||||
-rw-r--r-- | drivers/hid/hid-ids.h | 3 | ||||
-rw-r--r-- | drivers/hid/hid-wiimote.c | 62 |
3 files changed, 65 insertions, 1 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 6f3289a57888..eccaf8ad26c1 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
@@ -1504,6 +1504,7 @@ static const struct hid_device_id hid_have_special_driver[] = { | |||
1504 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, | 1504 | { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) }, |
1505 | 1505 | ||
1506 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, | 1506 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_PRESENTER_8K_BT) }, |
1507 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | ||
1507 | { } | 1508 | { } |
1508 | }; | 1509 | }; |
1509 | 1510 | ||
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index a756ee6c7df5..dfe252896932 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
@@ -495,6 +495,9 @@ | |||
495 | #define USB_VENDOR_ID_NEXTWINDOW 0x1926 | 495 | #define USB_VENDOR_ID_NEXTWINDOW 0x1926 |
496 | #define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003 | 496 | #define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003 |
497 | 497 | ||
498 | #define USB_VENDOR_ID_NINTENDO 0x057e | ||
499 | #define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 | ||
500 | |||
498 | #define USB_VENDOR_ID_NTRIG 0x1b96 | 501 | #define USB_VENDOR_ID_NTRIG 0x1b96 |
499 | #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 | 502 | #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 |
500 | #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1 0x0003 | 503 | #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1 0x0003 |
diff --git a/drivers/hid/hid-wiimote.c b/drivers/hid/hid-wiimote.c index 8a770e62a8b4..ed4fe18c7fb5 100644 --- a/drivers/hid/hid-wiimote.c +++ b/drivers/hid/hid-wiimote.c | |||
@@ -10,18 +10,78 @@ | |||
10 | * any later version. | 10 | * any later version. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/hid.h> | ||
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
15 | #include "hid-ids.h" | ||
14 | 16 | ||
15 | #define WIIMOTE_VERSION "0.1" | 17 | #define WIIMOTE_VERSION "0.1" |
16 | #define WIIMOTE_NAME "Nintendo Wii Remote" | 18 | #define WIIMOTE_NAME "Nintendo Wii Remote" |
17 | 19 | ||
18 | static int __init wiimote_init(void) | 20 | static int wiimote_hid_event(struct hid_device *hdev, struct hid_report *report, |
21 | u8 *raw_data, int size) | ||
22 | { | ||
23 | if (size < 1) | ||
24 | return -EINVAL; | ||
25 | |||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | static int wiimote_hid_probe(struct hid_device *hdev, | ||
30 | const struct hid_device_id *id) | ||
19 | { | 31 | { |
32 | int ret; | ||
33 | |||
34 | ret = hid_parse(hdev); | ||
35 | if (ret) { | ||
36 | hid_err(hdev, "HID parse failed\n"); | ||
37 | return ret; | ||
38 | } | ||
39 | |||
40 | ret = hid_hw_start(hdev, HID_CONNECT_HIDRAW); | ||
41 | if (ret) { | ||
42 | hid_err(hdev, "HW start failed\n"); | ||
43 | return ret; | ||
44 | } | ||
45 | |||
46 | hid_info(hdev, "New device registered\n"); | ||
20 | return 0; | 47 | return 0; |
21 | } | 48 | } |
22 | 49 | ||
50 | static void wiimote_hid_remove(struct hid_device *hdev) | ||
51 | { | ||
52 | hid_info(hdev, "Device removed\n"); | ||
53 | hid_hw_stop(hdev); | ||
54 | } | ||
55 | |||
56 | static const struct hid_device_id wiimote_hid_devices[] = { | ||
57 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO, | ||
58 | USB_DEVICE_ID_NINTENDO_WIIMOTE) }, | ||
59 | { } | ||
60 | }; | ||
61 | MODULE_DEVICE_TABLE(hid, wiimote_hid_devices); | ||
62 | |||
63 | static struct hid_driver wiimote_hid_driver = { | ||
64 | .name = "wiimote", | ||
65 | .id_table = wiimote_hid_devices, | ||
66 | .probe = wiimote_hid_probe, | ||
67 | .remove = wiimote_hid_remove, | ||
68 | .raw_event = wiimote_hid_event, | ||
69 | }; | ||
70 | |||
71 | static int __init wiimote_init(void) | ||
72 | { | ||
73 | int ret; | ||
74 | |||
75 | ret = hid_register_driver(&wiimote_hid_driver); | ||
76 | if (ret) | ||
77 | pr_err("Can't register wiimote hid driver\n"); | ||
78 | |||
79 | return ret; | ||
80 | } | ||
81 | |||
23 | static void __exit wiimote_exit(void) | 82 | static void __exit wiimote_exit(void) |
24 | { | 83 | { |
84 | hid_unregister_driver(&wiimote_hid_driver); | ||
25 | } | 85 | } |
26 | 86 | ||
27 | module_init(wiimote_init); | 87 | module_init(wiimote_init); |