Enable dispatching of WM_INPUT events directly, in case the application hasn't created a window with the normal message loop

Sam Lantinga 2020-11-27 10:44:55 -08:00
parent 0252235e82
commit e8adc64810
1 changed files with 18 additions and 1 deletions

View File

@ -640,6 +640,20 @@ RAWINPUT_GetPendingDeviceChanges(void)
}
}
static SDL_bool pump_device_events;
static void
RAWINPUT_GetPendingDeviceEvents(void)
{
if (pump_device_events) {
MSG msg;
while (PeekMessage(&msg, SDL_HelperWindow, WM_INPUT, WM_INPUT + 1, PM_REMOVE)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
pump_device_events = SDL_FALSE;
}
}
static int
RAWINPUT_JoystickInit(void)
{
@ -673,6 +687,7 @@ RAWINPUT_JoystickInit(void)
/* Get initial controller connect messages */
RAWINPUT_GetPendingDeviceChanges();
pump_device_events = SDL_TRUE;
return 0;
}
@ -917,6 +932,8 @@ RAWINPUT_PostUpdate(void)
guide_button_candidate.joystick = NULL;
#endif /* SDL_JOYSTICK_RAWINPUT_MATCHING */
pump_device_events = SDL_TRUE;
}
SDL_bool
@ -1705,7 +1722,7 @@ RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
static void
RAWINPUT_JoystickUpdate(SDL_Joystick *joystick)
{
/* The input events have been handled in the main loop message pumping */
RAWINPUT_GetPendingDeviceEvents();
RAWINPUT_UpdateOtherAPIs(joystick);
}