-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow invalidating mouse position state
- Loading branch information
1 parent
d0b288d
commit d95cc56
Showing
4 changed files
with
63 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
osu.Framework/Input/StateChanges/MouseInvalidatePositionInput.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Input.StateChanges.Events; | ||
using osu.Framework.Input.States; | ||
|
||
namespace osu.Framework.Input.StateChanges | ||
{ | ||
/// <summary> | ||
/// Denotes an invalidation of the current mouse position, | ||
/// mainly used when a single remaining touch source is released, | ||
/// or a hovering pen (e.g. Apple Pencil) leaves the screen area. | ||
/// </summary> | ||
public class MouseInvalidatePositionInput : IInput | ||
{ | ||
public void Apply(InputState state, IInputStateChangeHandler handler) | ||
{ | ||
var mouse = state.Mouse; | ||
|
||
if (mouse.IsPositionValid) | ||
{ | ||
mouse.IsPositionValid = false; | ||
mouse.LastSource = this; | ||
handler.HandleInputStateChange(new MousePositionChangeEvent(state, this, mouse.Position)); | ||
} | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
osu.Framework/Input/StateChanges/MouseInvalidatePositionInputFromTouch.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using osu.Framework.Input.StateChanges.Events; | ||
|
||
namespace osu.Framework.Input.StateChanges | ||
{ | ||
public class MouseInvalidatePositionInputFromTouch : MouseInvalidatePositionInput, ISourcedFromTouch | ||
{ | ||
public MouseInvalidatePositionInputFromTouch(TouchStateChangeEvent touchEvent) | ||
{ | ||
TouchEvent = touchEvent; | ||
} | ||
|
||
public TouchStateChangeEvent TouchEvent { get; } | ||
} | ||
} |