public static AxisDelegateFactory CreateTriggerDelegateFactory(SPInputId axis, AxleValueConsideration axisConsideration = AxleValueConsideration.Positive) { return((j) => CreateTriggerDelegate(axis, j, axisConsideration)); }
/* * Triggers */ public static AxisDelegate CreateTriggerDelegate(SPInputId axis, Joystick joystick = Joystick.All, AxleValueConsideration axisConsideration = AxleValueConsideration.Positive) { var inputId = SPInputDirect.GetInputName(axis, joystick); if (axis.IsAxis()) { switch (axisConsideration) { case AxleValueConsideration.Positive: return(() => UnityEngine.Mathf.Clamp01(UnityEngine.Input.GetAxisRaw(inputId))); case AxleValueConsideration.Negative: return(() => - UnityEngine.Mathf.Clamp(UnityEngine.Input.GetAxisRaw(inputId), -1f, 0f)); case AxleValueConsideration.Absolute: return(() => Math.Abs(UnityEngine.Input.GetAxisRaw(inputId))); default: return(null); } } else { return(() => UnityEngine.Input.GetButton(inputId) ? 1f : 0f); } }
public static ButtonDelegateFactory CreateAxleButtonDelegateFactory(SPInputId axis, AxleValueConsideration consideration, float axleButtonDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) { return((j) => { return CreateAxleButtonDelegate(axis, consideration, j, axleButtonDeadZone); }); }
public static ButtonDelegate CreateAxleButtonDelegate <TInputId>(this IEnumerable <IInputProfile <TInputId> > profiles, TInputId axis, AxleValueConsideration consideration = AxleValueConsideration.Positive, Joystick joystick = Joystick.All, Comparison <IInputProfile <TInputId> > comparison = null, float axleButtonDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) where TInputId : struct, System.IConvertible { using (var lst = TempCollection.GetList <IInputProfile <TInputId> >(from p in profiles where p != null select p)) { if (comparison != null) { lst.Sort(comparison); } if (lst.Count == 0) { return(null); } if (lst.Count == 1) { return(CreateAxleButtonDelegate(lst[0].GetMapping(axis).CreateAxisDelegate(joystick), consideration, axleButtonDeadZone)); } if (lst.Count == 2) { return(CreateAxleButtonDelegate(lst[0].GetMapping(axis).CreateAxisDelegate(joystick), consideration, axleButtonDeadZone).Merge( CreateAxleButtonDelegate(lst[1].GetMapping(axis).CreateAxisDelegate(joystick), consideration, axleButtonDeadZone))); } var arr = (from p in lst select CreateAxleButtonDelegate(p.GetMapping(axis).CreateAxisDelegate(joystick), consideration, axleButtonDeadZone)).ToArray(); return(Merge(arr)); } }
public static IButtonInputSignature CreateAxleButtonSignature <TInputId>(this IEnumerable <IInputProfile <TInputId> > profiles, string id, TInputId axis, AxleValueConsideration consideration = AxleValueConsideration.Positive, Joystick joystick = Joystick.All, Comparison <IInputProfile <TInputId> > comparison = null, float axleButtonDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) where TInputId : struct, System.IConvertible { return(new DelegatedAxleButtonInputSignature(id, CreateAxisDelegate(profiles, axis, joystick, comparison), consideration, axleButtonDeadZone)); }
public static IButtonInputSignature CreateAxleButtonSignature <TInputId>(this IInputProfile <TInputId> profile, string id, TInputId axis, AxleValueConsideration consideration = AxleValueConsideration.Positive, Joystick joystick = Joystick.All, float axleButtonDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) where TInputId : struct, System.IConvertible { if (profile == null) { return(null); } return(new DelegatedAxleButtonInputSignature(id, profile.GetMapping(axis).CreateAxisDelegate(joystick), consideration, axleButtonDeadZone)); }
public DelegatedAxleButtonInputSignature(string id, AxisDelegate del, AxleValueConsideration consideration = AxleValueConsideration.Positive, float axisButtnDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) : base(id, del) { this.AxisButtonDeadZone = axisButtnDeadZone; this.Consideration = consideration; }
public AxleButtonInputSignature(string id, string unityInputId, AxleValueConsideration consideration = AxleValueConsideration.Positive, float axisButtnDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) : base(id, unityInputId) { this.AxisButtonDeadZone = axisButtnDeadZone; this.Consideration = consideration; }
public void RegisterTrigger(XboxInputId trigger, SPInputId axis, AxleValueConsideration consideration = AxleValueConsideration.Positive) { _axisTable[trigger] = InputToken.CreateTrigger(axis, consideration); _buttonTable.Remove(trigger); }
public void RegisterAxleButton(XboxInputId button, SPInputId axis, AxleValueConsideration consideration, float axleButtonDeadZone = InputUtil.DEFAULT_AXLEBTNDEADZONE) { _buttonTable[button] = InputToken.CreateAxleButton(axis, consideration, axleButtonDeadZone); _axisTable.Remove(button); }