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.
This commit is contained in:
David Lawson 2020-12-30 22:07:40 +00:00
parent b0de18ea12
commit 0bdf574cfd

View File

@ -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)
{