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 8C448236458; Mon, 31 Mar 2025 14:55:28 +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=1743432928; cv=none; b=ESaMgcW/1R1aKwI2qOZq61vWPeg0MpoOV+MIpHO6A+p7h6sNICVfLCqILrkq5MMwKIXxrA8No0kEdM31UD+Qxhvk0p0zRAzcNLFZiac+3sXX78Lecw3Ze8UMsjZ6zhkY/NXlbUmOu42ET8MKdWDUcOqv1l7iJNWYHMBCcUpYMgg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1743432928; c=relaxed/simple; bh=LqegsevUlW4Jmv/KWEUBxSOvYZxF2yubkhIEq4rvtbk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=KP1V1+Sx5EHUX7VrcQHf9WlTM+jaCnjMDcqjWTy3fXNKOarJKhJ9G851+SunxMDJSX+HSAn2kPfJ+t0o5uCigMqQ+ouaM2M6+jBs6h9PySgtj2HguCgQ09l+4fQpHUI9unV2tSR4SRycDHxsMWmpVgEKtr1wUSTd3AjybXhQXx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pAixdvle; 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="pAixdvle" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FCDEC4CEE3; Mon, 31 Mar 2025 14:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1743432928; bh=LqegsevUlW4Jmv/KWEUBxSOvYZxF2yubkhIEq4rvtbk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pAixdvleZyodRsZMPnLB+ZzY97twfk0eG23El3kP1EjUwYPSE1FUjZ29bNKH8idyC McnB0K539raEyi9mwOjPjPJ6KDE2l0SYl9dizAnxeMES9mz8hR8EvjHKnGu9xkWlJG e0lz+AK0nzaH3kbdCnIsu6FlQnkakig3y7GFQk/MQOxx77YclG+rTIbPDtgFeI/N7K mVOeRsV2QOH7kLeJ8In2c9Qb6FZfHCc/dyNs7lY5+Abk2Hzd/pgpGMOiUu7Tnguikp myAgJL/fi5TZpsFC+6JuBwmsEe2Iv4bJjft0xF77n6j6uXNZB9jAss+CuAe+5/kUZk wsn2osHcF/i3g== 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.12 09/23] HID: pidff: Add FIX_WHEEL_DIRECTION quirk Date: Mon, 31 Mar 2025 10:54:55 -0400 Message-Id: <20250331145510.1705478-9-sashal@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250331145510.1705478-1-sashal@kernel.org> References: <20250331145510.1705478-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.12.21 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 818e07744c408..c2927e3854a6e 100644 --- a/include/linux/hid.h +++ b/include/linux/hid.h @@ -1233,6 +1233,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