From 0bdf574cfde5506ebf8e143c5ed9b73ad7af6ce6 Mon Sep 17 00:00:00 2001 From: David Lawson Date: Wed, 30 Dec 2020 22:07:40 +0000 Subject: [PATCH] udev_joypad: make rumble work Rumble was not working for me. I learnt a bit about how evdev works and it seems like you need to set a replay which defines how long the effect is (previously we set it to 0). This means there's a maximum length to the rumble effect which feels wrong. When we do `play.value = !!strength;` we're setting the number of times for the effect to repeat, which works fine because the effect stops when we set it to 0. It doesn't feel quite right to me playing e.g. Goldeneye but I've not played on real hardware for a while. I'm hoping someone is more familiar with evdev and can suggest a better approach. --- input/drivers_joypad/udev_joypad.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index fa1a8afea5..4b985f1953 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -386,9 +386,16 @@ static bool udev_set_rumble(unsigned i, { /* Create new or update old playing state. */ struct ff_effect e = {0}; + /* This defines the length of the effect and + the delay before playing it. This means there + is a limit on the maximum vibration time, but + it's hopefully sufficient for most cases. Maybe + there's a better way? */ + struct ff_replay replay = {0xffff, 0}; e.type = FF_RUMBLE; e.id = old_effect; + e.replay = replay; switch (effect) {