aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid/hid-wiimote.c
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@googlemail.com>2011-07-05 07:45:09 -0400
committerJiri Kosina <jkosina@suse.cz>2011-07-11 08:30:22 -0400
commit02fb72a06ae1ed55b4373a4c678f25d70fd65902 (patch)
treeddb12e5aae98bf7667cecdad5bdad0f106cea09e /drivers/hid/hid-wiimote.c
parentfb51b44385a0ded0d629d5cf4a2095f80fb01b56 (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/hid-wiimote.c')
-rw-r--r--drivers/hid/hid-wiimote.c62
1 files changed, 61 insertions, 1 deletions
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
18static int __init wiimote_init(void) 20static 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
29static 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
50static void wiimote_hid_remove(struct hid_device *hdev)
51{
52 hid_info(hdev, "Device removed\n");
53 hid_hw_stop(hdev);
54}
55
56static const struct hid_device_id wiimote_hid_devices[] = {
57 { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_NINTENDO,
58 USB_DEVICE_ID_NINTENDO_WIIMOTE) },
59 { }
60};
61MODULE_DEVICE_TABLE(hid, wiimote_hid_devices);
62
63static 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
71static 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
23static void __exit wiimote_exit(void) 82static void __exit wiimote_exit(void)
24{ 83{
84 hid_unregister_driver(&wiimote_hid_driver);
25} 85}
26 86
27module_init(wiimote_init); 87module_init(wiimote_init);