diff --git a/source/build/include/baselayer.h b/source/build/include/baselayer.h index 638befe78..2d0da3fbd 100644 --- a/source/build/include/baselayer.h +++ b/source/build/include/baselayer.h @@ -222,9 +222,8 @@ int32_t handleevents_peekkeys(void); extern void (*keypresscallback)(int32_t,int32_t); extern void (*g_mouseCallback)(int32_t,int32_t); -extern void (*g_controllerHotplugCallback)(void); -int32_t initinput(void(*hotplugCallback)(void) = NULL); +int32_t initinput(void); void uninitinput(void); void keySetCallback(void (*callback)(int32_t,int32_t)); void mouseSetCallback(void (*callback)(int32_t,int32_t)); diff --git a/source/build/src/baselayer.cpp b/source/build/src/baselayer.cpp index e98d20bd5..760364c73 100644 --- a/source/build/src/baselayer.cpp +++ b/source/build/src/baselayer.cpp @@ -102,8 +102,6 @@ bool g_mouseLockedToWindow = 1; void (*g_mouseCallback)(int32_t, int32_t); void mouseSetCallback(void(*callback)(int32_t, int32_t)) { g_mouseCallback = callback; } -void (*g_controllerHotplugCallback)(void); - int32_t mouseAdvanceClickState(void) { switch (g_mouseClickState) diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index 59e27fe7c..47c09c113 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -825,8 +825,6 @@ static void LoadSDLControllerDB() } #endif -static int numjoysticks; - void joyScanDevices() { inputdevices &= ~4; @@ -842,8 +840,7 @@ void joyScanDevices() joydev = nullptr; } - numjoysticks = SDL_NumJoysticks(); - + int numjoysticks = SDL_NumJoysticks(); if (numjoysticks < 1) { buildputs("No game controllers found\n"); @@ -928,20 +925,10 @@ void joyScanDevices() // // initinput() -- init input system // -int32_t initinput(void(*hotplugCallback)(void) /*= NULL*/) +int32_t initinput(void) { int32_t i; -#if SDL_MAJOR_VERSION >= 2 - if (hotplugCallback) - { - g_controllerHotplugCallback = hotplugCallback; - SDL_JoystickEventState(SDL_ENABLE); - } -#else - UNREFERENCED_PARAMETER(hotplugCallback); -#endif - #ifdef _WIN32 Win_GetOriginalLayoutName(); Win_SetKeyboardLayoutUS(1); @@ -987,6 +974,7 @@ int32_t initinput(void(*hotplugCallback)(void) /*= NULL*/) #if SDL_MAJOR_VERSION >= 2 LoadSDLControllerDB(); #endif + joyScanDevices(); } @@ -2111,13 +2099,7 @@ int32_t handleevents_sdlcommon(SDL_Event *ev) break; # endif #endif -#if SDL_MAJOR_VERSION >= 2 - case SDL_CONTROLLERDEVICEADDED: - case SDL_CONTROLLERDEVICEREMOVED: - if (g_controllerHotplugCallback && SDL_NumJoysticks() != numjoysticks) - g_controllerHotplugCallback(); - break; -#endif + case SDL_JOYAXISMOTION: #if SDL_MAJOR_VERSION >= 2 if (joystick.isGameController) @@ -2205,9 +2187,6 @@ int32_t handleevents_pollsdl(void) int32_t code, rv=0, j; SDL_Event ev; - if (g_controllerHotplugCallback && SDL_NumJoysticks() != numjoysticks) - g_controllerHotplugCallback(); - while (SDL_PollEvent(&ev)) { switch (ev.type) diff --git a/source/build/src/winlayer.cpp b/source/build/src/winlayer.cpp index 962fbffd6..074e66061 100644 --- a/source/build/src/winlayer.cpp +++ b/source/build/src/winlayer.cpp @@ -683,7 +683,7 @@ int32_t handleevents(void) // // initinput() -- init input system // -int32_t initinput(void(*hotplugCallback)(void) /*= NULL*/) +int32_t initinput(void) { Win_GetOriginalLayoutName(); Win_SetKeyboardLayoutUS(1); diff --git a/source/mact/src/control.cpp b/source/mact/src/control.cpp index f1fc11ef5..9abcd6281 100644 --- a/source/mact/src/control.cpp +++ b/source/mact/src/control.cpp @@ -955,7 +955,7 @@ bool CONTROL_Startup(controltype which, int32_t(*TimeFunction)(void), int32_t ti if (CONTROL_DoubleClickSpeed <= 0) CONTROL_DoubleClickSpeed = 1; - if (initinput(CONTROL_ScanForControllers)) + if (initinput()) return true; KB_Startup();