From 355bec2058217ae28cc683d2a1edd030dade305e Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 16 Jan 2023 20:11:59 +0900 Subject: [PATCH] Handle movement locally as we are blocking events from touch->mouse mapping --- .../UI/OsuTouchInputMapper.cs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/UI/OsuTouchInputMapper.cs b/osu.Game.Rulesets.Osu/UI/OsuTouchInputMapper.cs index f4ed70f790..a57953f8d3 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuTouchInputMapper.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuTouchInputMapper.cs @@ -6,6 +6,7 @@ using System.Linq; using osu.Framework.Graphics; using osu.Framework.Input; using osu.Framework.Input.Events; +using osu.Framework.Input.StateChanges; namespace osu.Game.Rulesets.Osu.UI { @@ -27,17 +28,24 @@ namespace osu.Game.Rulesets.Osu.UI osuInputManager = inputManager; } - private OsuAction? lastAction; + protected override void OnTouchMove(TouchMoveEvent e) + { + base.OnTouchMove(e); + handleTouchMovement(e); + } protected override bool OnTouchDown(TouchDownEvent e) { - OsuAction action = lastAction == OsuAction.LeftButton && trackedTouches.Count > 0 ? OsuAction.RightButton : OsuAction.LeftButton; + OsuAction action = trackedTouches.Any(t => t.Action == OsuAction.LeftButton) + ? OsuAction.RightButton + : OsuAction.LeftButton; + + handleTouchMovement(e); if (trackedTouches.All(t => t.Action != action)) { trackedTouches.Add(new TrackedTouch(e.Touch, action)); osuInputManager.KeyBindingContainer.TriggerPressed(action); - lastAction = action; } else { @@ -48,6 +56,11 @@ namespace osu.Game.Rulesets.Osu.UI return true; } + private void handleTouchMovement(TouchEvent touchEvent) + { + new MousePositionAbsoluteInput { Position = touchEvent.ScreenSpaceTouch.Position }.Apply(osuInputManager.CurrentState, osuInputManager); + } + protected override void OnTouchUp(TouchUpEvent e) { var tracked = trackedTouches.First(t => t.Touch.Source == e.Touch.Source);