From: "Pär Eriksson" <parherman@gmail.com>
To: "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
"Vicki Pfau" <vi@endrift.com>,
"Pavel Rojtberg" <rojtberg@gmail.com>,
"Nilton Perim Neto" <niltonperimneto@gmail.com>,
"Pär Eriksson" <parherman@gmail.com>,
"Antheas Kapenekakis" <lkml@antheas.dev>,
"Pierre-Loup A. Griffais" <pgriffais@valvesoftware.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] Input: xpad - Implement custom axis mapping for Ferrari 458 Spider
Date: Tue, 5 Aug 2025 21:20:30 +0200 [thread overview]
Message-ID: <20250805192036.53918-4-parherman@gmail.com> (raw)
In-Reply-To: <20250805192036.53918-1-parherman@gmail.com>
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@gmail.com>
---
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
next prev parent reply other threads:[~2025-08-05 19:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-05 19:20 [PATCH 0/3] xpad: Add support for Thrustmaster, Inc. Ferrari 458 Spider Racing Wheel Pär Eriksson
2025-08-05 19:20 ` [PATCH 1/3] Input: xpad - Add MAP_FERRARI_458_CUSTOM_AXES mapping flag Pär Eriksson
2025-08-05 19:20 ` [PATCH 2/3] Input: xpad - Add Thrustmaster Ferrari 458 Spider (044f:b671) device entry Pär Eriksson
2025-08-05 19:20 ` Pär Eriksson [this message]
2025-08-05 20:23 ` [PATCH 0/3] xpad: Add support for Thrustmaster, Inc. Ferrari 458 Spider Racing Wheel Vicki Pfau
2025-08-05 20:57 ` Dmitry Torokhov
2025-08-06 0:16 ` Vicki Pfau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250805192036.53918-4-parherman@gmail.com \
--to=parherman@gmail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@antheas.dev \
--cc=niltonperimneto@gmail.com \
--cc=pgriffais@valvesoftware.com \
--cc=rojtberg@gmail.com \
--cc=vi@endrift.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).