[win32] Use wheel scroll lines system setting to determine how much to scroll
This commit is contained in:
parent
d01dc832fb
commit
60083c1f2e
|
@ -163,6 +163,10 @@ void mp_init()
|
||||||
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode);
|
SetConsoleMode(GetStdHandle(STD_OUTPUT_HANDLE), mode);
|
||||||
|
|
||||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||||
|
|
||||||
|
u32 wheelScrollLines = 3;
|
||||||
|
SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0);
|
||||||
|
__mpApp.win32.wheelScrollLines = wheelScrollLines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,8 +245,10 @@ static void process_wheel_event(mp_window_data* window, f32 x, f32 y)
|
||||||
mp_event event = {0};
|
mp_event event = {0};
|
||||||
event.window = mp_window_handle_from_ptr(window);
|
event.window = mp_window_handle_from_ptr(window);
|
||||||
event.type = MP_EVENT_MOUSE_WHEEL;
|
event.type = MP_EVENT_MOUSE_WHEEL;
|
||||||
event.mouse.deltaX = x/30.0f;
|
// Borrowed from https://source.chromium.org/chromium/chromium/src/+/3e1a26c44c024d97dc9a4c09bbc6a2365398ca2c:ui/events/blink/web_input_event_builders_win.cc;l=318-330
|
||||||
event.mouse.deltaY = -y/30.0f;
|
f32 scrollMultiplier = __mpApp.win32.wheelScrollLines * 100.0 / 3.0;
|
||||||
|
event.mouse.deltaX = x / WHEEL_DELTA * scrollMultiplier;
|
||||||
|
event.mouse.deltaY = -y / WHEEL_DELTA * scrollMultiplier;
|
||||||
event.mouse.mods = mp_get_mod_keys();
|
event.mouse.mods = mp_get_mod_keys();
|
||||||
|
|
||||||
mp_queue_event(&event);
|
mp_queue_event(&event);
|
||||||
|
@ -500,6 +506,17 @@ LRESULT WinProc(HWND windowHandle, UINT message, WPARAM wParam, LPARAM lParam)
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
case WM_SETTINGCHANGE:
|
||||||
|
{
|
||||||
|
if((u32)wParam == SPI_SETWHEELSCROLLLINES)
|
||||||
|
{
|
||||||
|
u32 wheelScrollLines;
|
||||||
|
if(SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &wheelScrollLines, 0) != 0) {
|
||||||
|
__mpApp.win32.wheelScrollLines = wheelScrollLines;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
|
||||||
case WM_DROPFILES:
|
case WM_DROPFILES:
|
||||||
{
|
{
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
@ -40,6 +40,7 @@ typedef struct win32_app_data
|
||||||
int mouseCaptureMask;
|
int mouseCaptureMask;
|
||||||
bool mouseTracked;
|
bool mouseTracked;
|
||||||
vec2 lastMousePos;
|
vec2 lastMousePos;
|
||||||
|
u32 wheelScrollLines;
|
||||||
|
|
||||||
} win32_app_data;
|
} win32_app_data;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue