diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-08-16 13:42:58 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-08-16 13:42:58 -0400 |
commit | e4862f2f6f5653dfb67f3ba2b6f0bc74516ed51a (patch) | |
tree | 1db5a0540a4eecfad9b7daee476b985e82ddc810 /drivers/input/joystick | |
parent | ec62dbd7eb8e3dddb221da89ecbcea0fc3dee8c1 (diff) | |
parent | b2c1e07b81a126e5846dfc3d36f559d861df59f4 (diff) |
Merge branch 'for-2.6.36' into for-2.6.37
Fairly simple conflicts, the most serious ones are the i.MX ones which I
suspect now need another rename.
Conflicts:
arch/arm/mach-mx2/clock_imx27.c
arch/arm/mach-mx2/devices.c
arch/arm/mach-omap2/board-rx51-peripherals.c
arch/arm/mach-omap2/board-zoom2.c
sound/soc/fsl/mpc5200_dma.c
sound/soc/fsl/mpc5200_dma.h
sound/soc/fsl/mpc8610_hpcd.c
sound/soc/pxa/spitz.c
Diffstat (limited to 'drivers/input/joystick')
-rw-r--r-- | drivers/input/joystick/a3d.c | 3 | ||||
-rw-r--r-- | drivers/input/joystick/adi.c | 2 | ||||
-rw-r--r-- | drivers/input/joystick/amijoy.c | 4 | ||||
-rw-r--r-- | drivers/input/joystick/gamecon.c | 5 | ||||
-rw-r--r-- | drivers/input/joystick/gf2k.c | 20 | ||||
-rw-r--r-- | drivers/input/joystick/interact.c | 14 | ||||
-rw-r--r-- | drivers/input/joystick/sidewinder.c | 18 | ||||
-rw-r--r-- | drivers/input/joystick/xpad.c | 109 |
8 files changed, 98 insertions, 77 deletions
diff --git a/drivers/input/joystick/a3d.c b/drivers/input/joystick/a3d.c index 6489f4010c4f..d259b41354b8 100644 --- a/drivers/input/joystick/a3d.c +++ b/drivers/input/joystick/a3d.c | |||
@@ -342,7 +342,8 @@ static int a3d_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
342 | 342 | ||
343 | for (i = 0; i < 4; i++) { | 343 | for (i = 0; i < 4; i++) { |
344 | if (i < 2) | 344 | if (i < 2) |
345 | input_set_abs_params(input_dev, axes[i], 48, input_dev->abs[axes[i]] * 2 - 48, 0, 8); | 345 | input_set_abs_params(input_dev, axes[i], |
346 | 48, input_abs_get_val(input_dev, axes[i]) * 2 - 48, 0, 8); | ||
346 | else | 347 | else |
347 | input_set_abs_params(input_dev, axes[i], 2, 253, 0, 0); | 348 | input_set_abs_params(input_dev, axes[i], 2, 253, 0, 0); |
348 | input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); | 349 | input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); |
diff --git a/drivers/input/joystick/adi.c b/drivers/input/joystick/adi.c index 89c4c084d4ad..b992fbf91f2f 100644 --- a/drivers/input/joystick/adi.c +++ b/drivers/input/joystick/adi.c | |||
@@ -452,7 +452,7 @@ static void adi_init_center(struct adi *adi) | |||
452 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) { | 452 | for (i = 0; i < adi->axes10 + adi->axes8 + (adi->hats + (adi->pad != -1)) * 2; i++) { |
453 | 453 | ||
454 | t = adi->abs[i]; | 454 | t = adi->abs[i]; |
455 | x = adi->dev->abs[t]; | 455 | x = input_abs_get_val(adi->dev, t); |
456 | 456 | ||
457 | if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) | 457 | if (t == ABS_THROTTLE || t == ABS_RUDDER || adi->id == ADI_ID_WGPE) |
458 | x = i < adi->axes10 ? 512 : 128; | 458 | x = i < adi->axes10 ? 512 : 128; |
diff --git a/drivers/input/joystick/amijoy.c b/drivers/input/joystick/amijoy.c index 05022f07ec77..0bc86204213e 100644 --- a/drivers/input/joystick/amijoy.c +++ b/drivers/input/joystick/amijoy.c | |||
@@ -139,8 +139,8 @@ static int __init amijoy_init(void) | |||
139 | amijoy_dev[i]->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | | 139 | amijoy_dev[i]->keybit[BIT_WORD(BTN_LEFT)] = BIT_MASK(BTN_LEFT) | |
140 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); | 140 | BIT_MASK(BTN_MIDDLE) | BIT_MASK(BTN_RIGHT); |
141 | for (j = 0; j < 2; j++) { | 141 | for (j = 0; j < 2; j++) { |
142 | amijoy_dev[i]->absmin[ABS_X + j] = -1; | 142 | input_set_abs_params(amijoy_dev[i], ABS_X + j, |
143 | amijoy_dev[i]->absmax[ABS_X + j] = 1; | 143 | -1, 1, 0, 0); |
144 | } | 144 | } |
145 | 145 | ||
146 | err = input_register_device(amijoy_dev[i]); | 146 | err = input_register_device(amijoy_dev[i]); |
diff --git a/drivers/input/joystick/gamecon.c b/drivers/input/joystick/gamecon.c index fbd62abb66f9..0ffaf2c77a19 100644 --- a/drivers/input/joystick/gamecon.c +++ b/drivers/input/joystick/gamecon.c | |||
@@ -89,7 +89,6 @@ struct gc_pad { | |||
89 | struct gc { | 89 | struct gc { |
90 | struct pardevice *pd; | 90 | struct pardevice *pd; |
91 | struct gc_pad pads[GC_MAX_DEVICES]; | 91 | struct gc_pad pads[GC_MAX_DEVICES]; |
92 | struct input_dev *dev[GC_MAX_DEVICES]; | ||
93 | struct timer_list timer; | 92 | struct timer_list timer; |
94 | int pad_count[GC_MAX]; | 93 | int pad_count[GC_MAX]; |
95 | int used; | 94 | int used; |
@@ -387,7 +386,7 @@ static void gc_nes_process_packet(struct gc *gc) | |||
387 | for (i = 0; i < GC_MAX_DEVICES; i++) { | 386 | for (i = 0; i < GC_MAX_DEVICES; i++) { |
388 | 387 | ||
389 | pad = &gc->pads[i]; | 388 | pad = &gc->pads[i]; |
390 | dev = gc->dev[i]; | 389 | dev = pad->dev; |
391 | s = gc_status_bit[i]; | 390 | s = gc_status_bit[i]; |
392 | 391 | ||
393 | switch (pad->type) { | 392 | switch (pad->type) { |
@@ -579,7 +578,7 @@ static void gc_psx_command(struct gc *gc, int b, unsigned char *data) | |||
579 | read = parport_read_status(port) ^ 0x80; | 578 | read = parport_read_status(port) ^ 0x80; |
580 | 579 | ||
581 | for (j = 0; j < GC_MAX_DEVICES; j++) { | 580 | for (j = 0; j < GC_MAX_DEVICES; j++) { |
582 | struct gc_pad *pad = &gc->pads[i]; | 581 | struct gc_pad *pad = &gc->pads[j]; |
583 | 582 | ||
584 | if (pad->type == GC_PSX || pad->type == GC_DDR) | 583 | if (pad->type == GC_PSX || pad->type == GC_DDR) |
585 | data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0; | 584 | data[j] |= (read & gc_status_bit[j]) ? (1 << i) : 0; |
diff --git a/drivers/input/joystick/gf2k.c b/drivers/input/joystick/gf2k.c index 45ac70eae0aa..0536b1b2f018 100644 --- a/drivers/input/joystick/gf2k.c +++ b/drivers/input/joystick/gf2k.c | |||
@@ -318,11 +318,8 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
318 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) | 318 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) |
319 | set_bit(gf2k_abs[i], input_dev->absbit); | 319 | set_bit(gf2k_abs[i], input_dev->absbit); |
320 | 320 | ||
321 | for (i = 0; i < gf2k_hats[gf2k->id]; i++) { | 321 | for (i = 0; i < gf2k_hats[gf2k->id]; i++) |
322 | set_bit(ABS_HAT0X + i, input_dev->absbit); | 322 | input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); |
323 | input_dev->absmin[ABS_HAT0X + i] = -1; | ||
324 | input_dev->absmax[ABS_HAT0X + i] = 1; | ||
325 | } | ||
326 | 323 | ||
327 | for (i = 0; i < gf2k_joys[gf2k->id]; i++) | 324 | for (i = 0; i < gf2k_joys[gf2k->id]; i++) |
328 | set_bit(gf2k_btn_joy[i], input_dev->keybit); | 325 | set_bit(gf2k_btn_joy[i], input_dev->keybit); |
@@ -334,11 +331,14 @@ static int gf2k_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
334 | gf2k_read(gf2k, data); | 331 | gf2k_read(gf2k, data); |
335 | 332 | ||
336 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) { | 333 | for (i = 0; i < gf2k_axes[gf2k->id]; i++) { |
337 | input_dev->absmax[gf2k_abs[i]] = (i < 2) ? input_dev->abs[gf2k_abs[i]] * 2 - 32 : | 334 | int max = i < 2 ? |
338 | input_dev->abs[gf2k_abs[0]] + input_dev->abs[gf2k_abs[1]] - 32; | 335 | input_abs_get_val(input_dev, gf2k_abs[i]) * 2 : |
339 | input_dev->absmin[gf2k_abs[i]] = 32; | 336 | input_abs_get_val(input_dev, gf2k_abs[0]) + |
340 | input_dev->absfuzz[gf2k_abs[i]] = 8; | 337 | input_abs_get_val(input_dev, gf2k_abs[1]); |
341 | input_dev->absflat[gf2k_abs[i]] = (i < 2) ? 24 : 0; | 338 | int flat = i < 2 ? 24 : 0; |
339 | |||
340 | input_set_abs_params(input_dev, gf2k_abs[i], | ||
341 | 32, max - 32, 8, flat); | ||
342 | } | 342 | } |
343 | 343 | ||
344 | err = input_register_device(gf2k->dev); | 344 | err = input_register_device(gf2k->dev); |
diff --git a/drivers/input/joystick/interact.c b/drivers/input/joystick/interact.c index 2478289aeeea..16fb19d1ca25 100644 --- a/drivers/input/joystick/interact.c +++ b/drivers/input/joystick/interact.c | |||
@@ -270,18 +270,14 @@ static int interact_connect(struct gameport *gameport, struct gameport_driver *d | |||
270 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 270 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
271 | 271 | ||
272 | for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { | 272 | for (i = 0; (t = interact_type[interact->type].abs[i]) >= 0; i++) { |
273 | set_bit(t, input_dev->absbit); | 273 | if (i < interact_type[interact->type].b8) |
274 | if (i < interact_type[interact->type].b8) { | 274 | input_set_abs_params(input_dev, t, 0, 255, 0, 0); |
275 | input_dev->absmin[t] = 0; | 275 | else |
276 | input_dev->absmax[t] = 255; | 276 | input_set_abs_params(input_dev, t, -1, 1, 0, 0); |
277 | } else { | ||
278 | input_dev->absmin[t] = -1; | ||
279 | input_dev->absmax[t] = 1; | ||
280 | } | ||
281 | } | 277 | } |
282 | 278 | ||
283 | for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) | 279 | for (i = 0; (t = interact_type[interact->type].btn[i]) >= 0; i++) |
284 | set_bit(t, input_dev->keybit); | 280 | __set_bit(t, input_dev->keybit); |
285 | 281 | ||
286 | err = input_register_device(interact->dev); | 282 | err = input_register_device(interact->dev); |
287 | if (err) | 283 | if (err) |
diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index ca13a6bec33e..b8d86115644b 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c | |||
@@ -761,17 +761,21 @@ static int sw_connect(struct gameport *gameport, struct gameport_driver *drv) | |||
761 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 761 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); |
762 | 762 | ||
763 | for (j = 0; (bits = sw_bit[sw->type][j]); j++) { | 763 | for (j = 0; (bits = sw_bit[sw->type][j]); j++) { |
764 | int min, max, fuzz, flat; | ||
765 | |||
764 | code = sw_abs[sw->type][j]; | 766 | code = sw_abs[sw->type][j]; |
765 | set_bit(code, input_dev->absbit); | 767 | min = bits == 1 ? -1 : 0; |
766 | input_dev->absmax[code] = (1 << bits) - 1; | 768 | max = (1 << bits) - 1; |
767 | input_dev->absmin[code] = (bits == 1) ? -1 : 0; | 769 | fuzz = (bits >> 1) >= 2 ? 1 << ((bits >> 1) - 2) : 0; |
768 | input_dev->absfuzz[code] = ((bits >> 1) >= 2) ? (1 << ((bits >> 1) - 2)) : 0; | 770 | flat = code == ABS_THROTTLE || bits < 5 ? |
769 | if (code != ABS_THROTTLE) | 771 | 0 : 1 << (bits - 5); |
770 | input_dev->absflat[code] = (bits >= 5) ? (1 << (bits - 5)) : 0; | 772 | |
773 | input_set_abs_params(input_dev, code, | ||
774 | min, max, fuzz, flat); | ||
771 | } | 775 | } |
772 | 776 | ||
773 | for (j = 0; (code = sw_btn[sw->type][j]); j++) | 777 | for (j = 0; (code = sw_btn[sw->type][j]); j++) |
774 | set_bit(code, input_dev->keybit); | 778 | __set_bit(code, input_dev->keybit); |
775 | 779 | ||
776 | dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); | 780 | dbg("%s%s [%d-bit id %d data %d]\n", sw->name, comment, m, l, k); |
777 | 781 | ||
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c index c1087ce4cef9..f9fb7fa10af3 100644 --- a/drivers/input/joystick/xpad.c +++ b/drivers/input/joystick/xpad.c | |||
@@ -9,6 +9,7 @@ | |||
9 | * 2005 Dominic Cerquetti <binary1230@yahoo.com> | 9 | * 2005 Dominic Cerquetti <binary1230@yahoo.com> |
10 | * 2006 Adam Buchbinder <adam.buchbinder@gmail.com> | 10 | * 2006 Adam Buchbinder <adam.buchbinder@gmail.com> |
11 | * 2007 Jan Kratochvil <honza@jikos.cz> | 11 | * 2007 Jan Kratochvil <honza@jikos.cz> |
12 | * 2010 Christoph Fritz <chf.fritz@googlemail.com> | ||
12 | * | 13 | * |
13 | * This program is free software; you can redistribute it and/or | 14 | * This program is free software; you can redistribute it and/or |
14 | * modify it under the terms of the GNU General Public License as | 15 | * modify it under the terms of the GNU General Public License as |
@@ -88,6 +89,9 @@ | |||
88 | but we map them to axes when possible to simplify things */ | 89 | but we map them to axes when possible to simplify things */ |
89 | #define MAP_DPAD_TO_BUTTONS (1 << 0) | 90 | #define MAP_DPAD_TO_BUTTONS (1 << 0) |
90 | #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) | 91 | #define MAP_TRIGGERS_TO_BUTTONS (1 << 1) |
92 | #define MAP_STICKS_TO_NULL (1 << 2) | ||
93 | #define DANCEPAD_MAP_CONFIG (MAP_DPAD_TO_BUTTONS | \ | ||
94 | MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL) | ||
91 | 95 | ||
92 | #define XTYPE_XBOX 0 | 96 | #define XTYPE_XBOX 0 |
93 | #define XTYPE_XBOX360 1 | 97 | #define XTYPE_XBOX360 1 |
@@ -102,6 +106,10 @@ static int triggers_to_buttons; | |||
102 | module_param(triggers_to_buttons, bool, S_IRUGO); | 106 | module_param(triggers_to_buttons, bool, S_IRUGO); |
103 | MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads"); | 107 | MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes for unknown pads"); |
104 | 108 | ||
109 | static int sticks_to_null; | ||
110 | module_param(sticks_to_null, bool, S_IRUGO); | ||
111 | MODULE_PARM_DESC(sticks_to_null, "Do not map sticks at all for unknown pads"); | ||
112 | |||
105 | static const struct xpad_device { | 113 | static const struct xpad_device { |
106 | u16 idVendor; | 114 | u16 idVendor; |
107 | u16 idProduct; | 115 | u16 idProduct; |
@@ -114,7 +122,7 @@ static const struct xpad_device { | |||
114 | { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, | 122 | { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", 0, XTYPE_XBOX }, |
115 | { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, | 123 | { 0x045e, 0x0287, "Microsoft Xbox Controller S", 0, XTYPE_XBOX }, |
116 | { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, | 124 | { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, |
117 | { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, | 125 | { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", DANCEPAD_MAP_CONFIG, XTYPE_XBOX }, |
118 | { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, | 126 | { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", 0, XTYPE_XBOX }, |
119 | { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, | 127 | { 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 }, |
120 | { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, | 128 | { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX }, |
@@ -140,6 +148,7 @@ static const struct xpad_device { | |||
140 | { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX }, | 148 | { 0x0e6f, 0x0005, "Eclipse wireless Controller", 0, XTYPE_XBOX }, |
141 | { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX }, | 149 | { 0x0e6f, 0x0006, "Edge wireless Controller", 0, XTYPE_XBOX }, |
142 | { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, | 150 | { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, |
151 | { 0x0e6f, 0x0201, "Pelican PL-3601 'TSZ' Wired Xbox 360 Controller", 0, XTYPE_XBOX360 }, | ||
143 | { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX }, | 152 | { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", 0, XTYPE_XBOX }, |
144 | { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, | 153 | { 0x0f30, 0x0202, "Joytech Advanced Controller", 0, XTYPE_XBOX }, |
145 | { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, | 154 | { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", 0, XTYPE_XBOX }, |
@@ -151,6 +160,7 @@ static const struct xpad_device { | |||
151 | { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, | 160 | { 0x045e, 0x028e, "Microsoft X-Box 360 pad", 0, XTYPE_XBOX360 }, |
152 | { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, | 161 | { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, |
153 | { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, | 162 | { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, |
163 | { 0x0f0d, 0x000d, "Hori Fighting Stick EX2", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, | ||
154 | { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, | 164 | { 0xffff, 0xffff, "Chinese-made Xbox Controller", 0, XTYPE_XBOX }, |
155 | { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } | 165 | { 0x0000, 0x0000, "Generic X-Box pad", 0, XTYPE_UNKNOWN } |
156 | }; | 166 | }; |
@@ -158,7 +168,7 @@ static const struct xpad_device { | |||
158 | /* buttons shared with xbox and xbox360 */ | 168 | /* buttons shared with xbox and xbox360 */ |
159 | static const signed short xpad_common_btn[] = { | 169 | static const signed short xpad_common_btn[] = { |
160 | BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */ | 170 | BTN_A, BTN_B, BTN_X, BTN_Y, /* "analog" buttons */ |
161 | BTN_START, BTN_BACK, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */ | 171 | BTN_START, BTN_SELECT, BTN_THUMBL, BTN_THUMBR, /* start/back/sticks */ |
162 | -1 /* terminating entry */ | 172 | -1 /* terminating entry */ |
163 | }; | 173 | }; |
164 | 174 | ||
@@ -168,10 +178,10 @@ static const signed short xpad_btn[] = { | |||
168 | -1 /* terminating entry */ | 178 | -1 /* terminating entry */ |
169 | }; | 179 | }; |
170 | 180 | ||
171 | /* used when dpad is mapped to nuttons */ | 181 | /* used when dpad is mapped to buttons */ |
172 | static const signed short xpad_btn_pad[] = { | 182 | static const signed short xpad_btn_pad[] = { |
173 | BTN_LEFT, BTN_RIGHT, /* d-pad left, right */ | 183 | BTN_TRIGGER_HAPPY1, BTN_TRIGGER_HAPPY2, /* d-pad left, right */ |
174 | BTN_0, BTN_1, /* d-pad up, down (XXX names??) */ | 184 | BTN_TRIGGER_HAPPY3, BTN_TRIGGER_HAPPY4, /* d-pad up, down */ |
175 | -1 /* terminating entry */ | 185 | -1 /* terminating entry */ |
176 | }; | 186 | }; |
177 | 187 | ||
@@ -279,17 +289,19 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d | |||
279 | { | 289 | { |
280 | struct input_dev *dev = xpad->dev; | 290 | struct input_dev *dev = xpad->dev; |
281 | 291 | ||
282 | /* left stick */ | 292 | if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { |
283 | input_report_abs(dev, ABS_X, | 293 | /* left stick */ |
284 | (__s16) le16_to_cpup((__le16 *)(data + 12))); | 294 | input_report_abs(dev, ABS_X, |
285 | input_report_abs(dev, ABS_Y, | 295 | (__s16) le16_to_cpup((__le16 *)(data + 12))); |
286 | ~(__s16) le16_to_cpup((__le16 *)(data + 14))); | 296 | input_report_abs(dev, ABS_Y, |
287 | 297 | ~(__s16) le16_to_cpup((__le16 *)(data + 14))); | |
288 | /* right stick */ | 298 | |
289 | input_report_abs(dev, ABS_RX, | 299 | /* right stick */ |
290 | (__s16) le16_to_cpup((__le16 *)(data + 16))); | 300 | input_report_abs(dev, ABS_RX, |
291 | input_report_abs(dev, ABS_RY, | 301 | (__s16) le16_to_cpup((__le16 *)(data + 16))); |
292 | ~(__s16) le16_to_cpup((__le16 *)(data + 18))); | 302 | input_report_abs(dev, ABS_RY, |
303 | ~(__s16) le16_to_cpup((__le16 *)(data + 18))); | ||
304 | } | ||
293 | 305 | ||
294 | /* triggers left/right */ | 306 | /* triggers left/right */ |
295 | if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { | 307 | if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { |
@@ -302,10 +314,11 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d | |||
302 | 314 | ||
303 | /* digital pad */ | 315 | /* digital pad */ |
304 | if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { | 316 | if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { |
305 | input_report_key(dev, BTN_LEFT, data[2] & 0x04); | 317 | /* dpad as buttons (left, right, up, down) */ |
306 | input_report_key(dev, BTN_RIGHT, data[2] & 0x08); | 318 | input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); |
307 | input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ | 319 | input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); |
308 | input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ | 320 | input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); |
321 | input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); | ||
309 | } else { | 322 | } else { |
310 | input_report_abs(dev, ABS_HAT0X, | 323 | input_report_abs(dev, ABS_HAT0X, |
311 | !!(data[2] & 0x08) - !!(data[2] & 0x04)); | 324 | !!(data[2] & 0x08) - !!(data[2] & 0x04)); |
@@ -315,7 +328,7 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d | |||
315 | 328 | ||
316 | /* start/back buttons and stick press left/right */ | 329 | /* start/back buttons and stick press left/right */ |
317 | input_report_key(dev, BTN_START, data[2] & 0x10); | 330 | input_report_key(dev, BTN_START, data[2] & 0x10); |
318 | input_report_key(dev, BTN_BACK, data[2] & 0x20); | 331 | input_report_key(dev, BTN_SELECT, data[2] & 0x20); |
319 | input_report_key(dev, BTN_THUMBL, data[2] & 0x40); | 332 | input_report_key(dev, BTN_THUMBL, data[2] & 0x40); |
320 | input_report_key(dev, BTN_THUMBR, data[2] & 0x80); | 333 | input_report_key(dev, BTN_THUMBR, data[2] & 0x80); |
321 | 334 | ||
@@ -349,11 +362,11 @@ static void xpad360_process_packet(struct usb_xpad *xpad, | |||
349 | 362 | ||
350 | /* digital pad */ | 363 | /* digital pad */ |
351 | if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { | 364 | if (xpad->mapping & MAP_DPAD_TO_BUTTONS) { |
352 | /* dpad as buttons (right, left, down, up) */ | 365 | /* dpad as buttons (left, right, up, down) */ |
353 | input_report_key(dev, BTN_LEFT, data[2] & 0x04); | 366 | input_report_key(dev, BTN_TRIGGER_HAPPY1, data[2] & 0x04); |
354 | input_report_key(dev, BTN_RIGHT, data[2] & 0x08); | 367 | input_report_key(dev, BTN_TRIGGER_HAPPY2, data[2] & 0x08); |
355 | input_report_key(dev, BTN_0, data[2] & 0x01); /* up */ | 368 | input_report_key(dev, BTN_TRIGGER_HAPPY3, data[2] & 0x01); |
356 | input_report_key(dev, BTN_1, data[2] & 0x02); /* down */ | 369 | input_report_key(dev, BTN_TRIGGER_HAPPY4, data[2] & 0x02); |
357 | } else { | 370 | } else { |
358 | input_report_abs(dev, ABS_HAT0X, | 371 | input_report_abs(dev, ABS_HAT0X, |
359 | !!(data[2] & 0x08) - !!(data[2] & 0x04)); | 372 | !!(data[2] & 0x08) - !!(data[2] & 0x04)); |
@@ -363,7 +376,7 @@ static void xpad360_process_packet(struct usb_xpad *xpad, | |||
363 | 376 | ||
364 | /* start/back buttons */ | 377 | /* start/back buttons */ |
365 | input_report_key(dev, BTN_START, data[2] & 0x10); | 378 | input_report_key(dev, BTN_START, data[2] & 0x10); |
366 | input_report_key(dev, BTN_BACK, data[2] & 0x20); | 379 | input_report_key(dev, BTN_SELECT, data[2] & 0x20); |
367 | 380 | ||
368 | /* stick press left/right */ | 381 | /* stick press left/right */ |
369 | input_report_key(dev, BTN_THUMBL, data[2] & 0x40); | 382 | input_report_key(dev, BTN_THUMBL, data[2] & 0x40); |
@@ -378,17 +391,19 @@ static void xpad360_process_packet(struct usb_xpad *xpad, | |||
378 | input_report_key(dev, BTN_TR, data[3] & 0x02); | 391 | input_report_key(dev, BTN_TR, data[3] & 0x02); |
379 | input_report_key(dev, BTN_MODE, data[3] & 0x04); | 392 | input_report_key(dev, BTN_MODE, data[3] & 0x04); |
380 | 393 | ||
381 | /* left stick */ | 394 | if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { |
382 | input_report_abs(dev, ABS_X, | 395 | /* left stick */ |
383 | (__s16) le16_to_cpup((__le16 *)(data + 6))); | 396 | input_report_abs(dev, ABS_X, |
384 | input_report_abs(dev, ABS_Y, | 397 | (__s16) le16_to_cpup((__le16 *)(data + 6))); |
385 | ~(__s16) le16_to_cpup((__le16 *)(data + 8))); | 398 | input_report_abs(dev, ABS_Y, |
386 | 399 | ~(__s16) le16_to_cpup((__le16 *)(data + 8))); | |
387 | /* right stick */ | 400 | |
388 | input_report_abs(dev, ABS_RX, | 401 | /* right stick */ |
389 | (__s16) le16_to_cpup((__le16 *)(data + 10))); | 402 | input_report_abs(dev, ABS_RX, |
390 | input_report_abs(dev, ABS_RY, | 403 | (__s16) le16_to_cpup((__le16 *)(data + 10))); |
391 | ~(__s16) le16_to_cpup((__le16 *)(data + 12))); | 404 | input_report_abs(dev, ABS_RY, |
405 | ~(__s16) le16_to_cpup((__le16 *)(data + 12))); | ||
406 | } | ||
392 | 407 | ||
393 | /* triggers left/right */ | 408 | /* triggers left/right */ |
394 | if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { | 409 | if (xpad->mapping & MAP_TRIGGERS_TO_BUTTONS) { |
@@ -814,6 +829,8 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
814 | xpad->mapping |= MAP_DPAD_TO_BUTTONS; | 829 | xpad->mapping |= MAP_DPAD_TO_BUTTONS; |
815 | if (triggers_to_buttons) | 830 | if (triggers_to_buttons) |
816 | xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; | 831 | xpad->mapping |= MAP_TRIGGERS_TO_BUTTONS; |
832 | if (sticks_to_null) | ||
833 | xpad->mapping |= MAP_STICKS_TO_NULL; | ||
817 | } | 834 | } |
818 | 835 | ||
819 | xpad->dev = input_dev; | 836 | xpad->dev = input_dev; |
@@ -830,16 +847,20 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id | |||
830 | input_dev->open = xpad_open; | 847 | input_dev->open = xpad_open; |
831 | input_dev->close = xpad_close; | 848 | input_dev->close = xpad_close; |
832 | 849 | ||
833 | input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS); | 850 | input_dev->evbit[0] = BIT_MASK(EV_KEY); |
851 | |||
852 | if (!(xpad->mapping & MAP_STICKS_TO_NULL)) { | ||
853 | input_dev->evbit[0] |= BIT_MASK(EV_ABS); | ||
854 | /* set up axes */ | ||
855 | for (i = 0; xpad_abs[i] >= 0; i++) | ||
856 | xpad_set_up_abs(input_dev, xpad_abs[i]); | ||
857 | } | ||
834 | 858 | ||
835 | /* set up standard buttons and axes */ | 859 | /* set up standard buttons */ |
836 | for (i = 0; xpad_common_btn[i] >= 0; i++) | 860 | for (i = 0; xpad_common_btn[i] >= 0; i++) |
837 | __set_bit(xpad_common_btn[i], input_dev->keybit); | 861 | __set_bit(xpad_common_btn[i], input_dev->keybit); |
838 | 862 | ||
839 | for (i = 0; xpad_abs[i] >= 0; i++) | 863 | /* set up model-specific ones */ |
840 | xpad_set_up_abs(input_dev, xpad_abs[i]); | ||
841 | |||
842 | /* Now set up model-specific ones */ | ||
843 | if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) { | 864 | if (xpad->xtype == XTYPE_XBOX360 || xpad->xtype == XTYPE_XBOX360W) { |
844 | for (i = 0; xpad360_btn[i] >= 0; i++) | 865 | for (i = 0; xpad360_btn[i] >= 0; i++) |
845 | __set_bit(xpad360_btn[i], input_dev->keybit); | 866 | __set_bit(xpad360_btn[i], input_dev->keybit); |