void HandleTouchInput() { var touches = m_inputFrame.Touches; var anyTouchesDown = touches.Any(_t => _t.phase == TouchPhase.Began); var anyTouchesUp = touches.Any(_t => _t.phase == TouchPhase.Ended); int index = 0; foreach (var provokingTouch in touches) { var touchEvent = new TouchInputEvent(anyTouchesUp, anyTouchesDown, index++, provokingTouch.fingerId); touchEvent.pointerEvents.AddRange(touches.Select((_t, _i) => new TouchInputPointerEvent { x = _t.position.x, y = _t.position.y, pointerIdentity = _t.fingerId, pointerIndex = _i })); m_inputProcessor.HandleInput(touchEvent); } }
bool HandleTouchInput() { var touchPointerEvents = new List <TouchInputPointerEvent>(m_inputFrame.Touches.Length); bool anyTouchesDown = false; bool anyTouchesUp = false; foreach (var touch in m_inputFrame.Touches) { if (ShouldConsumeTouch(touch.fingerId)) { if (touch.phase == TouchPhase.Began) { anyTouchesDown = true; } else if (touch.phase == TouchPhase.Ended) { anyTouchesUp = true; } touchPointerEvents.Add(new TouchInputPointerEvent { x = TranslateGlobalXToLocalX(touch.position.x), y = TranslateGlobalYToLocalY(touch.position.y), pointerIdentity = touch.fingerId, pointerIndex = touchPointerEvents.Count }); } } int touchEventIndex = 0; foreach (var touchPointerEvent in touchPointerEvents) { var touchEvent = new TouchInputEvent(anyTouchesUp, anyTouchesDown, touchEventIndex, touchPointerEvent.pointerIdentity); touchEvent.pointerEvents = touchPointerEvents; m_touchInputProcessor.HandleInput(touchEvent); ++touchEventIndex; } bool hasProcessedTouches = touchEventIndex > 0; return(hasProcessedTouches); }
bool HandleTouchInput() { var touches = m_inputFrame.Touches; var anyTouchesDown = touches.Any(_t => _t.phase == TouchPhase.Began) && m_inputFrame.ShouldHandleEventsThisFrame; var anyTouchesUp = touches.Any(_t => _t.phase == TouchPhase.Ended); int index = 0; foreach (var provokingTouch in touches) { var touchEvent = new TouchInputEvent(anyTouchesUp, anyTouchesDown, index++, provokingTouch.fingerId); touchEvent.pointerEvents.AddRange(touches.Select((_t, _i) => new TouchInputPointerEvent { x = TranslateGlobalXToLocalX(_t.position.x), y = TranslateGlobalYToLocalY(_t.position.y), pointerIdentity = _t.fingerId, pointerIndex = _i })); m_touchInputProcessor.HandleInput(touchEvent); } return(touches.Length > 0); }
void SendActionToHandler(MouseInputEvent mouseEvent, MouseInputAction action) { mouseEvent.Action = action; m_mouseInputProcessor.HandleInput(mouseEvent); }