/// <summary> /// Get the <see cref="TouchEventManager"/> responsible for a specified touch source. /// </summary> /// <param name="source">The touch source to find the manager for.</param> /// <returns>The <see cref="TouchEventManager"/>.</returns> public TouchEventManager GetButtonEventManagerFor(TouchSource source) { if (touchEventManagers.TryGetValue(source, out var existing)) { return(existing); } var manager = CreateButtonEventManagerFor(source); manager.GetInputQueue = () => buildPositionalInputQueue(CurrentState.Touch.TouchPositions[(int)source]); return(touchEventManagers[source] = manager); }
/// <summary> /// Create a <see cref="TouchEventManager"/> for a specified touch source. /// </summary> /// <param name="source">The touch source to be handled by the returned manager.</param> /// <returns>The <see cref="TouchEventManager"/>.</returns> protected virtual TouchEventManager CreateButtonEventManagerFor(TouchSource source) => new TouchEventManager(source);
private Vector2 getTouchDownPos(TouchSource source) => receptors.ToScreenSpace(new Vector2(getTouchXPos(source), 1f));
private Vector2 getTouchUpPos(TouchSource source) => receptors.ToScreenSpace(new Vector2(getTouchXPos(source), receptors.DrawHeight - 1f));
private float getTouchXPos(TouchSource source) => receptors[(int)source].DrawPosition.X + 10f;
public Touch(TouchSource source, Vector2 position) { Source = source; Position = position; }
/// <summary> /// Whether the provided touch <paramref name="source"/> is active. /// </summary> /// <param name="source">The touch source to check for.</param> public bool IsActive(TouchSource source) => ActiveSources.IsPressed(source);
/// <summary> /// Retrieves the current touch position of a specified <paramref name="source"/>. /// </summary> /// <param name="source">The touch source.</param> /// <returns>The touch position, or null if provided <paramref name="source"/> is not currently active.</returns> public Vector2?GetTouchPosition(TouchSource source) => IsActive(source) ? TouchPositions[(int)source] : (Vector2?)null;
private Color4 colourFor(TouchSource source) { return(Color4.FromHsv(new Vector4((float)source / TouchState.MAX_TOUCH_COUNT, 1f, 1f, 1f))); }