diff options
| author | Léo Lam <leo@leolam.fr> | 2021-06-07 12:15:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 12:15:15 +0200 |
| commit | 8ca6ffd908aa95ffb5c7665083463c4ea1139b0d (patch) | |
| tree | 5a058d8aa001d2577f7e65d5aa44ec86737c3386 /Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp | |
| parent | ebe3fbe04c329f9bc100ded4dcf22720f375e2f4 (diff) | |
| parent | 83ea16f40238fa82981221ba65061a7094b2a64b (diff) | |
Merge pull request #9702 from Filoppi/controller_interface_fixes
Controller Interface refactor
Diffstat (limited to 'Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp')
| -rw-r--r-- | Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp index f908181c8d..71d75f786c 100644 --- a/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp +++ b/Source/Core/InputCommon/ControllerInterface/SDL/SDL.cpp @@ -46,7 +46,6 @@ static void OpenAndAddDevice(int index) static Common::Event s_init_event; static Uint32 s_stop_event_type; static Uint32 s_populate_event_type; -static Common::Event s_populated_event; static std::thread s_hotplug_thread; static bool HandleEventAndContinue(const SDL_Event& e) @@ -64,9 +63,10 @@ static bool HandleEventAndContinue(const SDL_Event& e) } else if (e.type == s_populate_event_type) { - for (int i = 0; i < SDL_NumJoysticks(); ++i) - OpenAndAddDevice(i); - s_populated_event.Set(); + g_controller_interface.PlatformPopulateDevices([] { + for (int i = 0; i < SDL_NumJoysticks(); ++i) + OpenAndAddDevice(i); + }); } else if (e.type == s_stop_event_type) { @@ -111,7 +111,8 @@ void Init() // Drain all of the events and add the initial joysticks before returning. Otherwise, the // individual joystick events as well as the custom populate event will be handled _after_ // ControllerInterface::Init/RefreshDevices has cleared its list of devices, resulting in - // duplicate devices. + // duplicate devices. Adding devices will actually "fail" here, as the ControllerInterface + // hasn't finished initializing yet. SDL_Event e; while (SDL_PollEvent(&e) != 0) { @@ -161,8 +162,6 @@ void PopulateDevices() SDL_Event populate_event{s_populate_event_type}; SDL_PushEvent(&populate_event); - - s_populated_event.Wait(); #endif } |
