From 666e5cf62d7bbcf4b74fc3907dc94db9a5d3c22e Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 23 May 2023 23:32:11 +0300 Subject: [PATCH] Fix mouse events processing See alexbatalov/fallout1-ce#55 --- src/dinput.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/dinput.cc b/src/dinput.cc index 4fae607..a5c1dfc 100644 --- a/src/dinput.cc +++ b/src/dinput.cc @@ -50,6 +50,14 @@ bool mouseDeviceUnacquire() // 0x4E053C bool mouseDeviceGetData(MouseData* mouseState) { + // CE: This function is sometimes called outside loops calling `get_input` + // and subsequently `GNW95_process_message`, so mouse events might not be + // handled by SDL yet. + // + // TODO: Move mouse events processing into `GNW95_process_message` and + // update mouse position manually. + SDL_PumpEvents(); + Uint32 buttons = SDL_GetRelativeMouseState(&(mouseState->x), &(mouseState->y)); mouseState->buttons[0] = (buttons & SDL_BUTTON(SDL_BUTTON_LEFT)) != 0; mouseState->buttons[1] = (buttons & SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0;