From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94F7222172F; Mon, 31 Mar 2025 14:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743432977; cv=none; b=Ae0SV7F0/dxRt+nCXeptX1gyPaCdbkWo9krPw95du/zXUhypqmlyqI3IUPQDbjt7SexeXYYxtkh0wZtBn0JatLl6N7ATg2gBy5/N5L3DcAd/9JF6YPVum1zfdqe9YPvKxFoVVd1Mg1DxyYeS1DV/SPvISWGNlUIg8L+DymRkEh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743432977; c=relaxed/simple; bh=/e2UTHVch52JG7KUFimu8G4tA/D2XHRltjZWp4s5Fa0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ltPtVNi6vM6LTfr/ZV05MJycqPhfUfEHkzCeDPPA0LEXRfngv4GljvRpzO5FPpjAtzPESJlkSHz71DJ69x9lxE6iaISXWrVm32/YQacfLr1x8F+8sHpBVwrmkrSSm33cUcEqRJmUcy+jOF0i1/UIw6JWt7onYWnU0mwOMQ2vi/E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IriUDnlD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IriUDnlD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4693DC4CEE3; Mon, 31 Mar 2025 14:56:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743432977; bh=/e2UTHVch52JG7KUFimu8G4tA/D2XHRltjZWp4s5Fa0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IriUDnlDRVZXRv1xifjH+l8hxl9YzBMIgxmvu4uCb+9WIjtdHLXtLR1d6XgzhVKbB Cxik1z5CjKTMAyd774cWBuiZixVmS1f2zSNpwi878fuQIJTdJba/CbMMIvU/JZUeBy ci+jBZ8EqjqIhl5Wa2rTIb6zWE1IvXZ9oHWh665VggTH8pZtS0ZEAcsoJioFdkJNFI 2RmA+JZn35FjUDsVdLqxWusi7GKRG2BhTZeqmkaBo4mfjFg1zp4PGbIHqXoTciE9q7 viN1/So4MjtLPSZVrq1mQB9tKlo87ZwM6rbkKk4rE/fjo4F5eL3UgGyNs/KN2try3f mDGcKmfOOlpdg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Tomasz=20Paku=C5=82a?= , =?UTF-8?q?Micha=C5=82=20Kope=C4=87?= , Paul Dino Jones , Jiri Kosina , Sasha Levin , jikos@kernel.org, bentiss@kernel.org, linux-usb@vger.kernel.org, linux-input@vger.kernel.org Subject: [PATCH AUTOSEL 6.6 08/19] HID: pidff: Add FIX_WHEEL_DIRECTION quirk Date: Mon, 31 Mar 2025 10:55:49 -0400 Message-Id: <20250331145601.1705784-8-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250331145601.1705784-1-sashal@kernel.org> References: <20250331145601.1705784-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6.85 Content-Transfer-Encoding: 8bit From: Tomasz Pakuła [ 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 Reviewed-by: Michał Kopeć Reviewed-by: Paul Dino Jones Signed-off-by: Jiri Kosina Signed-off-by: Sasha Levin --- 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 3f776ab47e27d..e3a55fd4e9fc4 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1224,6 +1224,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