The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] Input: xpad - scale Xbox One rumble to the 0-100 GIP range
@ 2026-11-16 19:53 Elliott Tyson
  0 siblings, 0 replies; only message in thread
From: Elliott Tyson @ 2026-11-16 19:53 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Elliott Tyson, linux-input, linux-kernel, Vicki Pfau, stable

The GIP rumble command takes actuator levels from 0 to 100, but
xpad_play_effect() converts the 16-bit FF_RUMBLE magnitudes by dividing
by 512, which yields levels up to 127.

Not all pads handle out-of-range levels. On a PowerA XBX Spectra
Enhanced Wired Controller (20d6:4002), levels 1 to 100 produce
proportional rumble, 101 produces almost none, and 110 to 127 produce
only weak rumble. Any effect above about 78% of full magnitude,
including full-strength rumble, is therefore barely noticeable on this
pad.

Scale the magnitudes to 0-100 instead. This is the range used by SDL's
HIDAPI Xbox One driver and by the xbox_gip driver currently under
review on linux-input. Intermediate magnitudes now map to
proportionally lower levels than before; for example, half magnitude
sends 50 instead of 64.

The problem was diagnosed and this patch written with the help of an AI
coding assistant (Claude). The submitter tested it on the hardware
above and reviewed the change.

Fixes: 2a6d7527b35c ("Input: xpad - update Xbox One Force Feedback Support")
Cc: stable@vger.kernel.org
Signed-off-by: Elliott Tyson <planetlinux98@gmail.com>
---

Notes:
    Testing:
    - Built as a module against 7.3.4 (Clang, W=1) with no warnings and
      loaded on that kernel. A GCC/allmodconfig build was not done.
    - Hardware: PowerA XBX Spectra Enhanced Wired Controller (20d6:4002).
      FF_RUMBLE effects were uploaded directly with EVIOCSFF. Before the
      patch, full magnitude on both motors barely rumbled and half
      magnitude felt stronger; with the patch, rumble strength increases
      with magnitude all the way to full.
    - Not tested on a Microsoft-made controller or on other architectures.
    
    Behavior change for pads that already worked: below the old maximum,
    the same magnitude now gives a level about 22% lower (half magnitude
    sends 50 instead of 64). If you would rather keep those levels,
    clamping instead (min(strong / 512, 100)) also fixes this pad. I chose
    rescaling to match SDL and xbox_gip.
    
    The pending xbox_gip series (v7, patch 2 "Input: xpad - Remove Xbox One
    support") removes this code. This fix is meant for current and stable
    kernels in the meantime; please drop it if that series lands first.
    
    AI assistance: Claude Code (Claude Opus 5.5) found the cause using
    userspace FF_RUMBLE tests, wrote the code change and the commit
    message, and built the test module. I ran the hardware tests and
    reviewed the change and the description before submitting.

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

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index d2eb48d98fea..6cb3be9845fb 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1606,8 +1606,9 @@ static int xpad_play_effect(struct input_dev *dev, void *data, struct ff_effect
 		packet->data[5] = GIP_MOTOR_ALL;
 		packet->data[6] = 0x00; /* left trigger */
 		packet->data[7] = 0x00; /* right trigger */
-		packet->data[8] = strong / 512;	/* left actuator */
-		packet->data[9] = weak / 512;	/* right actuator */
+		/* GIP actuator levels range from 0 to 100 */
+		packet->data[8] = strong * 100 / 0xffff;	/* left actuator */
+		packet->data[9] = weak * 100 / 0xffff;	/* right actuator */
 		packet->data[10] = 0xFF; /* on period */
 		packet->data[11] = 0x00; /* off period */
 		packet->data[12] = 0xFF; /* repeat count */

base-commit: ab13b5fc808e043a13f861a7c1c2ba8173c22b84
-- 
2.56.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-16 19:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 19:53 [PATCH] Input: xpad - scale Xbox One rumble to the 0-100 GIP range Elliott Tyson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox