diff --git a/joystick/linux/SDL_sysjoystick.c b/joystick/linux/SDL_sysjoystick.c index 4045909..9421ff6 100644 --- a/joystick/linux/SDL_sysjoystick.c +++ b/joystick/linux/SDL_sysjoystick.c @@ -24,6 +24,7 @@ /* This is the system specific header for the SDL joystick API */ +#include #include #include #include @@ -1160,6 +1161,12 @@ EV_HandleEvents(SDL_Joystick * joystick) } } } + if (ENODEV == errno || EBADF == errno) + { + // try reopening: + joystick->hwdata->fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0); + fcntl(joystick->hwdata->fd, F_SETFL, O_NONBLOCK); + } } #endif /* SDL_INPUT_LINUXEV */