void ProcessDPad(ulong updateTick, float deltaTime) { var x = Utility.ValueFromSides(DPadLeft.NextRawValue, DPadRight.NextRawValue); var y = Utility.ValueFromSides(DPadDown.NextRawValue, DPadUp.NextRawValue, InputManager.InvertYAxis); Vector2 v; if (RawSticks || DPadLeft.Raw || DPadRight.Raw || DPadUp.Raw || DPadDown.Raw) { v = new Vector2(x, y); } else { var lowerDeadZone = Utility.Max(DPadLeft.LowerDeadZone, DPadRight.LowerDeadZone, DPadUp.LowerDeadZone, DPadDown.LowerDeadZone); var upperDeadZone = Utility.Min(DPadLeft.UpperDeadZone, DPadRight.UpperDeadZone, DPadUp.UpperDeadZone, DPadDown.UpperDeadZone); v = Utility.ApplySeparateDeadZone(x, y, lowerDeadZone, upperDeadZone); } DPad.Raw = true; DPad.UpdateWithAxes(v.x, v.y, updateTick, deltaTime); DPadX.Raw = true; DPadX.CommitWithValue(v.x, updateTick, deltaTime); DPadY.Raw = true; DPadY.CommitWithValue(v.y, updateTick, deltaTime); DPadLeft.SetValue(DPad.Left.Value, updateTick); DPadRight.SetValue(DPad.Right.Value, updateTick); DPadUp.SetValue(DPad.Up.Value, updateTick); DPadDown.SetValue(DPad.Down.Value, updateTick); }
void Update() { ControllersManager.Instance.Update(); switch (state) { case State.Initial: if (ControllersManager.Instance.isControllerLinked(Index)) { state = State.Linked; } break; case State.Linked: if (!DownButton.IsOn(Index)) { state = State.Ready; readyEvent.Invoke(); } break; case State.Ready: DownButton.Update(Index); DPadLeft.Update(Index); DPadRight.Update(Index); DPadDown.Update(Index); DPadUp.Update(Index); break; default: break; } }
internal void ProcessDPad() { var lowerDeadZone = Utility.Max(DPadLeft.LowerDeadZone, DPadRight.LowerDeadZone, DPadUp.LowerDeadZone, DPadDown.LowerDeadZone); var upperDeadZone = Utility.Min(DPadLeft.UpperDeadZone, DPadRight.UpperDeadZone, DPadUp.UpperDeadZone, DPadDown.UpperDeadZone); var x = Utility.ValueFromSides(DPadLeft.NextRawValue, DPadRight.NextRawValue); var y = Utility.ValueFromSides(DPadDown.NextRawValue, DPadUp.NextRawValue, InputManager.InvertYAxis); var v = Utility.ApplyCircularDeadZone(x, y, lowerDeadZone, upperDeadZone); DPad.Raw = true; DPad.UpdateWithAxes(v.X, v.Y); DPadX.Raw = true; DPadX.CommitWithValue(v.X); DPadY.Raw = true; DPadY.CommitWithValue(v.Y); DPadLeft.SetValue(DPad.Left.Value); DPadRight.SetValue(DPad.Right.Value); DPadUp.SetValue(DPad.Up.Value); DPadDown.SetValue(DPad.Down.Value); }
public void HandleInputs() { GameObject.Find("Prompt").GetComponent <Text>().text = ""; //perform action linked to x button if (ControllerPluginWrapper.GetButtonDown(0, 0)) { if ((XButton.getCommand() != "DoNothing") && (XButton.getCommand() != "Jump") && (XButton.getCommand() != "UndoButton") && (XButton.getCommand() != "RemapButton")) { inputs.Push(XButton); } cooldown = maxCD; XButton.Execute(player, inputs.Peek()); if (XButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (XButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to circle button else if (ControllerPluginWrapper.GetButtonDown(0, 1)) { if ((CircleButton.getCommand() != "DoNothing") && (CircleButton.getCommand() != "Jump") && (CircleButton.getCommand() != "UndoButton") && (CircleButton.getCommand() != "RemapButton")) { inputs.Push(CircleButton); } cooldown = maxCD; CircleButton.Execute(player, inputs.Peek()); if (CircleButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (CircleButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to square button else if (ControllerPluginWrapper.GetButtonDown(0, 2)) { if ((SquareButton.getCommand() != "DoNothing") && (SquareButton.getCommand() != "Jump") && (SquareButton.getCommand() != "UndoButton") && (SquareButton.getCommand() != "RemapButton")) { inputs.Push(SquareButton); } cooldown = maxCD; SquareButton.Execute(player, inputs.Peek()); if (SquareButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (SquareButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to triangle button else if (ControllerPluginWrapper.GetButtonDown(0, 3)) { if ((TriangleButton.getCommand() != "DoNothing") && (TriangleButton.getCommand() != "Jump") && (TriangleButton.getCommand() != "UndoButton") && (TriangleButton.getCommand() != "RemapButton")) { inputs.Push(TriangleButton); } cooldown = maxCD; TriangleButton.Execute(player, inputs.Peek()); if (TriangleButton.getCommand() == "UndoButton") { inputs.Pop(); } else if (TriangleButton.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to up on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 4)) { if ((DPadUp.getCommand() != "DoNothing") && (DPadUp.getCommand() != "Jump") && (DPadUp.getCommand() != "UndoButton") && (DPadUp.getCommand() != "RemapButton")) { inputs.Push(DPadUp); } cooldown = maxCD; DPadUp.Execute(player, inputs.Peek()); if (DPadUp.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadUp.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to down on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 5)) { if ((DPadDown.getCommand() != "DoNothing") && (DPadDown.getCommand() != "Jump") && (DPadDown.getCommand() != "UndoButton") && (DPadDown.getCommand() != "RemapButton")) { inputs.Push(DPadDown); } cooldown = maxCD; DPadDown.Execute(player, inputs.Peek()); if (DPadDown.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadDown.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 6)) { if ((DPadLeft.getCommand() != "DoNothing") && (DPadLeft.getCommand() != "Jump") && (DPadLeft.getCommand() != "UndoButton") && (DPadLeft.getCommand() != "RemapButton")) { inputs.Push(DPadLeft); } cooldown = maxCD; DPadLeft.Execute(player, inputs.Peek()); if (DPadLeft.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadLeft.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right on directional pad else if (ControllerPluginWrapper.GetButtonDown(0, 7)) { if ((DPadRight.getCommand() != "DoNothing") && (DPadRight.getCommand() != "Jump") && (DPadRight.getCommand() != "UndoButton") && (DPadRight.getCommand() != "RemapButton")) { inputs.Push(DPadRight); } cooldown = maxCD; DPadRight.Execute(player, inputs.Peek()); if (DPadRight.getCommand() == "UndoButton") { inputs.Pop(); } else if (DPadRight.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left bumper else if (ControllerPluginWrapper.GetButtonDown(0, 8)) { if ((L1.getCommand() != "DoNothing") && (L1.getCommand() != "Jump") && (L1.getCommand() != "UndoButton") && (L1.getCommand() != "RemapButton")) { inputs.Push(L1); } cooldown = maxCD; L1.Execute(player, inputs.Peek()); if (L1.getCommand() == "UndoButton") { inputs.Pop(); } else if (L1.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right bumper else if (ControllerPluginWrapper.GetButtonDown(0, 9)) { if ((R1.getCommand() != "DoNothing") && (R1.getCommand() != "Jump") && (R1.getCommand() != "UndoButton") && (R1.getCommand() != "RemapButton")) { inputs.Push(R1); } cooldown = maxCD; R1.Execute(player, inputs.Peek()); if (R1.getCommand() == "UndoButton") { inputs.Pop(); } else if (R1.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left stick pressed else if (ControllerPluginWrapper.GetButtonDown(0, 10)) { if ((LStickPress.getCommand() != "DoNothing") && (LStickPress.getCommand() != "Jump") && (LStickPress.getCommand() != "UndoButton") && (LStickPress.getCommand() != "RemapButton")) { inputs.Push(LStickPress); } cooldown = maxCD; LStickPress.Execute(player, inputs.Peek()); if (LStickPress.getCommand() == "UndoButton") { inputs.Pop(); } else if (LStickPress.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right stick pressed else if (ControllerPluginWrapper.GetButtonDown(0, 11)) { if ((RStickPress.getCommand() != "DoNothing") && (RStickPress.getCommand() != "Jump") && (RStickPress.getCommand() != "UndoButton") && (RStickPress.getCommand() != "RemapButton")) { inputs.Push(RStickPress); } cooldown = maxCD; RStickPress.Execute(player, inputs.Peek()); if (RStickPress.getCommand() == "UndoButton") { inputs.Pop(); } else if (RStickPress.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to start button else if (ControllerPluginWrapper.GetButtonDown(0, 12)) { if ((Pause.getCommand() != "DoNothing") && (Pause.getCommand() != "Jump") && (Pause.getCommand() != "UndoButton") && (Pause.getCommand() != "RemapButton")) { inputs.Push(Pause); } cooldown = maxCD; Pause.Execute(player, inputs.Peek()); if (Pause.getCommand() == "UndoButton") { inputs.Pop(); } else if (Pause.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to back button else if (ControllerPluginWrapper.GetButtonDown(0, 13)) { if ((Select.getCommand() != "DoNothing") && (Select.getCommand() != "Jump") && (Select.getCommand() != "UndoButton") && (Select.getCommand() != "RemapButton")) { inputs.Push(Select); } cooldown = maxCD; Select.Execute(player, inputs.Peek()); if (Select.getCommand() == "UndoButton") { inputs.Pop(); } else if (Select.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to right trigger else if (ControllerPluginWrapper.RightTrigger(0) > 0.1f) { if ((RightTrigger.getCommand() != "DoNothing") && (RightTrigger.getCommand() != "Jump") && (RightTrigger.getCommand() != "UndoButton") && (RightTrigger.getCommand() != "RemapButton")) { inputs.Push(RightTrigger); } cooldown = maxCD; RightTrigger.Execute(player, inputs.Peek()); if (RightTrigger.getCommand() == "UndoButton") { inputs.Pop(); } else if (RightTrigger.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } //perform action linked to left trigger else if (ControllerPluginWrapper.LeftTrigger(0) > 0.1f) { if ((LeftTrigger.getCommand() != "DoNothing") && (LeftTrigger.getCommand() != "Jump") && (LeftTrigger.getCommand() != "UndoButton") && (LeftTrigger.getCommand() != "RemapButton")) { inputs.Push(LeftTrigger); } cooldown = maxCD; LeftTrigger.Execute(player, inputs.Peek()); if (LeftTrigger.getCommand() == "UndoButton") { inputs.Pop(); } else if (LeftTrigger.getCommand() == "RemapButton") { remapping = true; ResetAllButtons(); } } }