-
Notifications
You must be signed in to change notification settings - Fork 2
/
joydev-dancepad-1.1-2.6.29.6.patch
157 lines (148 loc) · 4.03 KB
/
joydev-dancepad-1.1-2.6.29.6.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
--- linux-2.6.29.6/drivers/input/joydev.c.bak 2010-10-07 01:14:09.474950133 -0300
+++ linux-2.6.29.6/drivers/input/joydev.c 2010-10-07 01:16:12.899752479 -0300
@@ -56,6 +56,8 @@
__u8 absmap[ABS_MAX + 1];
__u8 abspam[ABS_MAX + 1];
__s16 abs[ABS_MAX + 1];
+ unsigned x_axis_status;
+ unsigned y_axis_status;
};
struct joydev_client {
@@ -116,13 +118,36 @@
kill_fasync(&client->fasync, SIGIO, POLL_IN);
}
+static void joydev_send_event(struct js_event *event, struct joydev *joydev)
+{
+ struct joydev_client *client;
+ event->time = jiffies_to_msecs(jiffies);
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(client, &joydev->client_list, node)
+ joydev_pass_event(client, event);
+ rcu_read_unlock();
+}
+
static void joydev_event(struct input_handle *handle,
unsigned int type, unsigned int code, int value)
{
struct joydev *joydev = handle->private;
- struct joydev_client *client;
struct js_event event;
+# define JOYDEV_LEFT 12
+# define JOYDEV_RIGHT 13
+# define JOYDEV_UP 14
+# define JOYDEV_DOWN 15
+# define X_AXIS 0
+# define Y_AXIS 1
+# define X_AXIS_LEFT 1
+# define X_AXIS_RIGHT 2
+# define Y_AXIS_UP 1
+# define Y_AXIS_DOWN 2
+ unsigned x_axis_new_status = joydev->x_axis_status;
+ unsigned y_axis_new_status = joydev->y_axis_status;
+
switch (type) {
case EV_KEY:
@@ -131,29 +156,81 @@
event.type = JS_EVENT_BUTTON;
event.number = joydev->keymap[code - BTN_MISC];
event.value = value;
+
+ joydev_send_event(&event, joydev);
+
break;
case EV_ABS:
- event.type = JS_EVENT_AXIS;
- event.number = joydev->absmap[code];
- event.value = joydev_correct(value,
- &joydev->corr[event.number]);
- if (event.value == joydev->abs[event.number])
- return;
- joydev->abs[event.number] = event.value;
- break;
+ if (code == X_AXIS)
+ {
+ if (value == 0)
+ {
+ x_axis_new_status |= X_AXIS_LEFT;
+ x_axis_new_status &= ~X_AXIS_RIGHT;
+ }
+ if (value == 255)
+ {
+ x_axis_new_status |= X_AXIS_RIGHT;
+ x_axis_new_status &= ~X_AXIS_LEFT;
+ }
+ if (value == 128)
+ x_axis_new_status |= X_AXIS_LEFT | X_AXIS_RIGHT;
+ if (value == 127)
+ x_axis_new_status = 0;
+ }
+ if (code == Y_AXIS)
+ {
+ if (value == 0)
+ {
+ y_axis_new_status |= Y_AXIS_UP;
+ y_axis_new_status &= ~Y_AXIS_DOWN;
+ }
+ if (value == 255)
+ {
+ y_axis_new_status |= Y_AXIS_DOWN;
+ y_axis_new_status &= ~Y_AXIS_UP;
+ }
+ if (value == 128)
+ y_axis_new_status |= Y_AXIS_UP | Y_AXIS_DOWN;
+ if (value == 127)
+ y_axis_new_status = 0;
+ }
+ event.type = JS_EVENT_BUTTON;
+ if ((x_axis_new_status ^ joydev->x_axis_status) & X_AXIS_LEFT)
+ {
+ event.number = JOYDEV_LEFT;
+ event.value = (x_axis_new_status & X_AXIS_LEFT) > 0 ? 1 : 0;
+ joydev_send_event(&event, joydev);
+ }
+ if ((x_axis_new_status ^ joydev->x_axis_status) & X_AXIS_RIGHT)
+ {
+ event.number = JOYDEV_RIGHT;
+ event.value = (x_axis_new_status & X_AXIS_RIGHT) > 0 ? 1 : 0;
+ joydev_send_event(&event, joydev);
+ }
+ if ((y_axis_new_status ^ joydev->y_axis_status) & Y_AXIS_UP)
+ {
+ event.number = JOYDEV_UP;
+ event.value = (y_axis_new_status & Y_AXIS_UP) > 0 ? 1 : 0;
+ joydev_send_event(&event, joydev);
+ }
+ if ((y_axis_new_status ^ joydev->y_axis_status) & Y_AXIS_DOWN)
+ {
+ event.number = JOYDEV_DOWN;
+ event.value = (y_axis_new_status & Y_AXIS_DOWN) > 0 ? 1 : 0;
+ joydev_send_event(&event, joydev);
+ }
+
+ joydev->x_axis_status = x_axis_new_status;
+ joydev->y_axis_status = y_axis_new_status;
+
+ break;
default:
return;
}
- event.time = jiffies_to_msecs(jiffies);
-
- rcu_read_lock();
- list_for_each_entry_rcu(client, &joydev->client_list, node)
- joydev_pass_event(client, &event);
- rcu_read_unlock();
-
wake_up_interruptible(&joydev->wait);
}
@@ -800,6 +877,10 @@
}
}
+ joydev->x_axis_status = 0;
+ joydev->y_axis_status = 0;
+ joydev->nkey += 4;
+
dev_set_name(&joydev->dev, joydev->name);
joydev->dev.devt = MKDEV(INPUT_MAJOR, JOYDEV_MINOR_BASE + minor);
joydev->dev.class = &input_class;