From: Holger Schemel Date: Fri, 30 Jun 2017 19:39:56 +0000 (+0200) Subject: added hot-plug support for game controllers and joysticks X-Git-Tag: 4.0.1.0~37 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e913fbf7e7caa3234df0de282363ee4d6bb727e1;p=rocksndiamonds.git added hot-plug support for game controllers and joysticks --- diff --git a/src/events.c b/src/events.c index fc34d898..87011a97 100644 --- a/src/events.c +++ b/src/events.c @@ -248,6 +248,8 @@ void HandleOtherEvents(Event *event) #if defined(TARGET_SDL) #if defined(TARGET_SDL2) + case SDL_CONTROLLERDEVICEADDED: + case SDL_CONTROLLERDEVICEREMOVED: case SDL_CONTROLLERAXISMOTION: case SDL_CONTROLLERBUTTONDOWN: case SDL_CONTROLLERBUTTONUP: diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index 5586628b..d6cf2b17 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -2734,6 +2734,22 @@ void HandleJoystickEvent(Event *event) switch(event->type) { #if defined(TARGET_SDL2) + case SDL_CONTROLLERDEVICEADDED: +#if 1 + Error(ERR_DEBUG, "SDL_CONTROLLERDEVICEADDED: device %d added", + event->cdevice.which); +#endif + InitJoysticks(); + break; + + case SDL_CONTROLLERDEVICEREMOVED: +#if 1 + Error(ERR_DEBUG, "SDL_CONTROLLERDEVICEREMOVED: device %d removed", + event->cdevice.which); +#endif + InitJoysticks(); + break; + case SDL_CONTROLLERAXISMOTION: #if 1 Error(ERR_DEBUG, "SDL_CONTROLLERAXISMOTION: device %d, axis %d: %d",