public AxisDelegate CreateAxisDelegate(Joystick joystick = Joystick.All) { switch (this.Type) { case InputType.Unknown: return(null); case InputType.Joystick: { switch (this.Mode) { case InputMode.Axis: { if (float.IsNaN(this.DeadZone)) { return(SPInputFactory.CreateAxisDelegate((SPInputId)this.Value, (SPInputId)this.AltValue, joystick)); } else { return(SPInputFactory.CreateAxisDelegate((SPInputId)this.Value, joystick, this.AltValue != 0)); } } case InputMode.Trigger: return(SPInputFactory.CreateTriggerDelegate((SPInputId)this.Value, joystick, (AxleValueConsideration)this.AltValue)); case InputMode.LongTrigger: return(SPInputFactory.CreateLongTriggerDelegate((SPInputId)this.Value, joystick)); case InputMode.Button: return(SPInputFactory.CreateTriggerDelegate(SPInputFactory.CreateButtonDelegate((SPInputId)this.Value, joystick))); case InputMode.AxleButton: return(SPInputFactory.CreateTriggerDelegate(SPInputFactory.CreateAxleButtonDelegate((SPInputId)this.Value, (AxleValueConsideration)this.AltValue, joystick, this.DeadZone))); } } break; case InputType.Keyboard: { switch (this.Mode) { case InputMode.Axis: return(SPInputFactory.CreateAxisDelegate((KeyCode)this.Value, (KeyCode)this.AltValue)); case InputMode.Trigger: case InputMode.LongTrigger: case InputMode.Button: case InputMode.AxleButton: return(SPInputFactory.CreateTriggerDelegate((KeyCode)this.Value)); } } break; case InputType.Custom: { if (_axisDelegate is AxisDelegateFactory) { return((_axisDelegate as AxisDelegateFactory)(joystick)); } else if (_axisDelegate is AxisDelegate) { return(_axisDelegate as AxisDelegate); } else if (_buttonDelegate is ButtonDelegateFactory) { return(SPInputFactory.CreateTriggerDelegate((_buttonDelegate as ButtonDelegateFactory)(joystick))); } else if (_buttonDelegate is ButtonDelegate) { return(SPInputFactory.CreateTriggerDelegate(_buttonDelegate as ButtonDelegate)); } else { return(null); } } } return(null); }
public ButtonDelegate CreateButtonDelegate(Joystick joystick = Joystick.All) { switch (this.Type) { case InputType.Unknown: return(null); case InputType.Joystick: { switch (this.Mode) { case InputMode.Axis: return(SPInputFactory.CreateAxleButtonDelegate((SPInputId)this.Value, AxleValueConsideration.Absolute, joystick)); case InputMode.Trigger: return(SPInputFactory.CreateAxleButtonDelegate((SPInputId)this.Value, (AxleValueConsideration)this.AltValue, joystick)); case InputMode.LongTrigger: return(SPInputFactory.CreateAxleButtonDelegate(SPInputFactory.CreateLongTriggerDelegate((SPInputId)this.Value, joystick), AxleValueConsideration.Positive)); case InputMode.Button: return(SPInputFactory.CreateButtonDelegate((SPInputId)this.Value, joystick)); case InputMode.AxleButton: return(SPInputFactory.CreateAxleButtonDelegate((SPInputId)this.Value, (AxleValueConsideration)this.AltValue, joystick, this.DeadZone)); } } break; case InputType.Keyboard: { switch (this.Mode) { case InputMode.Axis: { KeyCode p = (KeyCode)Value; KeyCode n = (KeyCode)AltValue; return(() => Input.GetKey(p) || Input.GetKey(n)); } case InputMode.Trigger: case InputMode.LongTrigger: case InputMode.Button: case InputMode.AxleButton: return(SPInputFactory.CreateButtonDelegate((KeyCode)this.Value)); } } break; case InputType.Custom: { if (_buttonDelegate is ButtonDelegateFactory) { return((_buttonDelegate as ButtonDelegateFactory)(joystick)); } else if (_buttonDelegate is ButtonDelegate) { return(_buttonDelegate as ButtonDelegate); } else if (_axisDelegate is AxisDelegateFactory) { return(SPInputFactory.CreateAxleButtonDelegate((_axisDelegate as AxisDelegateFactory)(joystick), AxleValueConsideration.Absolute)); } else if (_axisDelegate is AxisDelegate) { return(SPInputFactory.CreateAxleButtonDelegate(_axisDelegate as AxisDelegate, AxleValueConsideration.Absolute)); } else { return(null); } } } return(null); }