From c52687f0eb586a602e98bd09c604633e275e472c Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Fri, 17 Dec 2021 16:50:32 +0100 Subject: [PATCH] [FIX] If mouse outside window or in border, mouse_x & mouse_y no longer update --- ascii.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ascii.cpp b/ascii.cpp index 05d3ecd..6abb0b9 100644 --- a/ascii.cpp +++ b/ascii.cpp @@ -229,9 +229,12 @@ int main(int argc,char*argv[]) { } } keys = SDL_GetKeyboardState(NULL); - mouse_buttons = SDL_GetMouseState(&mouse_x, &mouse_y); - mouse_x = (mouse_x-40) / (640/screen_width); - mouse_y = (mouse_y-40) / (480/screen_height); + int mx, my; + mouse_buttons = SDL_GetMouseState(&mx, &my); + if (mx>=40 && my>=40 && mx<680 && my<520) { + mouse_x = (mx-40) / (640/screen_width); + mouse_y = (my-40) / (480/screen_height); + } if (lua_is_playing()) { lua_call_update();