[PATCH RESEND] Interpret 0 length ff effects as infinite (0xffff) length effects

Paul Dino Jones posted 1 patch 1 year, 8 months ago
drivers/hid/usbhid/hid-pidff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH RESEND] Interpret 0 length ff effects as infinite (0xffff) length effects
Posted by Paul Dino Jones 1 year, 8 months ago
Greetings,

More and more vendors are entering the force feedback wheel space, and
many are supported well by this driver. Unfortunately a lot of new users
are hitting this issue.

It would be nice to have this merged.

I think we all agree a 0 length effect makes no sense, and this change
wouldn't break anything that sends 0xffff.

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
Re: [PATCH RESEND] Interpret 0 length ff effects as infinite (0xffff) length effects
Posted by Jiri Kosina 1 year, 8 months ago
On Tue, 21 May 2024, Paul Dino Jones wrote:

> Greetings,
> 
> More and more vendors are entering the force feedback wheel space, and
> many are supported well by this driver. Unfortunately a lot of new users
> are hitting this issue.
> 
> It would be nice to have this merged.
> 
> I think we all agree a 0 length effect makes no sense, and this change
> wouldn't break anything that sends 0xffff.

Could you please make the changelog a little bit more structured, namely 
what is the user-visible problem this patch is fixing, and how / why it is 
a proper fix.

Thanks,

-- 
Jiri Kosina
SUSE Labs
Re: [PATCH RESEND] Interpret 0 length ff effects as infinite (0xffff) length effects
Posted by Paul Dino Jones 1 year, 7 months ago
Hello, thank you for getting back to me.

It doesn't make sense to have a force feedback effect with zero
duration.

Many if not all existing wheels, interpret this as an infinite duration
effect, and existing software operates under the same assumption.

Interpreting 0 as 0, is causing many wheels to appear to not function at
all using certain software under linux.

- Paul
Re: [PATCH RESEND] Interpret 0 length ff effects as infinite (0xffff) length effects
Posted by Paul Dino Jones 1 year, 7 months ago
Hello, and thank you for getting back to me.

Without this, a lot of wheels do not work with proton and wine and other
software.

A lot of the community is already using this patch or other similar
workarounds.

I can't think of a situation where sending an effect of length zero
would ever make sense.

If you read through the first time I sent this patch you will see a lot
of the research that went into this.

https://lkml.indiana.edu/hypermail/linux/kernel/2210.0/04133.html

- Paul