[PATCH 3/3] Input: xpad - Implement custom axis mapping for Ferrari 458 Spider

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

 



Update xpadone_process_packet to handle steering and pedal data at
non-standard offsets for devices with MAP_FERRARI_458_CUSTOM_AXES.

Signed-off-by: Pär Eriksson <parherman@xxxxxxxxx>
---
 drivers/input/joystick/xpad.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index fdd70f256be7..252290424bbd 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1135,17 +1135,23 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 		input_report_key(dev, BTN_THUMBR, data[5] & BIT(7));
 
 		if (!(xpad->mapping & MAP_STICKS_TO_NULL)) {
-			/* left stick */
-			input_report_abs(dev, ABS_X,
-					(__s16) le16_to_cpup((__le16 *)(data + 10)));
-			input_report_abs(dev, ABS_Y,
-					~(__s16) le16_to_cpup((__le16 *)(data + 12)));
-
-			/* right stick */
-			input_report_abs(dev, ABS_RX,
-					(__s16) le16_to_cpup((__le16 *)(data + 14)));
-			input_report_abs(dev, ABS_RY,
-					~(__s16) le16_to_cpup((__le16 *)(data + 16)));
+			if (xpad->mapping & MAP_FERRARI_458_CUSTOM_AXES) {
+				/* steering wheel */
+				input_report_abs(dev, ABS_X,
+				((__u16) le16_to_cpup((__le16 *)(data + 6))) - S16_MAX);
+			} else {
+				/* left stick */
+				input_report_abs(dev, ABS_X,
+						(__s16) le16_to_cpup((__le16 *)(data + 10)));
+				input_report_abs(dev, ABS_Y,
+						~(__s16) le16_to_cpup((__le16 *)(data + 12)));
+
+				/* right stick */
+				input_report_abs(dev, ABS_RX,
+						(__s16) le16_to_cpup((__le16 *)(data + 14)));
+				input_report_abs(dev, ABS_RY,
+						~(__s16) le16_to_cpup((__le16 *)(data + 16)));
+			}
 		}
 
 		/* triggers left/right */
@@ -1154,6 +1160,11 @@ static void xpadone_process_packet(struct usb_xpad *xpad, u16 cmd, unsigned char
 					(__u16) le16_to_cpup((__le16 *)(data + 6)));
 			input_report_key(dev, BTN_TR2,
 					(__u16) le16_to_cpup((__le16 *)(data + 8)));
+		} else if (xpad->mapping & MAP_FERRARI_458_CUSTOM_AXES) {
+			input_report_abs(dev, ABS_Z,
+					(__u16) le16_to_cpup((__le16 *)(data + 10)));
+			input_report_abs(dev, ABS_RZ,
+					(__u16) le16_to_cpup((__le16 *)(data + 8)));
 		} else {
 			input_report_abs(dev, ABS_Z,
 					(__u16) le16_to_cpup((__le16 *)(data + 6)));
-- 
2.50.1





[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