Skip to content

Commit 14dcd00

Browse files
committed
Fix Mouse handler moving OS pen cursor
1 parent 29be2c8 commit 14dcd00

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

osu.Framework/Input/Handlers/INeedsMousePositionFeedback.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public interface INeedsMousePositionFeedback
1515
/// </summary>
1616
/// <param name="position">The final mouse position.</param>
1717
/// <param name="isSelfFeedback">Whether the feedback was triggered from this handler.</param>
18-
void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback);
18+
/// <param name="isOsCursor">Whether the position represents OS cursor.</param>
19+
void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor);
1920
}
2021
}

osu.Framework/Input/Handlers/InputHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public abstract class InputHandler : IDisposable, IHasDescription
3232

3333
private bool isInitialized;
3434

35+
public virtual bool IsOsCursor => false;
36+
3537
/// <summary>
3638
/// Used to initialize resources specific to this InputHandler. It gets called once.
3739
/// </summary>

osu.Framework/Input/Handlers/Mouse/MouseHandler.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class MouseHandler : InputHandler, IHasCursorSensitivity, INeedsMousePosi
3737
Precision = 0.01
3838
};
3939

40+
public override bool IsOsCursor => true;
41+
4042
public override string Description => "Mouse";
4143

4244
public override bool IsActive => true;
@@ -137,12 +139,12 @@ public override bool Initialize(GameHost host)
137139
return true;
138140
}
139141

140-
public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback)
142+
public virtual void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor)
141143
{
142144
if (!Enabled.Value)
143145
return;
144146

145-
if (!isSelfFeedback && isActive.Value)
147+
if (!isSelfFeedback && !isOsCursor && isActive.Value)
146148
// if another handler has updated the cursor position, handle updating the OS cursor so we can seamlessly revert
147149
// to mouse control at any point.
148150
window.UpdateMousePosition(position);

osu.Framework/Input/Handlers/Pen/PenHandler.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class PenHandler : InputHandler
1616
{
1717
private static readonly GlobalStatistic<ulong> statistic_total_events = GlobalStatistics.Get<ulong>(StatisticGroupFor<PenHandler>(), "Total events");
1818

19+
public override bool IsOsCursor => true;
20+
1921
public override bool IsActive => true;
2022

2123
public override bool Initialize(GameHost host)

osu.Framework/Input/InputManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ protected virtual void HandleMousePositionChange(MousePositionChangeEvent e)
964964
foreach (var h in InputHandlers)
965965
{
966966
if (h.Enabled.Value && h is INeedsMousePositionFeedback handler)
967-
handler.FeedbackMousePositionChange(mouse.Position, h == mouseSource);
967+
handler.FeedbackMousePositionChange(mouse.Position, h == mouseSource, mouseSource.IsOsCursor);
968968
}
969969

970970
handleMouseMove(state, e.LastPosition);

osu.Framework/Platform/Windows/WindowsMouseHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public override bool Initialize(GameHost host)
3131
return base.Initialize(host);
3232
}
3333

34-
public override void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback)
34+
public override void FeedbackMousePositionChange(Vector2 position, bool isSelfFeedback, bool isOsCursor)
3535
{
3636
window.LastMousePosition = position;
37-
base.FeedbackMousePositionChange(position, isSelfFeedback);
37+
base.FeedbackMousePositionChange(position, isSelfFeedback, isOsCursor);
3838
}
3939
}
4040
}

0 commit comments

Comments
 (0)