コード例 #1
0
        /// <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);
        }
コード例 #2
0
 /// <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);
コード例 #3
0
 private Vector2 getTouchDownPos(TouchSource source) => receptors.ToScreenSpace(new Vector2(getTouchXPos(source), 1f));
コード例 #4
0
 private Vector2 getTouchUpPos(TouchSource source) => receptors.ToScreenSpace(new Vector2(getTouchXPos(source), receptors.DrawHeight - 1f));
コード例 #5
0
 private float getTouchXPos(TouchSource source) => receptors[(int)source].DrawPosition.X + 10f;
コード例 #6
0
 public Touch(TouchSource source, Vector2 position)
 {
     Source   = source;
     Position = position;
 }
コード例 #7
0
 /// <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);
コード例 #8
0
 /// <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;
コード例 #9
0
 private Color4 colourFor(TouchSource source)
 {
     return(Color4.FromHsv(new Vector4((float)source / TouchState.MAX_TOUCH_COUNT, 1f, 1f, 1f)));
 }