mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-09 22:18:58 +01:00
ci/sdl: pump messages for SDL_hidapi so device detection works
This commit is contained in:
parent
ddf83462ac
commit
54b4ad8f55
@ -15,6 +15,8 @@
|
|||||||
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
#include "InputCommon/ControllerInterface/ControllerInterface.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
#pragma comment(lib, "SDL2.lib")
|
#pragma comment(lib, "SDL2.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -204,11 +206,34 @@ void Init()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
// This is a hack to workaround SDL_hidapi using window messages to detect device
|
||||||
|
// removal/arrival, yet no part of SDL pumps messages for it. It can hopefully be removed in the
|
||||||
|
// future when SDL fixes the issue. Note this is a separate issue from SDL_HINT_JOYSTICK_THREAD.
|
||||||
|
// Also note that SDL_WaitEvent may block while device detection window messages get queued up,
|
||||||
|
// causing some noticible stutter. This is just another reason it should be fixed properly by
|
||||||
|
// SDL...
|
||||||
|
const auto window_handle =
|
||||||
|
FindWindowEx(HWND_MESSAGE, nullptr, TEXT("SDL_HIDAPI_DEVICE_DETECTION"), nullptr);
|
||||||
|
#endif
|
||||||
|
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
while (SDL_WaitEvent(&e) != 0)
|
while (SDL_WaitEvent(&e) != 0)
|
||||||
{
|
{
|
||||||
if (!HandleEventAndContinue(e))
|
if (!HandleEventAndContinue(e))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
MSG msg;
|
||||||
|
while (window_handle && PeekMessage(&msg, window_handle, 0, 0, PM_NOREMOVE))
|
||||||
|
{
|
||||||
|
if (GetMessageA(&msg, window_handle, 0, 0) != 0)
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessage(&msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user