linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cameron Gutman <aicommander@gmail.com>
To: dmitry.torokhov@gmail.com, rojtberg@gmail.com
Cc: linux-input@vger.kernel.org, Cameron Gutman <aicommander@gmail.com>
Subject: [PATCH v3 2/2] Input: xpad - fix Xbox One rumble stopping after 2.5 secs
Date: Fri, 25 Nov 2016 14:18:35 -0800	[thread overview]
Message-ID: <0c07f12f63b5bf21374eb35a84a160bffc4f97e4.1480111549.git.aicommander@gmail.com> (raw)
In-Reply-To: <cover.1480111549.git.aicommander@gmail.com>
In-Reply-To: <cover.1480111549.git.aicommander@gmail.com>

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 reproducable 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>
---
No changes in v3.

---
 drivers/input/joystick/xpad.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 19886db..6d94996 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1045,9 +1045,9 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
 		packet->data[7] = 0x00;
 		packet->data[8] = strong / 512;	/* left actuator */
 		packet->data[9] = weak / 512;	/* right actuator */
-		packet->data[10] = 0xFF;
-		packet->data[11] = 0x00;
-		packet->data[12] = 0x00;
+		packet->data[10] = 0xFF; /* on period */
+		packet->data[11] = 0x00; /* off period */
+		packet->data[12] = 0xFF; /* repeat count */
 		packet->len = 13;
 		packet->pending = true;
 		break;
-- 
2.9.3


  parent reply	other threads:[~2016-11-25 22:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-25 22:18 [PATCH v3 0/2] Input: xpad - improve support for new Xbox One S pad Cameron Gutman
2016-11-25 22:18 ` [PATCH v3 1/2] Input: xpad - add product ID for " Cameron Gutman
2016-11-28  4:37   ` Dmitry Torokhov
2016-11-25 22:18 ` Cameron Gutman [this message]
2016-11-28  4:38   ` [PATCH v3 2/2] Input: xpad - fix Xbox One rumble stopping after 2.5 secs Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0c07f12f63b5bf21374eb35a84a160bffc4f97e4.1480111549.git.aicommander@gmail.com \
    --to=aicommander@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=rojtberg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).