Commit e916d458 authored by Tomasz Pakuła's avatar Tomasz Pakuła Committed by Greg Kroah-Hartman
Browse files

HID: pidff: Do not send effect envelope if it's empty



[ Upstream commit 8876fc18 ]

Envelope struct is always initialized, but the envelope itself is
optional as described in USB PID Device class definition 1.0.

5.1.1.1 Type Specific Block Offsets
...
4) Effects that do not use Condition Blocks use 1 Parameter Block and
an *optional* Envelope Block.

Sending out "empty" envelope breaks force feedback on some devices with
games that use SINE effect + offset to emulate constant force effect, as
well as generally breaking Constant/Periodic effects. One of the affected
brands is Moza Racing.

This change prevents the envelope from being sent if it contains all
0 values while keeping the old behavior of only sending it, if it differs
from the old one.

Changes in v6:
- Simplify the checks to make them clearer
- Fix possible null pointer dereference while calling
  pidff_needs_set_envelope

Signed-off-by: default avatarTomasz Pakuła <tomasz.pakula.oficjalny@gmail.com>
Reviewed-by: default avatarMichał Kopeć <michal@nozomi.space>
Reviewed-by: default avatarPaul Dino Jones <paul@spacefreak18.xyz>
Tested-by: default avatarPaul Dino Jones <paul@spacefreak18.xyz>
Tested-by: default avatarCristóferson Bueno <cbueno81@gmail.com>
Tested-by: default avatarPablo Cisneros <patchkez@protonmail.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent fbb2f79b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment