public void Process(ref InputInteractionContext context) { var isActuated = context.ControlIsActuated(pressPointOrDefault); switch (behavior) { case PressBehavior.PressOnly: if (m_WaitingForRelease) { if (!isActuated) { m_WaitingForRelease = false; // We need to reset the action to waiting state in order to stop it from triggering // continuously. However, we do not want to cancel here as that will trigger the action. // So go back directly to waiting here. context.Waiting(); } } else if (isActuated) { ////REVIEW: should this trigger Started? context.PerformedAndGoBackToWaiting(); m_WaitingForRelease = true; } break; case PressBehavior.ReleaseOnly: if (m_WaitingForRelease && !isActuated) { m_WaitingForRelease = false; context.PerformedAndGoBackToWaiting(); } else if (isActuated) { context.Started(); m_WaitingForRelease = true; } break; case PressBehavior.PressAndRelease: if (m_WaitingForRelease) { if (!isActuated) { context.PerformedAndGoBackToWaiting(); } m_WaitingForRelease = isActuated; } else if (isActuated) { context.PerformedAndGoBackToWaiting(); m_WaitingForRelease = true; } break; } }
////TODO: make sure 2d doesn't move too far public void Process(ref InputInteractionContext context) { if (context.timerHasExpired) { context.Canceled(); return; } if (context.isWaiting && context.ControlIsActuated(pressPointOrDefault)) { m_TapStartTime = context.time; // Set timeout slightly after duration so that if tap comes in exactly at the expiration // time, it still counts as a valid tap. context.SetTimeout(durationOrDefault + 0.00001f); context.Started(); return; } if (context.isStarted && !context.ControlIsActuated(pressPointOrDefault)) { if (context.time - m_TapStartTime <= durationOrDefault) { context.PerformedAndGoBackToWaiting(); } else { ////REVIEW: does it matter to cancel right after expiration of 'duration' or is it enough to cancel on button up like here? context.Canceled(); } } }
public void Process(ref InputInteractionContext context) { if (context.timerHasExpired) { if (context.continuous) { context.PerformedAndStayPerformed(); } else { context.PerformedAndGoBackToWaiting(); } return; } switch (context.phase) { case InputActionPhase.Waiting: if (context.ControlIsActuated(pressPointOrDefault)) { m_TimePressed = context.time; context.Started(); context.SetTimeout(durationOrDefault); } break; case InputActionPhase.Started: // If we've reached our hold time threshold, perform the hold. // We do this regardless of what state the control changed to. if (context.time - m_TimePressed >= durationOrDefault) { context.PerformedAndStayPerformed(); } else if (!context.ControlIsActuated()) { // Control is no longer actuated and we haven't performed a hold yet, // so cancel. context.Canceled(); } break; case InputActionPhase.Performed: if (context.ControlIsActuated(pressPointOrDefault)) { if (context.continuous) { context.PerformedAndStayPerformed(); } } else { context.Canceled(); } break; } }
public void Process(ref InputInteractionContext context) { if (context.isWaiting && context.ControlIsActuated(pressPointOrDefault)) { m_SlowTapStartTime = context.time; context.Started(); return; } if (context.isStarted && !context.ControlIsActuated(pressPointOrDefault)) { if (context.time - m_SlowTapStartTime >= durationOrDefault) { context.PerformedAndGoBackToWaiting(); } else { ////REVIEW: does it matter to cancel right after expiration of 'duration' or is it enough to cancel on button up like here? context.Canceled(); } } }
public void Process(ref InputInteractionContext context) { if (context.timerHasExpired) { // We use timers multiple times but no matter what, if they expire it means // that we didn't get input in time. context.Canceled(); return; } switch (m_CurrentTapPhase) { case TapPhase.None: if (context.ControlIsActuated(pressPointOrDefault)) { m_CurrentTapPhase = TapPhase.WaitingForNextRelease; m_CurrentTapStartTime = context.time; context.Started(); context.SetTimeout(tapTimeOrDefault); } break; case TapPhase.WaitingForNextRelease: if (!context.ControlIsActuated(pressPointOrDefault)) { if (context.time - m_CurrentTapStartTime <= tapTimeOrDefault) { ++m_CurrentTapCount; if (m_CurrentTapCount >= tapCount) { context.PerformedAndGoBackToWaiting(); } else { m_CurrentTapPhase = TapPhase.WaitingForNextPress; m_LastTapReleaseTime = context.time; context.SetTimeout(tapDelayOrDefault); } } else { context.Canceled(); } } break; case TapPhase.WaitingForNextPress: if (context.ControlIsActuated(pressPointOrDefault)) { if (context.time - m_LastTapReleaseTime <= tapDelayOrDefault) { m_CurrentTapPhase = TapPhase.WaitingForNextRelease; m_CurrentTapStartTime = context.time; context.SetTimeout(tapTimeOrDefault); } else { context.Canceled(); } } break; } }