//=========== UPDATING =========== /** <summary> Called every step to update the control state. </summary> */ public void Update(int time, double pressure) { // Apply the dead zone to the position if (pressure <= deadZone) { pressure = 0.0; } // Update the control state based on its position if (disabledState == DisableState.Enabled) { this.pressure = pressure; // Update the button control button.Update(time, pressure > ButtonDeadZone); } else if (disabledState == DisableState.DisabledUntilRelease) { if (pressure == 0.0) { disabledState = DisableState.Enabled; for (int i = 0; i < 4; i++) { button.Enable(); } } } }
//=========== UPDATING =========== /** <summary> Called every step to update the control state. </summary> */ public void Update(int time, Vector2F position) { // Apply the dead zone to the position if (position.Length <= deadZone) { position = Vector2F.Zero; } // Update the control state based on its position if (disabledState == DisableState.Enabled) { this.position = position; // Update the directional controls directions[0].Update(time, position.X > DirectionDeadZone.X); directions[1].Update(time, position.Y > DirectionDeadZone.Y); directions[2].Update(time, position.X < -DirectionDeadZone.X); directions[3].Update(time, position.Y < -DirectionDeadZone.Y); } else if (disabledState == DisableState.DisabledUntilRelease) { if (position.IsZero) { disabledState = DisableState.Enabled; for (int i = 0; i < 4; i++) { directions[i].Enable(); } } } }
//========= CONSTRUCTORS ========= /** <summary> Constructs the default control. </summary> */ public Trigger() { this.button = new InputControl(); this.disabledState = DisableState.Enabled; this.pressure = 0.0; this.deadZone = 0.12; }
/** <summary> Enables the control. </summary> */ public void Enable() { disabledState = DisableState.Enabled; for (int i = 0; i < 4; i++) { directions[i].Enable(); } }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- // Constructs the default control. public InputControl() { this.state = InputState.Up; this.disabledState = DisableState.Enabled; this.isDoubleClicked = false; this.isClicked = false; this.isTyped = false; this.holdTime = 0; }
//----------------------------------------------------------------------------- // Updating //----------------------------------------------------------------------------- // Called every step to update the control state. public void Update(int time, bool down, bool typed = false, bool doubleClicked = false, bool clicked = false) { // Update the duration of the control state holdTime += time; // Update the double pressed and typed state if (disabledState == DisableState.Enabled) { this.isDoubleClicked = doubleClicked; this.isClicked = clicked; this.isTyped = typed; } // Update the control state based on its down state if (down) { if (disabledState == DisableState.Enabled) { if (state == InputState.Pressed) { state = InputState.Down; } if (state == InputState.Released || state == InputState.Up) { state = InputState.Pressed; if (holdTime < DoubleClickTime) { this.isDoubleClicked = true; } holdTime = 0; } } } else { if (disabledState == DisableState.Enabled) { if (state == InputState.Released) { state = InputState.Up; } if (state == InputState.Pressed || state == InputState.Down) { state = InputState.Released; holdTime = 0; } } else if (disabledState == DisableState.DisabledUntilRelease) { disabledState = DisableState.Enabled; state = InputState.Up; } } }
//========= CONSTRUCTORS ========= /** <summary> Constructs the default control. </summary> */ public AnalogStick() { this.directions = new InputControl[4]; this.disabledState = DisableState.Enabled; this.position = Vector2F.Zero; this.deadZone = 0.28; this.directionDeadZone = new Vector2F(0.83f, 0.83f); for (int i = 0; i < 4; i++) this.directions[i] = new InputControl(); }
//========= CONSTRUCTORS ========= /** <summary> Constructs the default control. </summary> */ public AnalogStick() { this.directions = new InputControl[4]; this.disabledState = DisableState.Enabled; this.position = Vector2F.Zero; this.deadZone = 0.28; this.directionDeadZone = new Vector2F(0.83f, 0.83f); for (int i = 0; i < 4; i++) { this.directions[i] = new InputControl(); } }
/** <summary> Disables the control. </summary> */ public void Disable(bool untilRelease = false) { if (untilRelease) { if (pressure != 0.0) disabledState = DisableState.DisabledUntilRelease; else pressure = 0.0; } else { pressure = 0.0; disabledState = DisableState.Disabled; } button.Disable(untilRelease); }
// Disables the control. public void Disable(bool untilRelease = false) { if (untilRelease) { if (state != InputState.Up && state != InputState.Released) disabledState = DisableState.DisabledUntilRelease; else state = InputState.Up; } else { state = InputState.Up; disabledState = DisableState.Disabled; } isDoubleClicked = false; isClicked = false; isTyped = false; holdTime = 0; }
private void setStates(DisableState state) { if (GameObjects == null) { return; } for (int i = 0; i < GameObjects.Length; i++) { switch (state) { case DisableState.Disable: GameObjects[i].SetActive(value: false); break; case DisableState.Enable: GameObjects[i].SetActive(value: true); break; } } }
/** <summary> Disables the control. </summary> */ public void Disable(bool untilRelease = false) { if (untilRelease) { if (pressure != 0.0) { disabledState = DisableState.DisabledUntilRelease; } else { pressure = 0.0; } } else { pressure = 0.0; disabledState = DisableState.Disabled; } button.Disable(untilRelease); }
public void ClockDisableState_InitializeFromRegisterValue(byte regVal30, byte regVal74, DisableState state0, DisableState state1, DisableState state2, DisableState state3, DisableState state4, DisableState state5, DisableState state6, DisableState state7) { var register = new ClockDisableState(regVal30, regVal74); Assert.Equal(state0, register.ClockOutput0); Assert.Equal(state1, register.ClockOutput1); Assert.Equal(state2, register.ClockOutput2); Assert.Equal(state3, register.ClockOutput3); Assert.Equal(state4, register.ClockOutput4); Assert.Equal(state5, register.ClockOutput5); Assert.Equal(state6, register.ClockOutput6); Assert.Equal(state7, register.ClockOutput7); }
/** <summary> Disables the control. </summary> */ public void Disable(bool untilRelease = false) { if (untilRelease) { if (!position.IsZero) { disabledState = DisableState.DisabledUntilRelease; } else { position = Vector2F.Zero; } } else { position = Vector2F.Zero; disabledState = DisableState.Disabled; } for (int i = 0; i < 4; i++) { directions[i].Disable(untilRelease); } }
// Disables the control. public void Disable(bool untilRelease = false) { if (untilRelease) { if (state != InputState.Up && state != InputState.Released) { disabledState = DisableState.DisabledUntilRelease; } else { state = InputState.Up; } } else { state = InputState.Up; disabledState = DisableState.Disabled; } isDoubleClicked = false; isClicked = false; isTyped = false; holdTime = 0; }
// Enables the control. public void Enable() { disabledState = DisableState.Enabled; }
public void ClockDisableState_InitializeFromSettings_CheckPropertiesAndRegisterValue(DisableState state0, DisableState state1, DisableState state2, DisableState state3, DisableState state4, DisableState state5, DisableState state6, DisableState state7, byte regVal30, byte regVal74) { var reg = new ClockDisableState(state0, state1, state2, state3, state4, state5, state6, state7); Assert.Equal(2, reg.ToBytes().Length); Assert.Equal(regVal30, reg.ToBytes()[0]); Assert.Equal(regVal74, reg.ToBytes()[1]); }
//----------------------------------------------------------------------------- // Updating //----------------------------------------------------------------------------- // Called every step to update the control state. public void Update(int time, bool down, bool typed = false, bool doubleClicked = false, bool clicked = false) { // Update the duration of the control state holdTime += time; // Update the double pressed and typed state if (disabledState == DisableState.Enabled) { this.isDoubleClicked = doubleClicked; this.isClicked = clicked; this.isTyped = typed; } // Update the control state based on its down state if (down) { if (disabledState == DisableState.Enabled) { if (state == InputState.Pressed) state = InputState.Down; if (state == InputState.Released || state == InputState.Up) { state = InputState.Pressed; if (holdTime < DoubleClickTime) this.isDoubleClicked = true; holdTime = 0; } } } else { if (disabledState == DisableState.Enabled) { if (state == InputState.Released) state = InputState.Up; if (state == InputState.Pressed || state == InputState.Down) { state = InputState.Released; holdTime = 0; } } else if (disabledState == DisableState.DisabledUntilRelease) { disabledState = DisableState.Enabled; state = InputState.Up; } } }
/** <summary> Enables the control. </summary> */ public void Enable() { disabledState = DisableState.Enabled; button.Enable(); }
/** <summary> Disables the control. </summary> */ public void Disable(bool untilRelease = false) { if (untilRelease) { if (!position.IsZero) disabledState = DisableState.DisabledUntilRelease; else position = Vector2F.Zero; } else { position = Vector2F.Zero; disabledState = DisableState.Disabled; } for (int i = 0; i < 4; i++) directions[i].Disable(untilRelease); }
//=========== UPDATING =========== /** <summary> Called every step to update the control state. </summary> */ public void Update(int time, double pressure) { // Apply the dead zone to the position if (pressure <= deadZone) { pressure = 0.0; } // Update the control state based on its position if (disabledState == DisableState.Enabled) { this.pressure = pressure; // Update the button control button.Update(time, pressure > ButtonDeadZone); } else if (disabledState == DisableState.DisabledUntilRelease) { if (pressure == 0.0) { disabledState = DisableState.Enabled; for (int i = 0; i < 4; i++) button.Enable(); } } }
/** <summary> Enables the control. </summary> */ public void Enable() { disabledState = DisableState.Enabled; for (int i = 0; i < 4; i++) directions[i].Enable(); }
//=========== UPDATING =========== /** <summary> Called every step to update the control state. </summary> */ public void Update(int time, Vector2F position) { // Apply the dead zone to the position if (position.Length <= deadZone) { position = Vector2F.Zero; } // Update the control state based on its position if (disabledState == DisableState.Enabled) { this.position = position; // Update the directional controls directions[0].Update(time, position.X > DirectionDeadZone.X); directions[1].Update(time, position.Y > DirectionDeadZone.Y); directions[2].Update(time, position.X < -DirectionDeadZone.X); directions[3].Update(time, position.Y < -DirectionDeadZone.Y); } else if (disabledState == DisableState.DisabledUntilRelease) { if (position.IsZero) { disabledState = DisableState.Enabled; for (int i = 0; i < 4; i++) directions[i].Enable(); } } }