aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Torokhov <dtor@insightbb.com>2007-06-14 23:49:55 -0400
committerDmitry Torokhov <dtor@insightbb.com>2007-07-10 00:35:18 -0400
commitae91d10aab2762f81733e9194cb56eff99c8d808 (patch)
tree0be462dbe75c9fdb55cd5281db83ced72934a066
parent6426b333a7365035ede9744faa24bdc5682fad8a (diff)
Input: xpad - fix report for dpad and inverted Y and RY axes on xbox 360
Make the driver report Y/RY up as positive value and down as negative. Also make DPAD mapping the same as classic xpad. Reported-by: Brian Magnuson <bdmagnuson@gmail.com> Tested-by: Jan Kratochvil <honza@jikos.cz> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/joystick/xpad.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index de4fa8c80137..244089c52650 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -236,8 +236,8 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
236 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ { 236 } else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ {
237 input_report_key(dev, BTN_LEFT, data[2] & 0x04); 237 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
238 input_report_key(dev, BTN_RIGHT, data[2] & 0x08); 238 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
239 input_report_key(dev, BTN_0, data[2] & 0x01); // up 239 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */
240 input_report_key(dev, BTN_1, data[2] & 0x02); // down 240 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */
241 } 241 }
242 242
243 /* start/back buttons and stick press left/right */ 243 /* start/back buttons and stick press left/right */
@@ -275,40 +275,40 @@ static void xpad360_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
275 275
276 /* digital pad */ 276 /* digital pad */
277 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) { 277 if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) {
278 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x01) - !!((data[2] & 0x08) >> 3)); 278 input_report_abs(dev, ABS_HAT0X, !!(data[2] & 0x08) - !!(data[2] & 0x04));
279 input_report_abs(dev, ABS_HAT0Y, !!((data[2] & 0x02) >> 1) - !!((data[2] & 0x04) >> 2)); 279 input_report_abs(dev, ABS_HAT0Y, !!(data[2] & 0x02) - !!(data[2] & 0x01));
280 } else if ( xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS ) { 280 } else if (xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS) {
281 /* dpad as buttons (right, left, down, up) */ 281 /* dpad as buttons (right, left, down, up) */
282 input_report_key(dev, BTN_RIGHT, (data[2] & 0x01)); 282 input_report_key(dev, BTN_LEFT, data[2] & 0x04);
283 input_report_key(dev, BTN_LEFT, (data[2] & 0x08) >> 3); 283 input_report_key(dev, BTN_RIGHT, data[2] & 0x08);
284 input_report_key(dev, BTN_0, (data[2] & 0x02) >> 1); 284 input_report_key(dev, BTN_0, data[2] & 0x01); /* up */
285 input_report_key(dev, BTN_1, (data[2] & 0x04) >> 2); 285 input_report_key(dev, BTN_1, data[2] & 0x02); /* down */
286 } 286 }
287 287
288 /* start/back buttons */ 288 /* start/back buttons */
289 input_report_key(dev, BTN_START, (data[2] & 0x10) >> 4); 289 input_report_key(dev, BTN_START, data[2] & 0x10);
290 input_report_key(dev, BTN_BACK, (data[2] & 0x20) >> 5); 290 input_report_key(dev, BTN_BACK, data[2] & 0x20);
291 291
292 /* stick press left/right */ 292 /* stick press left/right */
293 input_report_key(dev, BTN_THUMBL, data[2] & 0x40); 293 input_report_key(dev, BTN_THUMBL, data[2] & 0x40);
294 input_report_key(dev, BTN_THUMBR, data[2] & 0x80); 294 input_report_key(dev, BTN_THUMBR, data[2] & 0x80);
295 295
296 /* buttons A,B,X,Y,TL,TR and MODE */ 296 /* buttons A,B,X,Y,TL,TR and MODE */
297 input_report_key(dev, BTN_A, (data[3] & 0x10) >> 4); 297 input_report_key(dev, BTN_A, data[3] & 0x10);
298 input_report_key(dev, BTN_B, (data[3] & 0x20) >> 5); 298 input_report_key(dev, BTN_B, data[3] & 0x20);
299 input_report_key(dev, BTN_X, (data[3] & 0x40) >> 6); 299 input_report_key(dev, BTN_X, data[3] & 0x40);
300 input_report_key(dev, BTN_Y, (data[3] & 0x80) >> 7); 300 input_report_key(dev, BTN_Y, data[3] & 0x80);
301 input_report_key(dev, BTN_TL, data[3] & 0x01 ); 301 input_report_key(dev, BTN_TL, data[3] & 0x01);
302 input_report_key(dev, BTN_TR, (data[3] & 0x02) >> 1); 302 input_report_key(dev, BTN_TR, data[3] & 0x02);
303 input_report_key(dev, BTN_MODE, (data[3] & 0x04) >> 2); 303 input_report_key(dev, BTN_MODE, data[3] & 0x04);
304 304
305 /* left stick */ 305 /* left stick */
306 input_report_abs(dev, ABS_X, (__s16) (((__s16)data[7] << 8) | (__s16)data[6])); 306 input_report_abs(dev, ABS_X, (__s16) (((__s16)data[7] << 8) | (__s16)data[6]));
307 input_report_abs(dev, ABS_Y, ~(__s16) (((__s16)data[9] << 8) | (__s16)data[8])); 307 input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[9] << 8) | (__s16)data[8]));
308 308
309 /* right stick */ 309 /* right stick */
310 input_report_abs(dev, ABS_RY, ~(__s16) (((__s16)data[13] << 8) | (__s16)data[12]));
311 input_report_abs(dev, ABS_RX, (__s16) (((__s16)data[11] << 8) | (__s16)data[10])); 310 input_report_abs(dev, ABS_RX, (__s16) (((__s16)data[11] << 8) | (__s16)data[10]));
311 input_report_abs(dev, ABS_RY, (__s16) (((__s16)data[13] << 8) | (__s16)data[12]));
312 312
313 /* triggers left/right */ 313 /* triggers left/right */
314 input_report_abs(dev, ABS_Z, data[4]); 314 input_report_abs(dev, ABS_Z, data[4]);