From e913fbf7e7caa3234df0de282363ee4d6bb727e1 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 30 Jun 2017 21:39:56 +0200 Subject: [PATCH] added hot-plug support for game controllers and joysticks --- src/events.c | 2 ++ src/libgame/sdl.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) 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", -- 2.34.1