/// <inheritdoc /> 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(); var maxTapTime = tapTimeOrDefault; var maxDelayInBetween = tapDelayOrDefault; context.SetTimeout(maxTapTime); // We'll be using multiple timeouts so set a total completion time that // effects the result of InputAction.GetTimeoutCompletionPercentage() // such that it accounts for the total time we allocate for the interaction // rather than only the time of one single timeout. context.SetTotalTimeoutCompletionTime(maxTapTime * tapCount + (tapCount - 1) * maxDelayInBetween); } break; case TapPhase.WaitingForNextRelease: if (!context.ControlIsActuated(releasePointOrDefault)) { if (context.time - m_CurrentTapStartTime <= tapTimeOrDefault) { ++m_CurrentTapCount; if (m_CurrentTapCount >= tapCount) { context.Performed(); } 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; } }