mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-11 06:59:07 +01:00
ControllerInterface: make SDL use PlatformPopulateDevices()
and avoid waiting on SDL async population being finished for no reason
This commit is contained in:
parent
1d816f8f26
commit
2aa941081e
@ -46,7 +46,6 @@ static void OpenAndAddDevice(int index)
|
|||||||
static Common::Event s_init_event;
|
static Common::Event s_init_event;
|
||||||
static Uint32 s_stop_event_type;
|
static Uint32 s_stop_event_type;
|
||||||
static Uint32 s_populate_event_type;
|
static Uint32 s_populate_event_type;
|
||||||
static Common::Event s_populated_event;
|
|
||||||
static std::thread s_hotplug_thread;
|
static std::thread s_hotplug_thread;
|
||||||
|
|
||||||
static bool HandleEventAndContinue(const SDL_Event& e)
|
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)
|
else if (e.type == s_populate_event_type)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < SDL_NumJoysticks(); ++i)
|
g_controller_interface.PlatformPopulateDevices([] {
|
||||||
OpenAndAddDevice(i);
|
for (int i = 0; i < SDL_NumJoysticks(); ++i)
|
||||||
s_populated_event.Set();
|
OpenAndAddDevice(i);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (e.type == s_stop_event_type)
|
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
|
// 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_
|
// 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
|
// 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;
|
SDL_Event e;
|
||||||
while (SDL_PollEvent(&e) != 0)
|
while (SDL_PollEvent(&e) != 0)
|
||||||
{
|
{
|
||||||
@ -161,8 +162,6 @@ void PopulateDevices()
|
|||||||
|
|
||||||
SDL_Event populate_event{s_populate_event_type};
|
SDL_Event populate_event{s_populate_event_type};
|
||||||
SDL_PushEvent(&populate_event);
|
SDL_PushEvent(&populate_event);
|
||||||
|
|
||||||
s_populated_event.Wait();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user