Skip to content

Commit

Permalink
Add marker IInputs for tablet pen position & touch
Browse files Browse the repository at this point in the history
These just map to the respective mouse inputs.
  • Loading branch information
Susko3 committed Sep 16, 2024
1 parent dbfb85c commit 6e4a08c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public override bool Initialize(GameHost host)
return true;
}

void IAbsolutePointer.SetPosition(System.Numerics.Vector2 pos) => enqueueInput(new MousePositionAbsoluteInput { Position = new Vector2(pos.X, pos.Y) });
void IAbsolutePointer.SetPosition(System.Numerics.Vector2 pos) => enqueueInput(new TabletPenPositionAbsoluteInput { Position = new Vector2(pos.X, pos.Y) });

void IRelativePointer.SetPosition(System.Numerics.Vector2 delta) => enqueueInput(new MousePositionRelativeInput { Delta = new Vector2(delta.X, delta.Y) });
void IRelativePointer.SetPosition(System.Numerics.Vector2 delta) => enqueueInput(new TabletPenPositionRelativeInput { Delta = new Vector2(delta.X, delta.Y) });

void IPressureHandler.SetPressure(float percentage) => enqueueInput(new MouseButtonInput(osuTK.Input.MouseButton.Left, percentage > 0));
void IPressureHandler.SetPressure(float percentage) => enqueueInput(new TabletPenTouchInput(percentage > 0));

private void handleTabletsChanged(object? sender, IEnumerable<TabletReference> tablets)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

namespace osu.Framework.Input.StateChanges
{
public class TabletPenPositionAbsoluteInput : MousePositionAbsoluteInput;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

namespace osu.Framework.Input.StateChanges
{
public class TabletPenPositionRelativeInput : MousePositionRelativeInput;
}
19 changes: 19 additions & 0 deletions osu.Framework/Input/StateChanges/TabletPenTouchInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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 osuTK.Input;

namespace osu.Framework.Input.StateChanges
{
/// <summary>
/// Denotes a pen touching or lifting from the tablet surface.
/// </summary>
/// <remarks>This currently emulates a left mouse press or release.</remarks>
public class TabletPenTouchInput : MouseButtonInput
{
public TabletPenTouchInput(bool isPressed)
: base(MouseButton.Left, isPressed)
{
}
}
}

0 comments on commit 6e4a08c

Please sign in to comment.