private System.Collections.IEnumerator WorkRoutine(float delay) { yield return(WaitForDuration.Seconds(delay, SPTime.Real)); SPInputId positiveBtn = SPInputId.Unknown; UnityEngine.KeyCode positiveKey = UnityEngine.KeyCode.None; float t = float.NegativeInfinity; while (_state == State.Running) { if (UnityEngine.Input.GetKeyDown(this.CancelKey)) { this.Cancel(); yield break; } if (this.CancelDelegate != null && this.CancelDelegate()) { this.Cancel(); yield break; } if (this.CustomPollingCallback != null) { InputToken token; if (this.CustomPollingCallback(this, out token)) { this.InputResult = token; goto Complete; } } if (this.PollFromStandardSPInputs) { if (this.PollJoyAxes || this.PollMouseAxes) { SPInputId axis; float value; if (SPInputDirect.TryPollAxis(out axis, out value, this.Joystick, this.PollMouseAxes, this.AxisPollingDeadZone) && TestConsideration(value, this.AxisConsideration, this.AxisPollingDeadZone)) { if ((this.PollJoyAxes && axis.IsJoyAxis()) || (this.PollMouseAxes && axis.IsMouseAxis())) { if (this.PollAsTrigger) { this.InputResult = InputToken.CreateTrigger(axis); } else { this.InputResult = InputToken.CreateAxis(axis, value < 0f); } goto Complete; } } } if (this.PollButtons) { SPInputId btn; if (SPInputDirect.TryPollButton(out btn, this.ButtonPollingState, this.Joystick)) { if (this.PollAsTrigger) { this.InputResult = InputToken.CreateTrigger(btn, AxleValueConsideration.Positive); goto Complete; } if (positiveBtn != SPInputId.Unknown) { this.InputResult = InputToken.CreateEmulatedAxis(positiveBtn, btn); goto Complete; } else { positiveKey = UnityEngine.KeyCode.None; positiveBtn = btn; t = UnityEngine.Time.realtimeSinceStartup; goto Restart; } } } } if (this.PollKeyboard) { UnityEngine.KeyCode key; if (SPInputDirect.TryPollKey(out key, this.ButtonPollingState)) { if (this.PollAsTrigger) { this.InputResult = InputToken.CreateTrigger(key); goto Complete; } if (positiveKey != UnityEngine.KeyCode.None) { this.InputResult = InputToken.CreateEmulatedAxis(positiveKey, key); goto Complete; } else { positiveBtn = SPInputId.Unknown; positiveKey = key; t = UnityEngine.Time.realtimeSinceStartup; goto Restart; } } } Restart: yield return(null); if (UnityEngine.Time.realtimeSinceStartup - t > this.ButtonPressMonitorDuration) { positiveBtn = SPInputId.Unknown; positiveKey = UnityEngine.KeyCode.None; } } Complete: _state = State.Complete; _routine = null; this.SignalOnComplete(); }
public void RegisterMouseAxis(TInputId axis, SPMouseId spaxis) { _axisTable[axis] = InputToken.CreateAxis(spaxis.ToSPInputId()); _buttonTable.Remove(axis); }