public static InputToken MergeAsButton(this InputToken t1, InputToken t2) { return(InputToken.CreateCustom((j) => t1.CreateButtonDelegate(j).Merge(t2.CreateButtonDelegate(j)))); }
private System.Collections.IEnumerator WorkRoutine(float delay) { yield return(WaitForDuration.Seconds(delay, SPTime.Real)); 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 t; if (this.CustomPollingCallback(this, out t)) { this.InputResult = t; goto Complete; } } if (this.PollFromStandardSPInputs) { if (this.PollButtons) { SPInputId btn; if (SPInputDirect.TryPollButton(out btn, this.ButtonPollingState, this.Joystick)) { this.InputResult = InputToken.CreateButton(btn); goto Complete; } } 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())) { this.InputResult = InputToken.CreateAxleButton(axis, this.AxisConsideration, this.AxisPollingDeadZone); goto Complete; } } } } if (this.PollKeyboard) { UnityEngine.KeyCode key; if (SPInputDirect.TryPollKey(out key, this.ButtonPollingState)) { this.InputResult = InputToken.CreateButton(key); goto Complete; } } yield return(null); } Complete: _state = State.Complete; _routine = null; this.SignalOnComplete(); }
public bool TryGetButtonMapping(TInputId button, out InputToken map) { return(_buttonTable.TryGetValue(button, out map)); }
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 RegisterButton(TInputId button, InputToken token) { _buttonTable[button] = token; _axisTable.Remove(button); }
public bool TryGetAxisMapping(TInputId axis, out InputToken map) { return(_axisTable.TryGetValue(axis, out map)); }
public void RegisterButton(TInputId button, KeyCode key) { _buttonTable[button] = InputToken.CreateButton(key); _axisTable.Remove(button); }
public void RegisterMouseButton(TInputId button, SPMouseId spbtn) { _buttonTable[button] = InputToken.CreateButton(spbtn.ToSPInputId()); _axisTable.Remove(button); }
public void RegisterMouseAxis(TInputId axis, SPMouseId spaxis) { _axisTable[axis] = InputToken.CreateAxis(spaxis.ToSPInputId()); _buttonTable.Remove(axis); }
public void RegisterAxis(TInputId axis, InputToken token) { _axisTable[axis] = token; _buttonTable.Remove(axis); }
public void RegisterAxis(TInputId axis, KeyCode positive, KeyCode negative) { _axisTable[axis] = InputToken.CreateEmulatedAxis(positive, negative); _buttonTable.Remove(axis); }
void IConfigurableInputProfile <TInputId> .SetButtonMapping(TInputId id, InputToken token) { this.RegisterButton(id, token); }
void IConfigurableInputProfile <TInputId> .SetAxisMapping(TInputId id, InputToken token) { this.RegisterAxis(id, token); }
public void SetButtonMapping(TInputId id, InputToken token) { _customTable[id] = token; }
public InputTokenKeyValuePair(TInputId id, InputToken token) { this.InputId = id; this.InputToken = token; }