From 6d7f899229575b60ea6963244948996d73740889 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Wed, 17 Dec 2025 23:07:35 +0100 Subject: [PATCH] fixed mousewheel in SDL2 --- control.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/control.cpp b/control.cpp index 151f0fb9..51d58b91 100644 --- a/control.cpp +++ b/control.cpp @@ -1431,14 +1431,25 @@ EX void handle_event(SDL_Event& ev) { if(ev.type == SDL_EVENT_MOUSE_BUTTON_DOWN || ev.type == SDL_EVENT_MOUSE_BUTTON_UP SDL12(, || ev.type == SDL_EVENT_MOUSE_WHEEL)) { + + int current_mouse_x = ev.button.x, current_mouse_y = ev.button.y; + + #if SDLVER == 2 + if(ev.type == SDL_EVENT_MOUSE_WHEEL) current_mouse_x = ev.wheel.mouseX, current_mouse_y = ev.wheel.mouseY; + #endif + + #if SDLVER == 3 + if(ev.type == SDL_EVENT_MOUSE_WHEEL) current_mouse_x = ev.wheel.mouse_x, current_mouse_y = ev.wheel.mouse_y; + #endif + #if SDLVER == 1 // ignore the extra event on touchpad if(ev.type == SDL_EVENT_MOUSE_BUTTON_DOWN && ev.button.which == 255) return; #endif - if(ev.button.x != ui_mousex || ev.button.y != ui_mousey) { - mousex = ui_mousex = ev.button.x; - mousey = ui_mousey = ev.button.y; + if(current_mouse_x != ui_mousex || current_mouse_y != ui_mousey) { + mousex = ui_mousex = current_mouse_x; + mousey = ui_mousey = current_mouse_y; fix_mouseh(); just_refreshing = 2; reset_handlers();