(uu.6cd36bd9ef57) joystick/xpad.c -- Support HORI RAP.EX/MadCatz Fightpad
Subsystems (3)
PATCH 1/3 (uu.6cd36bd9ef57) joystick/xpad.c -- Support HORI RAP.EX/MadCatz Fightpad
Part one of three patches against latest head ofgit://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
--
Added two new Xbox 360 devices:
- HORI Real Arcade Pro.EX
- Mad Catz SFIV Fightpad
drivers/input/joystick/xpad.c +0 -0
@@ -125,6 +125,7 @@ static const struct xpad_device { { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller",
MAP_DPAD_TO_AXES, XTYPE_XBOX },
{ 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller",MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
+ { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)",MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
{ 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS,XTYPE_XBOX },
{ 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES,XTYPE_XBOX },
{ 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES,XTYPE_XBOX },
@@ -146,6 +147,7 @@ static const struct xpad_device {
{ 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller",MAP_DPAD_TO_AXES, XTYPE_XBOX360 },
{ 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES,XTYPE_XBOX360 },
{ 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS,XTYPE_XBOX360 },
+ { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_DPAD_TO_AXES,XTYPE_XBOX360 },
{ 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES,XTYPE_XBOX },
{ 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, XTYPE_UNKNOWN }
};
@@ -212,6 +214,7 @@ static struct usb_device_id xpad_table [] = {
XPAD_XBOX360_VENDOR(0x1430), /* RedOctane X-Box 360 controllers */
XPAD_XBOX360_VENDOR(0x146b), /* BigBen Interactive Controllers */
XPAD_XBOX360_VENDOR(0x1bad), /* Rock Band Drums */
+ XPAD_XBOX360_VENDOR(0x0f0d), /* Hori Controllers */
{ }
};
.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Second patch in a series of three.
Signature · 13 lines
Certain devices implement triggers as buttons rather than axes. In
particular,
arcade sticks such as the HORI Real Arcade Pro.EX do not have
analog buttons.
These devices are now setup to present buttons rather than axes for
triggers.
User-space applications often also have problems with
axes-as-buttons. This
removes the artificial difference between buttons and triggers.
Signed-off-by: Nicolas Léveillé <[email protected]>drivers/input/joystick/xpad.c +60 -45
@@ -90,6 +90,9 @@#define MAP_DPAD_TO_AXES 1#define MAP_DPAD_UNKNOWN 2 +#define MAP_TRIGGERS_TO_AXES 0 +#define MAP_TRIGGERS_TO_BUTTONS 1 +#define XTYPE_XBOX 0#define XTYPE_XBOX360 1#define XTYPE_XBOX360W 2
@@ -104,52 +107,53 @@ static const struct xpad_device {u16 idProduct;char *name;u8 dpad_mapping; +u8 trigger_mapping;u8 xtype; } xpad_device[] = { - { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360W }, - { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, - { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, - { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, - { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, - { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX }, - { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, XTYPE_XBOX360 }, - { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_DPAD_TO_AXES, XTYPE_XBOX360 }, - { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES, XTYPE_XBOX }, - { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, XTYPE_UNKNOWN } + { 0x045e, 0x0202, "Microsoft X-Box pad v1 (US)", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x045e, 0x0289, "Microsoft X-Box pad v2 (US)", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x045e, 0x0285, "Microsoft X-Box pad (Japan)", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x045e, 0x0287, "Microsoft Xbox Controller S", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x045e, 0x0719, "Xbox 360 Wireless Receiver", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360W }, + { 0x0c12, 0x8809, "RedOctane Xbox Dance Pad", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x044f, 0x0f07, "Thrustmaster, Inc. Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x046d, 0xc242, "Logitech Chillstream Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x046d, 0xca84, "Logitech Xbox Cordless Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x046d, 0xca88, "Logitech Compact Controller for Xbox", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x05fd, 0x1007, "Mad Catz Controller (unverified)", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x05fd, 0x107a, "InterAct 'PowerPad Pro' X-Box pad (Germany)", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4516, "Mad Catz Control Pad", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4522, "Mad Catz LumiCON", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4526, "Mad Catz Control Pad Pro", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4536, "Mad Catz MicroCON", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4540, "Mad Catz Beat Pad", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4556, "Mad Catz Lynx Wireless Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0738, 0x4716, "Mad Catz Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x0738, 0x4738, "Mad Catz Wired Xbox 360 Controller (SFIV)", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, + { 0x0738, 0x6040, "Mad Catz Beat Pad Pro", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0c12, 0x8802, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0c12, 0x880a, "Pelican Eclipse PL-2023", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0c12, 0x8810, "Zeroplus Xbox Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0c12, 0x9902, "HAMA VibraX - *FAULTY HARDWARE*", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0e4c, 0x1097, "Radica Gamester Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0e4c, 0x2390, "Radica Games Jtech Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0e6f, 0x0003, "Logic3 Freebird wireless Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0e6f, 0x0005, "Eclipse wireless Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0e6f, 0x0006, "Edge wireless Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0e6f, 0x0006, "Pelican 'TSZ' Wired Xbox 360 Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x0e8f, 0x0201, "SmartJoy Frag Xpad/PS2 adaptor", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0f30, 0x0202, "Joytech Advanced Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0f30, 0x8888, "BigBen XBMiniPad Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x102c, 0xff0c, "Joytech Wireless Advanced Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x12ab, 0x8809, "Xbox DDR dancepad", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x1430, 0x4748, "RedOctane Guitar Hero X-plorer", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x1430, 0x8888, "TX6500+ Dance Pad (first generation)", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x146b, 0x0601, "BigBen Interactive XBOX 360 Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x045e, 0x028e, "Microsoft X-Box 360 pad", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x1bad, 0x0003, "Harmonix Rock Band Drumkit", MAP_DPAD_TO_BUTTONS, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX360 }, + { 0x0f0d, 0x0016, "Hori Real Arcade Pro.EX", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, + { 0xffff, 0xffff, "Chinese-made Xbox Controller", MAP_DPAD_TO_AXES, MAP_TRIGGERS_TO_AXES, XTYPE_XBOX }, + { 0x0000, 0x0000, "Generic X-Box pad", MAP_DPAD_UNKNOWN, MAP_TRIGGERS_TO_AXES, XTYPE_UNKNOWN } }; /* buttons shared with xbox and xbox360 */
@@ -181,7 +185,6 @@ static const signed short xpad360_btn[] = { /* buttons for x360 controller */static const signed short xpad_abs[] = {ABS_X ,ABS_Y ,/* left stick */ ABS_RX ,ABS_RY ,/* right stick */ -ABS_Z ,ABS_RZ ,/* triggers left/right */ -1 /* terminating entry */ };
@@ -191,6 +194,18 @@ static const signed short xpad_abs_pad[] = { -1 /* terminating entry */ }; +/* used if MAP_TRIGGERS_TO_AXES */ +static const signed short xpad_abs_triggers[] = { +ABS_Z ,ABS_RZ ,/* triggers left/right */ +-1 +}; + +/* used if MAP_TRIGGERS_TO_BUTTONS */ +static const signed short xpad_btn_triggers[] = { +BTN_TL2 ,BTN_TR2 ,/* triggers left/right */ +-1 +}; +/* Xbox 360 has a vendor-specific class, so we cannot match it with only * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we * match against vendor id as well. Wired Xbox 360 devices have
protocol 1,
@@ -247,6 +262,7 @@ struct usb_xpad {
char phys[64]; /* physical device path */
int dpad_mapping; /* map d-pad to buttons or to axes */
+ int trigger_mapping; /* map triggers to axes */
int xtype; /* type of xbox device */
};
@@ -277,8 +293,13 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d
~(__s16) le16_to_cpup((__le16 *)(data + 18)));
/* triggers left/right */
- input_report_abs(dev, ABS_Z, data[10]);
- input_report_abs(dev, ABS_RZ, data[11]);
+ if (xpad->trigger_mapping == MAP_TRIGGERS_TO_BUTTONS) {+ input_report_key(dev, BTN_TL2, data[10]);
+ input_report_key(dev, BTN_TR2, data[11]);
+ } else /* MAP_TRIGGERS_TO_AXES */ {
+ input_report_abs(dev, ABS_Z, data[10]);
+ input_report_abs(dev, ABS_RZ, data[11]);
+ }
/* digital pad */
if (xpad->dpad_mapping == MAP_DPAD_TO_AXES) {
@@ -371,8 +392,13 @@ static void xpad360_process_packet(struct usb_xpad *xpad,
~(__s16) le16_to_cpup((__le16 *)(data + 12)));
/* triggers left/right */
- input_report_abs(dev, ABS_Z, data[4]);
- input_report_abs(dev, ABS_RZ, data[5]);
+ if (xpad->trigger_mapping == MAP_TRIGGERS_TO_BUTTONS) {+ input_report_key(dev, BTN_TL2, data[4]);
+ input_report_key(dev, BTN_TR2, data[5]);
+ } else /* MAP_TRIGGERS_TO_AXES */ {
+ input_report_abs(dev, ABS_Z, data[4]);
+ input_report_abs(dev, ABS_RZ, data[5]);
+ }
input_sync(dev);
}
@@ -753,6 +779,7 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
xpad->udev = udev;
xpad->dpad_mapping = xpad_device[i].dpad_mapping;
+ xpad->trigger_mapping = xpad_device[i].trigger_mapping;
xpad->xtype = xpad_device[i].xtype;
if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
xpad->dpad_mapping = !dpad_to_buttons;
@@ -794,6 +821,12 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
for (i = 0; xpad_btn_pad[i] >= 0; i++)
set_bit(xpad_btn_pad[i], input_dev->keybit);+ if (xpad->trigger_mapping == MAP_TRIGGERS_TO_BUTTONS) {
+ for (i = 0; xpad_btn_triggers[i] >= 0; i++) {
+ set_bit(xpad_btn_triggers[i], input_dev->keybit);
+ }
+ }
+
/* set up axes */
for (i = 0; xpad_abs[i] >= 0; i++)
xpad_set_up_abs(input_dev, xpad_abs[i]);
@@ -801,6 +834,12 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
for (i = 0; xpad_abs_pad[i] >= 0; i++)
xpad_set_up_abs(input_dev, xpad_abs_pad[i]);+ if (xpad->trigger_mapping == MAP_TRIGGERS_TO_AXES) {
+ for (i = 0; xpad_abs_triggers[i] >= 0; i++) {
+ xpad_set_up_abs(input_dev, xpad_abs_triggers[i]);
+ }
+ }
+
error = xpad_init_output(intf, xpad);
if (error)
goto fail2;--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] (uu.6cd36bd9ef57) joystick/xpad.c -- Trigger buttons handling
Third patch in a series of three.
--
Added module parameter trigger_to_buttons, to let users force triggers
to behave as buttons.
Documentation/input/xpad.txt +0 -0
@@ -19,6 +19,9 @@ The number of buttons/axes reported varies based on 3 things: - if using an unknown device (one not listed below), what you set in the module configuration for "Map D-PAD to buttons rather than axes for
unknown
pads" (module option dpad_to_buttons)
+- if triggers are mapped to buttons or axes. This depends on the device and can be forced via module option triggers_to_buttons. +
+dpad_to_buttons:
If you set dpad_to_buttons to 0 and you are using an unknown device (one not listed below), the driver will map the directional pad to axes (X/Y),
@@ -27,6 +30,15 @@ style games to function correctly. The default is Y.
dpad_to_buttons has no effect for known pads.
+triggers_to_buttons:
+
+If you set triggers_to_buttons to 1 and you are using a device +otherwise configured to map triggers to axes, the module will map them +to digital buttons.
+
+Setting triggers_to_buttons to 0 does not do anything: it does not +make sense to map a device digital button's into an axis.
+
0.1 Normal Controllers
----------------------
With a normal controller, the directional pad is mapped to its own X/Y
axes.
@@ -139,7 +151,7 @@ It works? Voila, you're done ;)
I have to thank ITO Takayuki for the detailed info on his site
http://euc.jp/periphs/xbox-controller.ja.html.
-
+
His useful info and both the usb-skeleton as well as the iforce input
driver
(Greg Kroah-Hartmann; Vojtech Pavlik) helped a lot in rapid prototyping the basic functionality.
@@ -173,7 +185,7 @@ I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
E: Ad=82(I) Atr=03(Int.) MxPS= 32 Ivl=4ms E: Ad=02(O) Atr=03(Int.) MxPS= 32 Ivl=4ms
---
+--
Marko Friedemann <[email protected]> 2002-07-16
- original doc
@@ -181,3 +193,7 @@ Marko Friedemann <[email protected]>
Dominic Cerquetti <[email protected]> 2005-03-19
- added stuff for dance pads, new d-pad->axes mappings
+
+Nicolas Léveillé <[email protected]> +2009-11-21
+ - added triggers remapping.
drivers/input/joystick/xpad.c +0 -0
@@ -102,6 +102,10 @@ static int dpad_to_buttons;module_param (dpad_to_buttons, bool,S_IRUGO ); MODULE_PARM_DESC(dpad_to_buttons, "Map D-PAD to buttons rather than
axes for unknown pads");
+static int triggers_to_buttons;
+module_param(triggers_to_buttons, bool, S_IRUGO); +MODULE_PARM_DESC(triggers_to_buttons, "Map triggers to buttons rather than axes"); +
static const struct xpad_device {
u16 idVendor;
u16 idProduct;
@@ -781,8 +785,16 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
xpad->dpad_mapping = xpad_device[i].dpad_mapping;
xpad->trigger_mapping = xpad_device[i].trigger_mapping;
xpad->xtype = xpad_device[i].xtype;
+
if (xpad->dpad_mapping == MAP_DPAD_UNKNOWN)
xpad->dpad_mapping = !dpad_to_buttons;+
+ /* let module parameters override trigger_mapping */
+ if (triggers_to_buttons) {
+ printk (KERN_INFO "xpad: forcing triggers to map to buttons.\n");
+ xpad->trigger_mapping = MAP_TRIGGERS_TO_BUTTONS;
+ }
+
if (xpad->xtype == XTYPE_UNKNOWN) {
if (intf->cur_altsetting->desc.bInterfaceClass ==
USB_CLASS_VENDOR_SPEC) {
if (intf->cur_altsetting->desc.bInterfaceProtocol == 129)--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov
maintainerHi Nicolas,
Quoted 3 lines · Nicolas Léveillé
Part one of three patches against latest head of
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
It looks like your mailer wrapped the mails so the patches won't apply. Please resend. Also, instead of creating a new field maybe chnage dpad_mapping to be a bitmap of options?
Thanks.
Signature · 5 lines
Dmitry -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi, thanks for the feedback.
I'll soon resend the first two patches as properly formatted ones. (git format-patch this time)
About the third one adding a "trigger_mapping" option:
When reusing the dpad_mapping field to add new options to it are you thinking about turning it into a numerical constant that goes 0-1-2-3 for all mapping combinations?
It does not needlessly break user space's configuration scripts, however the name and semantics of the option are more complicated.
In particular the semantics of the existing dpad_mapping option is a bit strange already, since it only act on "unknown" devices / do not act on known devices.
Which I'm not sure works anyway? My devices only started to work when I registered their vendor and product id.
Why not allow overriding mappings of a known device?
Cheers,
Nicolas
Quoted 7 lines · Dmitry Torokhov
Hi Nicolas,
Quoted 3 lines · Nicolas Léveillé
Part one of three patches against latest head of
git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git
Quoted 10 lines
It looks like your mailer wrapped the mails so the patches won't apply. Please resend. Also, instead of creating a new field maybe chnage
dpad_mappingto be a bitmap of options?Thanks.
Signature · 1 line
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov
maintainerQuoted 10 lines · Nicolas Léveillé
Hi, thanks for the feedback.
I'll soon resend the first two patches as properly formatted ones. (git format-patch this time)
About the third one adding a "
trigger_mapping" option:When reusing the
dpad_mappingfield to add new options to it are you thinking about turning it into a numerical constant that goes 0-1-2-3 for all mapping combinations?
Rather a bitmap for mapping AXIS and DPAD to button.
Quoted 7 lines
It does not needlessly break user space's configuration scripts, however the name and semantics of the option are more complicated.
In particular the semantics of the existing
dpad_mappingoption is a bit strange already, since it only act on "unknown" devices / do not act on known devices.
The idea was is that for known devices the selection option is the proper one and it does not make sense to change it.
Quoted 3 lines
Which I'm not sure works anyway? My devices only started to work when I registered their vendor and product id.
We bind depening on vendor and interface. If vendor is known but particular model is not it will be "Unknown" and you can remap.
Quoted 2 lines
Why not allow overriding mappings of a known device?
See above.
So, could you please try the patch below and let me know if I broke it? I already applied your other patch adding new devices.
Thanks!
Signature · 24 lines
Dmitry Input: xpad - allow using triggers as buttons rather than axes From: Nicolas Léveillé <[email protected]> Certain devices implement triggers as buttons rather than axes. In particular, arcade sticks such as the HORI Real Arcade Pro.EX do not have analog buttons. These devices are now setup to present buttons rather than axes for triggers. User-space applications often also have problems with axes-as-buttons. Activating MAP_TRIGGERS_TO_BUTTONS for a device removes the artificial difference between buttons and triggers. Signed-off-by: Nicolas Léveillé <[email protected]> Signed-off-by: Dmitry Torokhov <[email protected]> --- drivers/input/joystick/xpad.c | 200 +++++++++++++++++++++++++---------------- 1 files changed, 121 insertions(+), 79 deletions(-)
drivers/input/joystick/xpad.c +121 -79
@@ -86,9 +86,8 @@/* xbox d-pads should map to buttons, as is required for DDR pads but we map them to axes when possible to simplify things */ -#define MAP_DPAD_TO_BUTTONS 0 -#define MAP_DPAD_TO_AXES 1 -#define MAP_DPAD_UNKNOWN 2 +#define MAP_DPAD_TO_BUTTONS (1 << 0) +#define MAP_TRIGGERS_TO_BUTTONS (1 << 1)#define XTYPE_XBOX 0#define XTYPE_XBOX360 1
@@ -99,57 +98,61 @@ static int dpad_to_buttons;module_param (dpad_to_buttons, bool,S_IRUGO );MODULE_PARM_DESC (dpad_to_buttons,"Map D-PAD to buttons rather than axes for unknown pads" ); +static int triggers_to_buttons; +module_param (triggers_to_buttons, bool,S_IRUGO ); +MODULE_PARM_DESC (triggers_to_buttons,"Map triggers to buttons rather than axes for unknown pads" ); +static const struct xpad_device {u16 idVendor;u16 idProduct;char *name; -u8 dpad_mapping; +u8 mapping;u8 xtype; } xpad_device[] = { - {0x045e ,0x0202 ,"Microsoft X-Box pad v1 (US)" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x045e ,0x0289 ,"Microsoft X-Box pad v2 (US)" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x045e ,0x0285 ,"Microsoft X-Box pad (Japan)" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x045e ,0x0287 ,"Microsoft Xbox Controller S" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, + {0x045e ,0x0202 ,"Microsoft X-Box pad v1 (US)" ,0 ,XTYPE_XBOX }, + {0x045e ,0x0289 ,"Microsoft X-Box pad v2 (US)" ,0 ,XTYPE_XBOX }, + {0x045e ,0x0285 ,"Microsoft X-Box pad (Japan)" ,0 ,XTYPE_XBOX }, + {0x045e ,0x0287 ,"Microsoft Xbox Controller S" ,0 ,XTYPE_XBOX }, {0x045e ,0x0719 ,"Xbox 360 Wireless Receiver" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX360W }, {0x0c12 ,0x8809 ,"RedOctane Xbox Dance Pad" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX }, - {0x044f ,0x0f07 ,"Thrustmaster, Inc. Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x046d ,0xc242 ,"Logitech Chillstream Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, - {0x046d ,0xca84 ,"Logitech Xbox Cordless Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x046d ,0xca88 ,"Logitech Compact Controller for Xbox" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x05fd ,0x1007 ,"Mad Catz Controller (unverified)" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x05fd ,0x107a ,"InterAct 'PowerPad Pro' X-Box pad (Germany)" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0738 ,0x4516 ,"Mad Catz Control Pad" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0738 ,0x4522 ,"Mad Catz LumiCON" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0738 ,0x4526 ,"Mad Catz Control Pad Pro" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0738 ,0x4536 ,"Mad Catz MicroCON" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, + {0x044f ,0x0f07 ,"Thrustmaster, Inc. Controller" ,0 ,XTYPE_XBOX }, + {0x046d ,0xc242 ,"Logitech Chillstream Controller" ,0 ,XTYPE_XBOX360 }, + {0x046d ,0xca84 ,"Logitech Xbox Cordless Controller" ,0 ,XTYPE_XBOX }, + {0x046d ,0xca88 ,"Logitech Compact Controller for Xbox" ,0 ,XTYPE_XBOX }, + {0x05fd ,0x1007 ,"Mad Catz Controller (unverified)" ,0 ,XTYPE_XBOX }, + {0x05fd ,0x107a ,"InterAct 'PowerPad Pro' X-Box pad (Germany)" ,0 ,XTYPE_XBOX }, + {0x0738 ,0x4516 ,"Mad Catz Control Pad" ,0 ,XTYPE_XBOX }, + {0x0738 ,0x4522 ,"Mad Catz LumiCON" ,0 ,XTYPE_XBOX }, + {0x0738 ,0x4526 ,"Mad Catz Control Pad Pro" ,0 ,XTYPE_XBOX }, + {0x0738 ,0x4536 ,"Mad Catz MicroCON" ,0 ,XTYPE_XBOX }, {0x0738 ,0x4540 ,"Mad Catz Beat Pad" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX }, - {0x0738 ,0x4556 ,"Mad Catz Lynx Wireless Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0738 ,0x4716 ,"Mad Catz Wired Xbox 360 Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, - {0x0738 ,0x4738 ,"Mad Catz Wired Xbox 360 Controller (SFIV)" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, + {0x0738 ,0x4556 ,"Mad Catz Lynx Wireless Controller" ,0 ,XTYPE_XBOX }, + {0x0738 ,0x4716 ,"Mad Catz Wired Xbox 360 Controller" ,0 ,XTYPE_XBOX360 }, + {0x0738 ,0x4738 ,"Mad Catz Wired Xbox 360 Controller (SFIV)" ,MAP_TRIGGERS_TO_BUTTONS ,XTYPE_XBOX360 }, {0x0738 ,0x6040 ,"Mad Catz Beat Pad Pro" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX }, - {0x0c12 ,0x8802 ,"Zeroplus Xbox Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0c12 ,0x880a ,"Pelican Eclipse PL-2023" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0c12 ,0x8810 ,"Zeroplus Xbox Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0c12 ,0x9902 ,"HAMA VibraX - *FAULTY HARDWARE*" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0e4c ,0x1097 ,"Radica Gamester Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0e4c ,0x2390 ,"Radica Games Jtech Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0e6f ,0x0003 ,"Logic3 Freebird wireless Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0e6f ,0x0005 ,"Eclipse wireless Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0e6f ,0x0006 ,"Edge wireless Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0e6f ,0x0006 ,"Pelican 'TSZ' Wired Xbox 360 Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, - {0x0e8f ,0x0201 ,"SmartJoy Frag Xpad/PS2 adaptor" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0f30 ,0x0202 ,"Joytech Advanced Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0f30 ,0x8888 ,"BigBen XBMiniPad Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x102c ,0xff0c ,"Joytech Wireless Advanced Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, + {0x0c12 ,0x8802 ,"Zeroplus Xbox Controller" ,0 ,XTYPE_XBOX }, + {0x0c12 ,0x880a ,"Pelican Eclipse PL-2023" ,0 ,XTYPE_XBOX }, + {0x0c12 ,0x8810 ,"Zeroplus Xbox Controller" ,0 ,XTYPE_XBOX }, + {0x0c12 ,0x9902 ,"HAMA VibraX - *FAULTY HARDWARE*" ,0 ,XTYPE_XBOX }, + {0x0e4c ,0x1097 ,"Radica Gamester Controller" ,0 ,XTYPE_XBOX }, + {0x0e4c ,0x2390 ,"Radica Games Jtech Controller" ,0 ,XTYPE_XBOX }, + {0x0e6f ,0x0003 ,"Logic3 Freebird wireless Controller" ,0 ,XTYPE_XBOX }, + {0x0e6f ,0x0005 ,"Eclipse wireless Controller" ,0 ,XTYPE_XBOX }, + {0x0e6f ,0x0006 ,"Edge wireless Controller" ,0 ,XTYPE_XBOX }, + {0x0e6f ,0x0006 ,"Pelican 'TSZ' Wired Xbox 360 Controller" ,0 ,XTYPE_XBOX360 }, + {0x0e8f ,0x0201 ,"SmartJoy Frag Xpad/PS2 adaptor" ,0 ,XTYPE_XBOX }, + {0x0f30 ,0x0202 ,"Joytech Advanced Controller" ,0 ,XTYPE_XBOX }, + {0x0f30 ,0x8888 ,"BigBen XBMiniPad Controller" ,0 ,XTYPE_XBOX }, + {0x102c ,0xff0c ,"Joytech Wireless Advanced Controller" ,0 ,XTYPE_XBOX }, {0x12ab ,0x8809 ,"Xbox DDR dancepad" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX }, - {0x1430 ,0x4748 ,"RedOctane Guitar Hero X-plorer" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, + {0x1430 ,0x4748 ,"RedOctane Guitar Hero X-plorer" ,0 ,XTYPE_XBOX360 }, {0x1430 ,0x8888 ,"TX6500+ Dance Pad (first generation)" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX }, - {0x146b ,0x0601 ,"BigBen Interactive XBOX 360 Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, - {0x045e ,0x028e ,"Microsoft X-Box 360 pad" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, + {0x146b ,0x0601 ,"BigBen Interactive XBOX 360 Controller" ,0 ,XTYPE_XBOX360 }, + {0x045e ,0x028e ,"Microsoft X-Box 360 pad" ,0 ,XTYPE_XBOX360 }, {0x1bad ,0x0003 ,"Harmonix Rock Band Drumkit" ,MAP_DPAD_TO_BUTTONS ,XTYPE_XBOX360 }, - {0x0f0d ,0x0016 ,"Hori Real Arcade Pro.EX" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX360 }, - {0xffff ,0xffff ,"Chinese-made Xbox Controller" ,MAP_DPAD_TO_AXES ,XTYPE_XBOX }, - {0x0000 ,0x0000 ,"Generic X-Box pad" ,MAP_DPAD_UNKNOWN ,XTYPE_UNKNOWN } + {0x0f0d ,0x0016 ,"Hori Real Arcade Pro.EX" ,MAP_TRIGGERS_TO_BUTTONS ,XTYPE_XBOX360 }, + {0xffff ,0xffff ,"Chinese-made Xbox Controller" ,0 ,XTYPE_XBOX }, + {0x0000 ,0x0000 ,"Generic X-Box pad" ,0 ,XTYPE_UNKNOWN } };/* buttons shared with xbox and xbox360 */
@@ -165,13 +168,20 @@ static const signed short xpad_btn[] = {-1 /* terminating entry */ }; -/* only used if MAP_DPAD_TO_BUTTONS */ +/* used when dpad is mapped to nuttons */ static const signed short xpad_btn_pad[] = {BTN_LEFT ,BTN_RIGHT ,/* d-pad left, right */ BTN_0 ,BTN_1 ,/* d-pad up, down (XXX names??) */ -1 /* terminating entry */ }; +/* used when triggers are mapped to buttons */ +static const signed short xpad_btn_triggers[] = { +BTN_TL2 ,BTN_TR2 ,/* triggers left/right */ +-1 +}; + +static const signed short xpad360_btn[] = {/* buttons for x360 controller */ BTN_TL ,BTN_TR ,/* Button LB/RB */ BTN_MODE ,/* The big X button */
@@ -181,16 +191,21 @@ static const signed short xpad360_btn[] = { /* buttons for x360 controller */static const signed short xpad_abs[] = {ABS_X ,ABS_Y ,/* left stick */ ABS_RX ,ABS_RY ,/* right stick */ -ABS_Z ,ABS_RZ ,/* triggers left/right */ -1 /* terminating entry */ }; -/* only used if MAP_DPAD_TO_AXES */ +/* used when dpad is mapped to axes */ static const signed short xpad_abs_pad[] = {ABS_HAT0X ,ABS_HAT0Y ,/* d-pad axes */ -1 /* terminating entry */ }; +/* used when triggers are mapped to axes */ +static const signed short xpad_abs_triggers[] = { +ABS_Z ,ABS_RZ ,/* triggers left/right */ +-1 +}; +/* Xbox 360 has a vendor-specific class, so we cannot match it with only * USB_INTERFACE_INFO (also specifically refused by USB subsystem), so we * match against vendor id as well. Wired Xbox 360 devices have protocol 1,
@@ -246,7 +261,7 @@ struct usb_xpad {char phys[64 ];/* physical device path */ -int dpad_mapping;/* map d-pad to buttons or to axes */ +int mapping;/* map d-pad to buttons or to axes */ int xtype;/* type of xbox device */ };
@@ -277,20 +292,25 @@ static void xpad_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char *d ~(__s16) le16_to_cpup((__le16 *)(data + 18)));/* triggers left/right */ -input_report_abs (dev,ABS_Z , data[10 ]); -input_report_abs (dev,ABS_RZ , data[11 ]); +if (xpad->mapping &MAP_TRIGGERS_TO_BUTTONS ) { +input_report_key (dev,BTN_TL2 , data[10 ]); +input_report_key (dev,BTN_TR2 , data[11 ]); + }else { +input_report_abs (dev,ABS_Z , data[10 ]); +input_report_abs (dev,ABS_RZ , data[11 ]); + }/* digital pad */ -if (xpad->dpad_mapping ==MAP_DPAD_TO_AXES ) { -input_report_abs (dev,ABS_HAT0X , - !!(data[2 ] &0x08 ) - !!(data[2 ] &0x04 )); -input_report_abs (dev,ABS_HAT0Y , - !!(data[2 ] &0x02 ) - !!(data[2 ] &0x01 )); - }else /* xpad->dpad_mapping == MAP_DPAD_TO_BUTTONS */ { +if (xpad->mapping &MAP_DPAD_TO_BUTTONS ) {input_report_key (dev,BTN_LEFT , data[2 ] &0x04 );input_report_key (dev,BTN_RIGHT , data[2 ] &0x08 );input_report_key (dev,BTN_0 , data[2 ] &0x01 );/* up */ input_report_key (dev,BTN_1 , data[2 ] &0x02 );/* down */ + }else { +input_report_abs (dev,ABS_HAT0X , + !!(data[2 ] &0x08 ) - !!(data[2 ] &0x04 )); +input_report_abs (dev,ABS_HAT0Y , + !!(data[2 ] &0x02 ) - !!(data[2 ] &0x01 )); }/* start/back buttons and stick press left/right */
@@ -328,17 +348,17 @@ static void xpad360_process_packet(struct usb_xpad *xpad,struct input_dev *dev = xpad->dev;/* digital pad */ -if (xpad->dpad_mapping ==MAP_DPAD_TO_AXES ) { -input_report_abs (dev,ABS_HAT0X , - !!(data[2 ] &0x08 ) - !!(data[2 ] &0x04 )); -input_report_abs (dev,ABS_HAT0Y , - !!(data[2 ] &0x02 ) - !!(data[2 ] &0x01 )); - }else if (xpad->dpad_mapping ==MAP_DPAD_TO_BUTTONS ) { +if (xpad->mapping &MAP_DPAD_TO_BUTTONS ) {/* dpad as buttons (right, left, down, up) */ input_report_key (dev,BTN_LEFT , data[2 ] &0x04 );input_report_key (dev,BTN_RIGHT , data[2 ] &0x08 );input_report_key (dev,BTN_0 , data[2 ] &0x01 );/* up */ input_report_key (dev,BTN_1 , data[2 ] &0x02 );/* down */ + }else { +input_report_abs (dev,ABS_HAT0X , + !!(data[2 ] &0x08 ) - !!(data[2 ] &0x04 )); +input_report_abs (dev,ABS_HAT0Y , + !!(data[2 ] &0x02 ) - !!(data[2 ] &0x01 )); }/* start/back buttons */
@@ -371,8 +391,13 @@ static void xpad360_process_packet(struct usb_xpad *xpad, ~(__s16) le16_to_cpup((__le16 *)(data + 12)));/* triggers left/right */ -input_report_abs (dev,ABS_Z , data[4 ]); -input_report_abs (dev,ABS_RZ , data[5 ]); +if (xpad->mapping &MAP_TRIGGERS_TO_BUTTONS ) { +input_report_key (dev,BTN_TL2 , data[4 ]); +input_report_key (dev,BTN_TR2 , data[5 ]); + }else { +input_report_abs (dev,ABS_Z , data[4 ]); +input_report_abs (dev,ABS_RZ , data[5 ]); + }input_sync (dev); }
@@ -712,11 +737,11 @@ static void xpad_set_up_abs(struct input_dev *input_dev, signed short abs)input_set_abs_params (input_dev, abs,-32768 ,32767 ,16 ,128 );break ;case ABS_Z : -case ABS_RZ :/* the triggers */ +case ABS_RZ :/* the triggers (if mapped to axes) */ input_set_abs_params (input_dev, abs,0 ,255 ,0 ,0 );break ;case ABS_HAT0X : -case ABS_HAT0Y :/* the d-pad (only if MAP_DPAD_TO_AXES) */ +case ABS_HAT0Y :/* the d-pad (only if dpad is mapped to axes */ input_set_abs_params (input_dev, abs,-1 ,1 ,0 ,0 );break ; }
@@ -752,10 +777,9 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id goto fail2; xpad->udev = udev; - xpad->dpad_mapping = xpad_device[i].dpad_mapping; + xpad->mapping = xpad_device[i].mapping; xpad->xtype = xpad_device[i].xtype; -if (xpad->dpad_mapping ==MAP_DPAD_UNKNOWN ) - xpad->dpad_mapping = !dpad_to_buttons; +if (xpad->xtype ==XTYPE_UNKNOWN ) {if (intf->cur_altsetting->desc.bInterfaceClass ==USB_CLASS_VENDOR_SPEC ) {if (intf->cur_altsetting->desc.bInterfaceProtocol ==129 )
@@ -764,7 +788,13 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id xpad->xtype =XTYPE_XBOX360 ; }else xpad->xtype =XTYPE_XBOX ; + +if (dpad_to_buttons) + xpad->mapping |=MAP_DPAD_TO_BUTTONS ; +if (triggers_to_buttons) + xpad->mapping |=MAP_TRIGGERS_TO_BUTTONS ; } + xpad->dev = input_dev;usb_make_path (udev, xpad->phys,sizeof (xpad->phys));strlcat (xpad->phys,"/input0" ,sizeof (xpad->phys));
@@ -781,25 +811,37 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id input_dev->evbit[0 ] =BIT_MASK (EV_KEY ) |BIT_MASK (EV_ABS ); -/* set up buttons */ +/* set up standard buttons and axes */ for (i =0 ; xpad_common_btn[i] >=0 ; i++) -set_bit (xpad_common_btn[i], input_dev->keybit); -if ((xpad->xtype ==XTYPE_XBOX360 ) || (xpad->xtype ==XTYPE_XBOX360W )) -for (i =0 ; xpad360_btn[i] >=0 ; i++) -set_bit (xpad360_btn[i], input_dev->keybit); -else -for (i =0 ; xpad_btn[i] >=0 ; i++) -set_bit (xpad_btn[i], input_dev->keybit); -if (xpad->dpad_mapping ==MAP_DPAD_TO_BUTTONS ) -for (i =0 ; xpad_btn_pad[i] >=0 ; i++) -set_bit (xpad_btn_pad[i], input_dev->keybit); +__set_bit (xpad_common_btn[i], input_dev->keybit); -/* set up axes */ for (i =0 ; xpad_abs[i] >=0 ; i++)xpad_set_up_abs (input_dev, xpad_abs[i]); -if (xpad->dpad_mapping ==MAP_DPAD_TO_AXES ) + +/* Now set up model-specific ones */ +if (xpad->xtype ==XTYPE_XBOX360 || xpad->xtype ==XTYPE_XBOX360W ) { +for (i =0 ; xpad360_btn[i] >=0 ; i++) +__set_bit (xpad360_btn[i], input_dev->keybit); + }else { +for (i =0 ; xpad_btn[i] >=0 ; i++) +__set_bit (xpad_btn[i], input_dev->keybit); + } + +if (xpad->mapping &MAP_DPAD_TO_BUTTONS ) { +for (i =0 ; xpad_btn_pad[i] >=0 ; i++) +__set_bit (xpad_btn_pad[i], input_dev->keybit); + }else {for (i =0 ; xpad_abs_pad[i] >=0 ; i++)xpad_set_up_abs (input_dev, xpad_abs_pad[i]); + } + +if (xpad->mapping &MAP_TRIGGERS_TO_BUTTONS ) { +for (i =0 ; xpad_btn_triggers[i] >=0 ; i++) +__set_bit (xpad_btn_triggers[i], input_dev->keybit); + }else { +for (i =0 ; xpad_abs_triggers[i] >=0 ; i++) +xpad_set_up_abs (input_dev, xpad_abs_triggers[i]); + } error =xpad_init_output (intf, xpad);if (error)
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html