Input: xpad - fix Xbox One rumble stopping after 2.5 secs
authorCameron Gutman <aicommander@gmail.com>
Mon, 28 Nov 2016 04:37:56 +0000 (20:37 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 1 Dec 2018 08:48:02 +0000 (09:48 +0100)
commit2d92cafaa9c8bf95eca57dae3668c0b2c704bb98
treecf096fadf58f8169e36113a0d983decb25fe9692
parentd4830857bb2233cc44f672119bc5996205aa5513
Input: xpad - fix Xbox One rumble stopping after 2.5 secs

[ Upstream commit ae3b4469dbcd3b842a9fd20940946e4d092d8731 ]

Unlike previous Xbox pads, the Xbox One pad doesn't have "sticky" rumble
packets. The duration is encoded into the command and expiration is handled
by the pad firmware.

ff-memless needs pseudo-sticky behavior for rumble effects to behave
properly for long duration effects. We already specify the maximum rumble
on duration in the command packets, but it's still only good for about 2.5
seconds of rumble. This is easily reproducible running fftest's sine
vibration test.

It turns out there's a repeat count encoded in the rumble command. We can
abuse that to get the pseudo-sticky behavior needed for rumble to behave as
expected for effects with long duration.

By my math, this change should allow a single ff_effect to rumble for 10
minutes straight, which should be more than enough for most needs.

Signed-off-by: Cameron Gutman <aicommander@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/input/joystick/xpad.c