diff --git a/osu.Framework/Platform/SDL3/SDL3Window.cs b/osu.Framework/Platform/SDL3/SDL3Window.cs index 1932911681..67f3b5b3ff 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window.cs @@ -287,12 +287,13 @@ protected void RunFrame() /// As per SDL's recommendation, application events should always be handled via the event filter. /// See: https://wiki.libsdl.org/SDL3/SDL_EventType#android_ios_and_winrt_events /// - protected virtual void HandleEventFromFilter(SDL_Event evt) + /// A bool denoting whether to keep the event. false will drop the event. + protected virtual bool HandleEventFromFilter(SDL_Event e) { - switch (evt.Type) + switch (e.Type) { case SDL_EventType.SDL_EVENT_TERMINATING: - handleQuitEvent(evt.quit); + handleQuitEvent(e.quit); break; case SDL_EventType.SDL_EVENT_DID_ENTER_BACKGROUND: @@ -306,7 +307,22 @@ protected virtual void HandleEventFromFilter(SDL_Event evt) case SDL_EventType.SDL_EVENT_LOW_MEMORY: LowOnMemory?.Invoke(); break; + + case SDL_EventType.SDL_EVENT_MOUSE_MOTION: + handleMouseMotionEvent(e.motion); + return false; + + case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN: + case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP: + handleMouseButtonEvent(e.button); + return false; + + case SDL_EventType.SDL_EVENT_MOUSE_WHEEL: + handleMouseWheelEvent(e.wheel); + return false; } + + return true; } protected void HandleEventFromWatch(SDL_Event evt) @@ -327,7 +343,7 @@ private static SDLBool eventFilter(IntPtr userdata, SDL_Event* eventPtr) { var handle = new ObjectHandle(userdata); if (handle.GetTarget(out SDL3Window window)) - window.HandleEventFromFilter(*eventPtr); + return window.HandleEventFromFilter(*eventPtr); return true; } @@ -514,19 +530,6 @@ protected virtual void HandleEvent(SDL_Event e) handleKeymapChangedEvent(); break; - case SDL_EventType.SDL_EVENT_MOUSE_MOTION: - handleMouseMotionEvent(e.motion); - break; - - case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN: - case SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP: - handleMouseButtonEvent(e.button); - break; - - case SDL_EventType.SDL_EVENT_MOUSE_WHEEL: - handleMouseWheelEvent(e.wheel); - break; - case SDL_EventType.SDL_EVENT_JOYSTICK_AXIS_MOTION: handleJoyAxisEvent(e.jaxis); break; diff --git a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs index 4153f78e2e..f98db45358 100644 --- a/osu.Framework/Platform/SDL3/SDL3Window_Input.cs +++ b/osu.Framework/Platform/SDL3/SDL3Window_Input.cs @@ -423,10 +423,17 @@ private void handleMouseWheelEvent(SDL_MouseWheelEvent evtWheel) { bool isPrecise(float f) => f % 1 != 0; + bool precise; + if (isPrecise(evtWheel.x) || isPrecise(evtWheel.y)) + { + precise = true; lastPreciseScroll = evtWheel.timestamp; - - bool precise = evtWheel.timestamp < lastPreciseScroll + precise_scroll_debounce; + } + else + { + precise = evtWheel.timestamp < lastPreciseScroll + precise_scroll_debounce; + } // SDL reports horizontal scroll opposite of what framework expects (in non-"natural" mode, scrolling to the right gives positive deltas while we want negative). TriggerMouseWheel(new Vector2(-evtWheel.x, evtWheel.y), precise); diff --git a/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs b/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs index d04ea28ba1..f46d42c665 100644 --- a/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs +++ b/osu.Framework/Platform/Windows/SDL3WindowsWindow.cs @@ -59,16 +59,16 @@ public override void Create() Native.Input.SetWindowFeedbackSetting(WindowHandle, feedbackType, false); } - protected override void HandleEventFromFilter(SDL_Event evt) + protected override bool HandleEventFromFilter(SDL_Event e) { - switch (evt.Type) + switch (e.Type) { case SDL_EventType.SDL_EVENT_WINDOW_FOCUS_LOST: warpCursorFromFocusLoss(); break; } - base.HandleEventFromFilter(evt); + return base.HandleEventFromFilter(e); } public Vector2? LastMousePosition { get; set; }