Worked around an issue where the kernel would lose the force feedback effect

This commit is contained in:
Sam Lantinga 2020-01-11 13:38:50 -08:00
parent e3cedf967d
commit c14a59d999
1 changed files with 5 additions and 1 deletions

View File

@ -828,9 +828,13 @@ LINUX_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint1
return SDL_Unsupported(); return SDL_Unsupported();
} }
if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) {
/* The kernel may have lost this effect, try to allocate a new one */
joystick->hwdata->effect.id = -1;
if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) { if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) {
return SDL_SetError("Couldn't update rumble effect: %s", strerror(errno)); return SDL_SetError("Couldn't update rumble effect: %s", strerror(errno));
} }
}
event.type = EV_FF; event.type = EV_FF;
event.code = joystick->hwdata->effect.id; event.code = joystick->hwdata->effect.id;