added mouse wheel support

This commit is contained in:
2026-01-12 21:54:15 +05:00
parent 75d894b1bd
commit 717c049265
8 changed files with 141 additions and 37 deletions

View File

@@ -140,9 +140,16 @@ void tim_read_event(i32 timeout_ms) {
}
case MOUSE_EVENT: {
bool wheel = rec.Event.MouseEvent.dwEventFlags & MOUSE_WHEELED;
if(wheel){
i16 scroll_value = HIWORD(rec.Event.MouseEvent.dwButtonState);
e->type = TimEvent_Mouse;
e->key = scroll_value > 0 ? TimKey_MouseScrollUp : TimKey_MouseScrollDown;
return;
}
bool move = rec.Event.MouseEvent.dwEventFlags & ~DOUBLE_CLICK;
bool left = rec.Event.MouseEvent.dwButtonState &
FROM_LEFT_1ST_BUTTON_PRESSED;
bool left = rec.Event.MouseEvent.dwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED;
if (move || !left) {
// ignore move events and buttons other than left
continue;
@@ -150,8 +157,8 @@ void tim_read_event(i32 timeout_ms) {
tim_update_screen_size(); // workaround, see WINDOW_BUFFER_SIZE_EVENT
e->type = TimEvent_Mouse;
e->key = TimKey_MouseButtonLeft;
e->x = rec.Event.MouseEvent.dwMousePosition.X - tim->window.Left;
e->y = rec.Event.MouseEvent.dwMousePosition.Y - tim->window.Top;
e->x = rec.Event.MouseEvent.dwMousePosition.X - tim->window.Left;
e->y = rec.Event.MouseEvent.dwMousePosition.Y - tim->window.Top;
return;
}