浏览代码

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

Sam Lantinga 5 年之前
父节点
当前提交
c14a59d999
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/joystick/linux/SDL_sysjoystick.c

+ 5 - 1
src/joystick/linux/SDL_sysjoystick.c

@@ -829,7 +829,11 @@ LINUX_JoystickRumble(SDL_Joystick * joystick, Uint16 low_frequency_rumble, Uint1
     }
 
     if (ioctl(joystick->hwdata->fd, EVIOCSFF, &joystick->hwdata->effect) < 0) {
-        return SDL_SetError("Couldn't update rumble effect: %s", strerror(errno));
+        /* 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) {
+            return SDL_SetError("Couldn't update rumble effect: %s", strerror(errno));
+        }
     }
 
     event.type = EV_FF;