diff --git a/joystick/linux/SDL_sysjoystick.c b/joystick/linux/SDL_sysjoystick.c index 5960c84..8ed70d0 100644 --- a/joystick/linux/SDL_sysjoystick.c +++ b/joystick/linux/SDL_sysjoystick.c @@ -25,6 +25,7 @@ /* This is the system specific header for the SDL joystick API */ +#include #include #include #include @@ -1133,6 +1134,12 @@ static __inline__ void 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 */