Re: [PATCH 3/3] (uu.6cd36bd9ef57) joystick/xpad.c -- Trigger buttons handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Third patch in a series of three.
--
   Added module parameter trigger_to_buttons, to let users force triggers
    to behave as buttons.

    Signed-off-by: Nicolas Léveillé <nicolas@xxxxxxxxxx>

diff --git a/Documentation/input/xpad.txt b/Documentation/input/xpad.txt
index aae0d40..01c9d1f 100644
--- a/Documentation/input/xpad.txt
+++ b/Documentation/input/xpad.txt
@@ -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 <mfr@xxxxxxxxxxxxxxx>
 2002-07-16
  - original doc
@@ -181,3 +193,7 @@ Marko Friedemann <mfr@xxxxxxxxxxxxxxx>
 Dominic Cerquetti <binary1230@xxxxxxxxx>
 2005-03-19
  - added stuff for dance pads, new d-pad->axes mappings
+
+Nicolas Léveillé <nicolas@xxxxxxxxxx>
+2009-11-21
+ - added triggers remapping.
diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 0d43838..7875494 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux