Skip to content

Commit

Permalink
Don't use case-when
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Apr 15, 2024
1 parent df9c309 commit f791e92
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions osu.Framework/Platform/Windows/WindowsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,18 @@ private SDL_bool handleEventFromHook(MSG msg)

protected override int HandleEventFromFilter(SDL_Event evt)
{
bool rawMouse = SDL3.SDL_GetRelativeMouseMode() == SDL_bool.SDL_TRUE;

switch (evt.type)
{
// handle raw mouse and keyboard events in SDL_EventFilter for lower latency and resilience against SDL_PumpEvents() lag
case SDL_EventType.SDL_EVENT_MOUSE_MOTION when rawMouse:
case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN when rawMouse:
case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP when rawMouse:
case SDL_EventType.SDL_EVENT_MOUSE_WHEEL when rawMouse:
case SDL_EventType.SDL_EVENT_MOUSE_MOTION:
case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN:
case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP:
case SDL_EventType.SDL_EVENT_MOUSE_WHEEL:
if (SDL3.SDL_GetRelativeMouseMode() != SDL_bool.SDL_TRUE) break;

HandleEvent(evt);
return DROP_EVENT;

case SDL_EventType.SDL_EVENT_KEY_DOWN:
case SDL_EventType.SDL_EVENT_KEY_UP:
HandleEvent(evt);
Expand Down

0 comments on commit f791e92

Please sign in to comment.