2 * HID driver for Retrode 2 controller adapter and plug-in extensions
4 * Copyright (c) 2017 Bastien Nocera <hadess@hadess.net>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation; either version 2 of the License, or (at your option)
14 #include <linux/input.h>
15 #include <linux/slab.h>
16 #include <linux/hid.h>
17 #include <linux/module.h>
20 #define CONTROLLER_NAME_BASE "Retrode"
22 static int retrode_input_configured(struct hid_device
*hdev
,
25 struct hid_field
*field
= hi
->report
->field
[0];
30 switch (field
->report
->id
) {
32 suffix
= "SNES Mouse";
36 suffix
= "SNES / N64";
37 number
= field
->report
->id
;
41 suffix
= "Mega Drive";
42 number
= field
->report
->id
- 2;
45 hid_err(hdev
, "Got unhandled report id %d\n", field
->report
->id
);
50 name
= devm_kasprintf(&hdev
->dev
, GFP_KERNEL
,
51 "%s %s #%d", CONTROLLER_NAME_BASE
,
54 name
= devm_kasprintf(&hdev
->dev
, GFP_KERNEL
,
55 "%s %s", CONTROLLER_NAME_BASE
, suffix
);
60 hi
->input
->name
= name
;
65 static int retrode_probe(struct hid_device
*hdev
,
66 const struct hid_device_id
*id
)
71 /* Has no effect on the mouse device */
72 hdev
->quirks
|= HID_QUIRK_MULTI_INPUT
;
74 ret
= hid_parse(hdev
);
78 ret
= hid_hw_start(hdev
, HID_CONNECT_DEFAULT
);
85 static const struct hid_device_id retrode_devices
[] = {
86 { HID_USB_DEVICE(USB_VENDOR_ID_FUTURE_TECHNOLOGY
, USB_DEVICE_ID_RETRODE2
) },
89 MODULE_DEVICE_TABLE(hid
, retrode_devices
);
91 static struct hid_driver retrode_driver
= {
92 .name
= "hid-retrode",
93 .id_table
= retrode_devices
,
94 .input_configured
= retrode_input_configured
,
95 .probe
= retrode_probe
,
98 module_hid_driver(retrode_driver
);
100 MODULE_LICENSE("GPL");