From d79ae73c14b2798b29e71d422f78676b7aff45f4 Mon Sep 17 00:00:00 2001 From: Valeri Date: Wed, 8 Jan 2025 19:09:39 +0300 Subject: [PATCH] Add: 2D map scrolling on win32 (#13172) --- src/video/win32_v.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/video/win32_v.cpp b/src/video/win32_v.cpp index 29a509604f..41402cd1b2 100644 --- a/src/video/win32_v.cpp +++ b/src/video/win32_v.cpp @@ -458,6 +458,8 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) static uint32_t keycode = 0; static bool console = false; + const float SCROLL_BUILTIN_MULTIPLIER = 14.0f / WHEEL_DELTA; + VideoDriver_Win32Base *video_driver = (VideoDriver_Win32Base *)GetWindowLongPtr(hwnd, GWLP_USERDATA); switch (msg) { @@ -768,6 +770,9 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) #if !defined(WM_MOUSEWHEEL) # define WM_MOUSEWHEEL 0x020A #endif /* WM_MOUSEWHEEL */ +#if !defined(WM_MOUSEHWHEEL) +# define WM_MOUSEHWHEEL 0x020E +#endif /* WM_MOUSEHWHEEL */ #if !defined(GET_WHEEL_DELTA_WPARAM) # define GET_WHEEL_DELTA_WPARAM(wparam) ((short)HIWORD(wparam)) #endif /* GET_WHEEL_DELTA_WPARAM */ @@ -780,6 +785,18 @@ LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } else if (delta > 0) { _cursor.wheel--; } + + _cursor.v_wheel -= static_cast(delta) * SCROLL_BUILTIN_MULTIPLIER * _settings_client.gui.scrollwheel_multiplier; + _cursor.wheel_moved = true; + HandleMouseEvents(); + return 0; + } + + case WM_MOUSEHWHEEL: { + int delta = GET_WHEEL_DELTA_WPARAM(wParam); + + _cursor.h_wheel += static_cast(delta) * SCROLL_BUILTIN_MULTIPLIER * _settings_client.gui.scrollwheel_multiplier; + _cursor.wheel_moved = true; HandleMouseEvents(); return 0; }