added hot-plug support for game controllers and joysticks
authorHolger Schemel <info@artsoft.org>
Fri, 30 Jun 2017 19:39:56 +0000 (21:39 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 30 Jun 2017 19:39:56 +0000 (21:39 +0200)
src/events.c
src/libgame/sdl.c

index fc34d89..87011a9 100644 (file)
@@ -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:
index 5586628..d6cf2b1 100644 (file)
@@ -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",