[PATCH v3 1/4] input: Add FF_TRIGGER_RUMBLE effect type
Guillaume Casal <[email protected]> Fri, 31 Jul 2026 07:41:56 +0200
| Newsgroups | org.kernel.vger.linux-input,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Some gamepads carry rumble motors behind their triggers, in addition to the ones in the grips that FF_RUMBLE drives: Xbox controllers call them impulse triggers, and handhelds such as the ASUS ROG Xbox Ally X have them too. The force feedback API cannot reach those motors. Add FF_TRIGGER_RUMBLE as a new effect type carrying its own struct ff_trigger_rumble_effect, and move FF_EFFECT_MIN down to it, in the same way FF_HAPTIC was added. v1 took the approach of the 2022 series and added two members to struct ff_rumble_effect instead: https://lore.kernel.org/linux-input/[email protected]/ That is not safe. EVIOCSFF copies the whole struct ff_effect from userspace, and an application that leaves the tail of the union uninitialised, which is common when only strong_magnitude and weak_magnitude are set, would have had that stack content interpreted as trigger magnitudes. Working programs would start buzzing their triggers at random. Keeping the size of the union unchanged makes the ABI compatible in layout, not in meaning. A distinct effect type has no such problem: no existing application ever emits it, so no uninitialised byte can be mistaken for a magnitude. It also removes the need for a separate capability bit, since userspace discovers the type in the EVIOCGBIT(EV_FF) bitmap exactly as it does for FF_RUMBLE. Based on an earlier attempt by Daniel Bomar: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Guillaume Casal <[email protected]> --- diff --git a/include/uapi/linux/input.h b/include/uapi/linux/input.h --- a/include/uapi/linux/input.h +++ b/include/uapi/linux/input.h @@ -448,9 +448,27 @@ }; /** + * struct ff_trigger_rumble_effect - parameters of a trigger rumble effect + * @left_magnitude: magnitude of the motor behind the left trigger + * @right_magnitude: magnitude of the motor behind the right trigger + * + * Some gamepads carry rumble motors behind their triggers, in addition to + * the ones in the grips that FF_RUMBLE drives. Xbox controllers call them + * impulse triggers. + * + * Magnitudes span 0 to 0xffff, as for struct ff_rumble_effect. The effect + * has no direction: each magnitude addresses one fixed actuator. + */ +struct ff_trigger_rumble_effect { + __u16 left_magnitude; + __u16 right_magnitude; +}; + +/** * struct ff_effect - defines force feedback effect * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING, - * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM) + * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_TRIGGER_RUMBLE, FF_INERTIA, or + * FF_CUSTOM) * @id: an unique id assigned to an effect * @direction: direction of the effect * @trigger: trigger conditions (struct ff_trigger) @@ -483,6 +501,7 @@ struct ff_periodic_effect periodic; struct ff_condition_effect condition[2]; /* One for each axis */ struct ff_rumble_effect rumble; + struct ff_trigger_rumble_effect trigger_rumble; struct ff_haptic_effect haptic; } u; }; @@ -491,6 +510,7 @@ * Force feedback effect types */ +#define FF_TRIGGER_RUMBLE 0x4e #define FF_HAPTIC 0x4f #define FF_RUMBLE 0x50 #define FF_PERIODIC 0x51 @@ -501,7 +521,7 @@ #define FF_INERTIA 0x56 #define FF_RAMP 0x57 -#define FF_EFFECT_MIN FF_HAPTIC +#define FF_EFFECT_MIN FF_TRIGGER_RUMBLE #define FF_EFFECT_MAX FF_RAMP /*