From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Tomasz Pakuła" <tomasz.pakula.oficjalny@gmail.com>,
"Michał Kopeć" <michal@nozomi.space>,
"Paul Dino Jones" <paul@spacefreak18.xyz>,
"Jiri Kosina" <jkosina@suse.com>,
"Sasha Levin" <sashal@kernel.org>,
jikos@kernel.org, bentiss@kernel.org, linux-usb@vger.kernel.org,
linux-input@vger.kernel.org
Subject: [PATCH AUTOSEL 6.13 09/24] HID: pidff: Add FIX_WHEEL_DIRECTION quirk
Date: Mon, 31 Mar 2025 10:53:49 -0400 [thread overview]
Message-ID: <20250331145404.1705141-9-sashal@kernel.org> (raw)
In-Reply-To: <20250331145404.1705141-1-sashal@kernel.org>
From: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
[ Upstream commit 3051bf5ec773b803c474ea556b57d678a8885be3 ]
Most steering wheels simply ignore DIRECTION field, but some try to be
compliant with the PID standard and use it in force calculations. Games
often ignore setting this field properly and/or there can be issues with
dinput8 -> wine -> SDL -> Linux API translation, and this value can be
incorrect. This can lead to partial/complete loss of Force Feedback or
even unexpected force reversal.
Sadly, this quirk can't be detected automatically without sending out
effects that would move an axis.
This fixes FFB on Moza Racing devices and others where effect direction
is not simply ignored.
Signed-off-by: Tomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
Reviewed-by: Michał Kopeć <michal@nozomi.space>
Reviewed-by: Paul Dino Jones <paul@spacefreak18.xyz>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/hid/usbhid/hid-pidff.c | 12 +++++++++---
include/linux/hid.h | 1 +
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index b8c2ba0a930c2..a37cf852a2836 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -137,6 +137,9 @@ static const u8 pidff_block_load_status[] = { 0x8c, 0x8d };
#define PID_EFFECT_STOP 1
static const u8 pidff_effect_operation_status[] = { 0x79, 0x7b };
+/* Polar direction 90 degrees (North) */
+#define PIDFF_FIXED_WHEEL_DIRECTION 0x4000
+
struct pidff_usage {
struct hid_field *field;
s32 *value;
@@ -328,9 +331,12 @@ static void pidff_set_effect_report(struct pidff_device *pidff,
pidff->set_effect[PID_GAIN].value[0] =
pidff->set_effect[PID_GAIN].field->logical_maximum;
pidff->set_effect[PID_DIRECTION_ENABLE].value[0] = 1;
- pidff->effect_direction->value[0] =
- pidff_rescale(effect->direction, 0xffff,
- pidff->effect_direction);
+
+ /* Use fixed direction if needed */
+ pidff->effect_direction->value[0] = pidff_rescale(
+ pidff->quirks & HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION ?
+ PIDFF_FIXED_WHEEL_DIRECTION : effect->direction,
+ 0xffff, pidff->effect_direction);
/* Omit setting delay field if it's missing */
if (!(pidff->quirks & HID_PIDFF_QUIRK_MISSING_DELAY))
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 31dfe9ed5394b..7a55accf689e0 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -1234,6 +1234,7 @@ int hid_pidff_init_with_quirks(struct hid_device *hid, __u32 initial_quirks);
#define HID_PIDFF_QUIRK_MISSING_DELAY BIT(0)
#define HID_PIDFF_QUIRK_MISSING_PBO BIT(1)
#define HID_PIDFF_QUIRK_PERMISSIVE_CONTROL BIT(2)
+#define HID_PIDFF_QUIRK_FIX_WHEEL_DIRECTION BIT(3)
#define dbg_hid(fmt, ...) pr_debug("%s: " fmt, __FILE__, ##__VA_ARGS__)
--
2.39.5
next prev parent reply other threads:[~2025-03-31 14:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 14:53 [PATCH AUTOSEL 6.13 01/24] platform/chrome: cros_ec_lpc: Match on Framework ACPI device Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 02/24] ASoC: SOF: topology: Use krealloc_array() to replace krealloc() Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 03/24] HID: pidff: Convert infinite length from Linux API to PID standard Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 04/24] HID: pidff: Do not send effect envelope if it's empty Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 05/24] HID: pidff: Add MISSING_DELAY quirk and its detection Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 06/24] HID: pidff: Add MISSING_PBO " Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 07/24] HID: pidff: Add PERMISSIVE_CONTROL quirk Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 08/24] HID: pidff: Add hid_pidff_init_with_quirks and export as GPL symbol Sasha Levin
2025-03-31 14:53 ` Sasha Levin [this message]
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 10/24] HID: Add hid-universal-pidff driver and supported device ids Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 11/24] HID: pidff: Add PERIODIC_SINE_ONLY quirk Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 12/24] HID: pidff: Fix null pointer dereference in pidff_find_fields Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 13/24] ASoC: amd: ps: use macro for ACP6.3 pci revision id Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 14/24] ASoC: amd: amd_sdw: Add quirks for Dell SKU's Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 15/24] ALSA: hda: intel: Fix Optimus when GPU has no sound Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 16/24] ALSA: hda: intel: Add Lenovo IdeaPad Z570 to probe denylist Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 17/24] ASoC: fsl_audmix: register card device depends on 'dais' property Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 18/24] media: uvcvideo: Add quirk for Actions UVC05 Sasha Levin
2025-03-31 14:53 ` [PATCH AUTOSEL 6.13 19/24] media: s5p-mfc: Corrected NV12M/NV21M plane-sizes Sasha Levin
2025-03-31 14:54 ` [PATCH AUTOSEL 6.13 20/24] mmc: dw_mmc: add a quirk for accessing 64-bit FIFOs in two halves Sasha Levin
2025-03-31 14:54 ` [PATCH AUTOSEL 6.13 21/24] ALSA: usb-audio: Fix CME quirk for UF series keyboards Sasha Levin
2025-03-31 14:54 ` [PATCH AUTOSEL 6.13 22/24] ASoC: amd: Add DMI quirk for ACP6X mic support Sasha Levin
2025-03-31 14:54 ` [PATCH AUTOSEL 6.13 23/24] ASoC: amd: yc: update quirk data for new Lenovo model Sasha Levin
2025-03-31 14:54 ` [PATCH AUTOSEL 6.13 24/24] platform/x86: x86-android-tablets: Add select POWER_SUPPLY to Kconfig Sasha Levin
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=20250331145404.1705141-9-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=bentiss@kernel.org \
--cc=jikos@kernel.org \
--cc=jkosina@suse.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=michal@nozomi.space \
--cc=paul@spacefreak18.xyz \
--cc=stable@vger.kernel.org \
--cc=tomasz.pakula.oficjalny@gmail.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