From f73bccfec85ba262874831978c203ad54eaa7a82 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 9 Jul 2019 16:38:16 -0400 Subject: [PATCH] Adds a potential workaround for SDL mouse motion. --- OSBindings/SDL/main.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 43a8b80b6..9af82460e 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -736,7 +736,6 @@ int main(int argc, char *argv[]) { case SDL_MOUSEBUTTONUP: { const auto mouse_machine = machine->mouse_machine(); if(mouse_machine) { - printf("%d %s\n", event.button.button, (event.type == SDL_MOUSEBUTTONDOWN) ? "pressed" : "released"); mouse_machine->get_mouse().set_button_pressed( event.button.button % mouse_machine->get_mouse().get_number_of_buttons(), event.type == SDL_MOUSEBUTTONDOWN); @@ -745,7 +744,12 @@ int main(int argc, char *argv[]) { case SDL_MOUSEMOTION: { if(SDL_GetRelativeMouseMode()) { - printf("-> %d %d (%d %d)\n", event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel); + // This is a workaround; using motion.xrel and motion.yrel from the event doesn't + // appear to work consistently. + int xrel, yrel; + SDL_GetRelativeMouseState(&xrel, &yrel); + + printf("-> %d %d (%d %d / %d %d)\n", event.motion.x, event.motion.y, event.motion.xrel, event.motion.yrel, xrel, yrel); const auto mouse_machine = machine->mouse_machine(); if(mouse_machine) { mouse_machine->get_mouse().move(event.motion.xrel, event.motion.yrel);