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 fc34d8981bc8dbc41583dd751573be706c60a330..87011a9732167f4aafd2c45b73f4d1e61b6e9a96 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 5586628b40dabf1385a5ae09472828f079e5501b..d6cf2b1779082a6a5b9d418273fe95c91add3ca7 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",