diff --git a/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs b/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs index d98eaf1bea..3eaba25347 100644 --- a/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs +++ b/osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs @@ -15,6 +15,7 @@ public interface INeedsMousePositionFeedback /// /// The final mouse position. /// Whether the feedback was triggered from this handler. - void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback); + /// Whether the position represents OS cursor. + void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor); } } diff --git a/osu.Framework/Input/Handlers/InputHandler.cs b/osu.Framework/Input/Handlers/InputHandler.cs index 752d6cb776..1b98e3005e 100644 --- a/osu.Framework/Input/Handlers/InputHandler.cs +++ b/osu.Framework/Input/Handlers/InputHandler.cs @@ -32,6 +32,8 @@ public abstract class InputHandler : IDisposable, IHasDescription private bool isInitialized; + public virtual bool IsOsCursor => false; + /// /// Used to initialize resources specific to this InputHandler. It gets called once. /// diff --git a/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs b/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs index aa480152c3..3f496ccf2d 100644 --- a/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs +++ b/osu.Framework/Input/Handlers/Mouse/MouseHandler.cs @@ -37,6 +37,8 @@ public class MouseHandler : InputHandler, IHasCursorSensitivity, INeedsMousePosi Precision = 0.01 }; + public override bool IsOsCursor => true; + public override string Description => "Mouse"; public override bool IsActive => true; @@ -137,12 +139,12 @@ public override bool Initialize(GameHost host) return true; } - public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback) + public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor) { if (!Enabled.Value) return; - if (!isSelfFeedback && isActive.Value) + if (!isSelfFeedback && !isOsCursor && isActive.Value) // if another handler has updated the cursor position, handle updating the OS cursor so we can seamlessly revert // to mouse control at any point. window.UpdateMousePosition(position); diff --git a/osu.Framework/Input/Handlers/Pen/PenHandler.cs b/osu.Framework/Input/Handlers/Pen/PenHandler.cs index 09df050a1c..c44ea9013c 100644 --- a/osu.Framework/Input/Handlers/Pen/PenHandler.cs +++ b/osu.Framework/Input/Handlers/Pen/PenHandler.cs @@ -16,6 +16,8 @@ public class PenHandler : InputHandler { private static readonly GlobalStatistic statistic_total_events = GlobalStatistics.Get(StatisticGroupFor(), "Total events"); + public override bool IsOsCursor => true; + public override bool IsActive => true; public override bool Initialize(GameHost host) diff --git a/osu.Framework/Input/InputManager.cs b/osu.Framework/Input/InputManager.cs index 87efb4345b..dd89c65cca 100644 --- a/osu.Framework/Input/InputManager.cs +++ b/osu.Framework/Input/InputManager.cs @@ -964,7 +964,7 @@ protected virtual void HandleMousePositionChange(MousePositionChangeEvent e) foreach (var h in InputHandlers) { if (h.Enabled.Value && h is INeedsMousePositionFeedback handler) - handler.FeedbackMousePositionChange(mouse.Position, h == mouseSource); + handler.FeedbackMousePositionChange(mouse.Position, h == mouseSource, mouseSource.IsOsCursor); } handleMouseMove(state, e.LastPosition); diff --git a/osu.Framework/Platform/Windows/WindowsMouseHandler.cs b/osu.Framework/Platform/Windows/WindowsMouseHandler.cs index 4abe150a6e..c1fe7d6ccd 100644 --- a/osu.Framework/Platform/Windows/WindowsMouseHandler.cs +++ b/osu.Framework/Platform/Windows/WindowsMouseHandler.cs @@ -31,10 +31,10 @@ public override bool Initialize(GameHost host) return base.Initialize(host); } - public override void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback) + public override void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor) { window.LastMousePosition = position; - base.FeedbackMousePositionChange(position, isSelfFeedback); + base.FeedbackMousePositionChange(position, isSelfFeedback, isOsCursor); } } }