linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usbhid: Interpret 0 length ff effects as infinite (0xffff) length effects
@ 2022-10-01 22:16 Paul Dino Jones
  2022-10-02 11:34 ` Anssi Hannula
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Dino Jones @ 2022-10-01 22:16 UTC (permalink / raw)
  To: jikos, anssi.hannula; +Cc: linux-kernel, linux-input, linux-usb

Greetings,

I started using my Accuforce V2 sim wheel on Linux. I was getting no
response from racing simulators through wine, while native linux test
tools worked properly. It appears that many real-world applications will
send 0 as the replay length, which was resulting in the behavior I was
observing (nothing). The PID document does not explicitly state that 0
length effects should be interpreted as infinite, but it does mention
null effects being infinite effects.

This patch will interpret 0 length force feedback effects as 0xffff
(infinite) length effects, leaving other values for replay length
unchanged.

Signed-off-by: Paul Dino Jones <paul@spacefreak18.xyz>
---
 drivers/hid/usbhid/hid-pidff.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/usbhid/hid-pidff.c b/drivers/hid/usbhid/hid-pidff.c
index 3b4ee21cd811..70653451c860 100644
--- a/drivers/hid/usbhid/hid-pidff.c
+++ b/drivers/hid/usbhid/hid-pidff.c
@@ -301,7 +301,7 @@ static void pidff_set_effect_report(struct pidff_device *pidff,
 		pidff->block_load[PID_EFFECT_BLOCK_INDEX].value[0];
 	pidff->set_effect_type->value[0] =
 		pidff->create_new_effect_type->value[0];
-	pidff->set_effect[PID_DURATION].value[0] = effect->replay.length;
+	pidff->set_effect[PID_DURATION].value[0] = effect->replay.length == 0 ? 0xffff : effect->replay.length;
 	pidff->set_effect[PID_TRIGGER_BUTTON].value[0] = effect->trigger.button;
 	pidff->set_effect[PID_TRIGGER_REPEAT_INT].value[0] =
 		effect->trigger.interval;
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-10-05 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-01 22:16 [PATCH] usbhid: Interpret 0 length ff effects as infinite (0xffff) length effects Paul Dino Jones
2022-10-02 11:34 ` Anssi Hannula
2022-10-05 21:30   ` Paul Dino Jones

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).