1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:52:55 +08:00

Handle movement locally as we are blocking events from touch->mouse mapping

This commit is contained in:
Dean Herbert 2023-01-16 20:11:59 +09:00
parent b265888f18
commit 355bec2058

View File

@ -6,6 +6,7 @@ using System.Linq;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Input.StateChanges;
namespace osu.Game.Rulesets.Osu.UI namespace osu.Game.Rulesets.Osu.UI
{ {
@ -27,17 +28,24 @@ namespace osu.Game.Rulesets.Osu.UI
osuInputManager = inputManager; osuInputManager = inputManager;
} }
private OsuAction? lastAction; protected override void OnTouchMove(TouchMoveEvent e)
{
base.OnTouchMove(e);
handleTouchMovement(e);
}
protected override bool OnTouchDown(TouchDownEvent 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)) if (trackedTouches.All(t => t.Action != action))
{ {
trackedTouches.Add(new TrackedTouch(e.Touch, action)); trackedTouches.Add(new TrackedTouch(e.Touch, action));
osuInputManager.KeyBindingContainer.TriggerPressed(action); osuInputManager.KeyBindingContainer.TriggerPressed(action);
lastAction = action;
} }
else else
{ {
@ -48,6 +56,11 @@ namespace osu.Game.Rulesets.Osu.UI
return true; return true;
} }
private void handleTouchMovement(TouchEvent touchEvent)
{
new MousePositionAbsoluteInput { Position = touchEvent.ScreenSpaceTouch.Position }.Apply(osuInputManager.CurrentState, osuInputManager);
}
protected override void OnTouchUp(TouchUpEvent e) protected override void OnTouchUp(TouchUpEvent e)
{ {
var tracked = trackedTouches.First(t => t.Touch.Source == e.Touch.Source); var tracked = trackedTouches.First(t => t.Touch.Source == e.Touch.Source);