xpad - Allow mapping D-pad to buttons for all pads
Subsystems (3)
PATCH 1/2 xpad - Allow mapping D-pad to buttons for all pads
From: Michael Gruber <[email protected]>
If the new module option force_dpad_to_buttons is set, the directional pad will be mapped to 4buttons instead of 2axes for all controllers. This includes those in the list of known controllers which are not affected by the existing option dpad_to_buttons.
---
The ability to switch between axes and buttons mode is already present in the driver but it is only possible if the connected controller is not known by the driver. This patch makes the feature available for all pads.
Documentation/input/xpad.txt | 4 +++- drivers/input/joystick/xpad.c | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-)
Documentation/input/xpad.txt +3 -1
@@ -25,7 +25,9 @@ not listed below), the driver will map t if you said N it will map the d-pad to buttons, which is needed for dance style games to function correctly. The default is Y. -dpad_to_buttons has no effect for known pads. +dpad_to_buttons has no effect for known pads. If you want to override the +d-pad mapping to use buttons instead of axes for a known controller you +should set force_dpad_to_buttons to Y. The default is N. 0.1 Normal Controllers ----------------------
drivers/input/joystick/xpad.c +6 -1
@@ -98,6 +98,9 @@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 force_dpad_to_buttons; +module_param (force_dpad_to_buttons, bool,S_IRUGO ); +MODULE_PARM_DESC (force_dpad_to_buttons,"Map D-PAD to buttons rather than axes for all pads" ); static const struct xpad_device { u16 idVendor;
@@ -742,7 +745,9 @@ static int xpad_probe(struct usb_interfa xpad->udev = udev; xpad->dpad_mapping = xpad_device[i].dpad_mapping; xpad->xtype = xpad_device[i].xtype; -if (xpad->dpad_mapping ==MAP_DPAD_UNKNOWN ) +if (force_dpad_to_buttons) + xpad->dpad_mapping =MAP_DPAD_TO_BUTTONS ; +else 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 ) {
Signature · 6 lines
249 Spiele für nur 1 Preis. Die GMX Spieleflatrate schon ab 9,90 Euro. Neu: Asterix bei den Olympischen Spielen: http://flat.games.gmx.de -- 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 Michael,
Quoted 7 lines · Michael Gruber
From: Michael Gruber <[email protected]>
If the new module option
force_dpad_to_buttonsis set, the directional pad will be mapped to 4buttons instead of 2axes for all controllers. This includes those in the list of known controllers which are not affected by the existing optiondpad_to_buttons.
The option was there to adapt mappings for the new controllers we don'ty know about yet. Coudl you explain why one would want to map axes to buttons on a controller that is known to be not a d-pad?
Thanks!
Signature · 1 line
Dmitry
Quoted 11 lines · Dmitry Torokhov
Hi Michael,
Quoted 7 lines · Michael Gruber
From: Michael Gruber <[email protected]>
If the new module option
force_dpad_to_buttonsis set, the directional pad will be mapped to 4buttons instead of 2axes for all controllers. This includes those in the list of known controllers which are not affected by the existing optiondpad_to_buttons.
Quoted 8 lines
The option was there to adapt mappings for the new controllers we don'ty know about yet. Coudl you explain why one would want to map axes to buttons on a controller that is known to be not a d-pad?
Thanks!
--
Dmitry
For me being able to choose between 2axis or 4buttons is an additional feature. Currently this feature is only offered if the controller is unknown which means that if you have a known controller you end up with less features, which is paradox.
Possible usage scenario: A user wants to play a first person shooter; he needs 2axes to look around and 2axes to move. Those 4axes are provided by the two thumbsticks; the dpad and the trigger axes are useless for this player but he might need a lot of buttons: fire, zoom, jump, duck, sprint, reload, switch weapons, grenades, flashlight, and more; hence he would profit from having more buttons; if the triggers acted as buttons then he could bind fire to the trigger and if the directional pad acted as 4 buttons then he could for example use them as shortcuts to his four favourite weapons.
A lot of Xbox360 games use the triggers and dpad axes for actions that can usually only be bound to buttons in PC games. Thus a Xbox-user might be expecting an easy way to get the same functionality with the linux driver.