// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Extensions.TypeExtensions; using osu.Framework.Input.States; using osuTK; namespace osu.Framework.Input.Events { /// /// Represents a touch event. /// public class TouchEvent : UIEvent { /// /// The touch of this event with the screen space position. /// public readonly Touch ScreenSpaceTouch; /// /// The touch of this event with local space position. /// public Touch Touch => new Touch(ScreenSpaceTouch.Source, ToLocalSpace(ScreenSpaceTouch.Position)); /// /// The touch position at the for this touch source in the screen space. /// public readonly Vector2 ScreenSpaceTouchDownPosition; /// /// The touch position at the for this touch source in local space. /// public Vector2 TouchDownPosition => ToLocalSpace(ScreenSpaceTouchDownPosition); /// /// Whether a touch is active. /// /// The touch to check for. public bool IsActive(Touch touch) => CurrentState.Touch.IsActive(touch.Source); public TouchEvent(InputState state, Touch touch, Vector2? screenSpaceTouchDownPosition = null) : base(state) { ScreenSpaceTouch = touch; ScreenSpaceTouchDownPosition = screenSpaceTouchDownPosition ?? ScreenSpaceTouch.Position; } public override string ToString() => $"{GetType().ReadableName()}({ScreenSpaceTouch.Source})"; } }