30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/slab.h>
33 #include <linux/input.h>
34 #include <linux/serio.h>
37 #define DRIVER_DESC "Gravis Stinger gamepad driver"
47 #define STINGER_MAX_LENGTH 8
54 struct input_dev *
dev;
67 struct input_dev *
dev = stinger->
dev;
70 if (!stinger->
idx)
return;
72 input_report_key(dev,
BTN_A, ((data[0] & 0x20) >> 5));
73 input_report_key(dev,
BTN_B, ((data[0] & 0x10) >> 4));
74 input_report_key(dev,
BTN_C, ((data[0] & 0x08) >> 3));
75 input_report_key(dev,
BTN_X, ((data[0] & 0x04) >> 2));
76 input_report_key(dev,
BTN_Y, ((data[3] & 0x20) >> 5));
77 input_report_key(dev,
BTN_Z, ((data[3] & 0x10) >> 4));
78 input_report_key(dev,
BTN_TL, ((data[3] & 0x08) >> 3));
79 input_report_key(dev,
BTN_TR, ((data[3] & 0x04) >> 2));
80 input_report_key(dev,
BTN_SELECT, ((data[3] & 0x02) >> 1));
81 input_report_key(dev,
BTN_START, (data[3] & 0x01));
83 input_report_abs(dev,
ABS_X, (data[1] & 0x3F) - ((data[0] & 0x01) << 6));
84 input_report_abs(dev,
ABS_Y, ((data[0] & 0x02) << 5) - (data[2] & 0x3F));
107 if (stinger->
idx == 4) {
108 stinger_process_packet(stinger);
119 static void stinger_disconnect(
struct serio *serio)
121 struct stinger *stinger = serio_get_drvdata(serio);
124 serio_set_drvdata(serio,
NULL);
125 input_unregister_device(stinger->
dev);
135 static int stinger_connect(
struct serio *serio,
struct serio_driver *drv)
137 struct stinger *stinger;
138 struct input_dev *input_dev;
142 input_dev = input_allocate_device();
143 if (!stinger || !input_dev)
146 stinger->
dev = input_dev;
149 input_dev->name =
"Gravis Stinger";
150 input_dev->phys = stinger->
phys;
153 input_dev->id.product = 0x0001;
154 input_dev->id.version = 0x0100;
155 input_dev->dev.parent = &serio->
dev;
162 input_set_abs_params(input_dev,
ABS_X, -64, 64, 0, 4);
163 input_set_abs_params(input_dev,
ABS_Y, -64, 64, 0, 4);
165 serio_set_drvdata(serio, stinger);
171 err = input_register_device(stinger->
dev);
178 fail2: serio_set_drvdata(serio,
NULL);
179 fail1: input_free_device(input_dev);
205 .id_table = stinger_serio_ids,
206 .interrupt = stinger_interrupt,
207 .connect = stinger_connect,
208 .disconnect = stinger_disconnect,