/// <summary> /// Listens input for Virtua-R Limit /// </summary> /// <param name="state">JoystickUpdate state.</param> /// <param name="useSto0Z">Use stoozes special driving controls.</param> /// <param name="joystickMapping">Joystick mapping.</param> private static void VrlInput(JoystickUpdate state, bool useSto0Z, JoystickMapping joystickMapping) { PlayerButtons playerButtons = InputCode.PlayerOneButtons; HandleDefaultWheelControls(state, joystickMapping, useSto0Z); HandleDefaultSpecialButtons(state, joystickMapping, playerButtons); }
/// <summary> /// Listens input for Virtua-R Limit /// </summary> /// <param name="state">JoystickUpdate state.</param> /// <param name="useSto0Z">Use stoozes special driving controls.</param> /// <param name="xinputMapping">Joystick mapping.</param> private static void VrlInput(State state, bool useSto0Z, XInputMapping xinputMapping) { PlayerButtons playerButtons = InputCode.PlayerOneButtons; HandleDefaultWheelControls(state, xinputMapping, useSto0Z); HandleDefaultSpecialButtons(state, xinputMapping, playerButtons); }
private void LetsGoIslandGuns(State state, PlayerButtons playerButtons, XInputMapping xinputMapping) { HandleDefaultSpecialButtons(state, xinputMapping, playerButtons); GetDirectionPress(playerButtons, xinputMapping.GunLeft, state, Direction.Left); GetDirectionPress(playerButtons, xinputMapping.GunRight, state, Direction.Right); GetDirectionPress(playerButtons, xinputMapping.GunUp, state, Direction.Up); GetDirectionPress(playerButtons, xinputMapping.GunDown, state, Direction.Down); playerButtons.Button1 = GetButtonPress(xinputMapping.GunTrigger, state); }
private void GoldenGunGuns(JoystickUpdate state, PlayerButtons playerButtons, JoystickMapping joystickMapping) { HandleDefaultSpecialButtons(state, joystickMapping, playerButtons); GetDirectionPress(playerButtons, joystickMapping.GunUp, state, Direction.Right); GetDirectionPress(playerButtons, joystickMapping.GunDown, state, Direction.Left); GetDirectionPress(playerButtons, joystickMapping.GunLeft, state, Direction.Down); GetDirectionPress(playerButtons, joystickMapping.GunRight, state, Direction.Up); playerButtons.Button1 = GetButtonPress(joystickMapping.GunTrigger, state); }
/// <summary> /// Listens input for Standard JVS ABDE button layout. Some games use this. (TX1/2 various game testing) /// </summary> /// <param name="state">JoystickUpdate state.</param> /// <param name="playerButtons">Player whos buttons to populate.</param> /// <param name="xinputMapping">Joystick mapping.</param> private static void StandardJvsAbdeController(State state, PlayerButtons playerButtons, XInputMapping xinputMapping) { HandleDefaultSpecialButtons(state, xinputMapping, playerButtons); GetDirectionPress(playerButtons, xinputMapping.Up, state, Direction.Up); GetDirectionPress(playerButtons, xinputMapping.Down, state, Direction.Down); GetDirectionPress(playerButtons, xinputMapping.Left, state, Direction.Left); GetDirectionPress(playerButtons, xinputMapping.Right, state, Direction.Right); playerButtons.Button1 = GetButtonPress(xinputMapping.Button1, state); playerButtons.Button2 = GetButtonPress(xinputMapping.Button2, state); playerButtons.Button4 = GetButtonPress(xinputMapping.Button3, state); playerButtons.Button5 = GetButtonPress(xinputMapping.Button4, state); }
/// <summary> /// Listens input for Standard JVS 6 button layout. /// </summary> /// <param name="state">JoystickUpdate state.</param> /// <param name="playerButtons">Player whos buttons to populate.</param> /// <param name="joystickMapping">Joystick mapping.</param> private static void Standard6ButtonController(JoystickUpdate state, PlayerButtons playerButtons, JoystickMapping joystickMapping) { HandleDefaultSpecialButtons(state, joystickMapping, playerButtons); GetDirectionPress(playerButtons, joystickMapping.Up, state, Direction.Up); GetDirectionPress(playerButtons, joystickMapping.Down, state, Direction.Down); GetDirectionPress(playerButtons, joystickMapping.Left, state, Direction.Left); GetDirectionPress(playerButtons, joystickMapping.Right, state, Direction.Right); playerButtons.Button1 = GetButtonPress(joystickMapping.Button1, state); playerButtons.Button2 = GetButtonPress(joystickMapping.Button2, state); playerButtons.Button3 = GetButtonPress(joystickMapping.Button3, state); playerButtons.Button4 = GetButtonPress(joystickMapping.Button4, state); playerButtons.Button5 = GetButtonPress(joystickMapping.Button5, state); playerButtons.Button6 = GetButtonPress(joystickMapping.Button6, state); }
public static void SetPlayerDirection(PlayerButtons playerButtons, Direction direction) { switch (direction) { case Direction.Up: playerButtons.Up = true; playerButtons.Down = false; break; case Direction.Down: playerButtons.Up = false; playerButtons.Down = true; break; case Direction.VerticalCenter: playerButtons.Up = false; playerButtons.Down = false; break; case Direction.HorizontalCenter: playerButtons.Left = false; playerButtons.Right = false; break; case Direction.Left: playerButtons.Left = true; playerButtons.Right = false; break; case Direction.Right: playerButtons.Left = false; playerButtons.Right = true; break; default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } }
/// <summary> /// Get directional press from button, POV and analog. /// </summary> /// <param name="playerButtons"></param> /// <param name="button"></param> /// <param name="state"></param> /// <param name="direction"></param> private static void GetDirectionPress(PlayerButtons playerButtons, XInputButton button, State state, Direction direction) { if (button == null) { return; } // Analog Axis, we expect that the both direction are on same axis!!!! if (button.IsLeftThumbX || button.IsLeftThumbY || button.IsRightThumbX || button.IsRightThumbY) { var calcVal = 0; if (button.IsLeftThumbY) { calcVal = state.Gamepad.LeftThumbY; } if (button.IsLeftThumbX) { calcVal = state.Gamepad.LeftThumbX; } if (button.IsRightThumbX) { calcVal = state.Gamepad.RightThumbX; } if (button.IsRightThumbY) { calcVal = state.Gamepad.RightThumbY; } if (button.IsAxisMinus) { if (calcVal >= 0 + 15000) { } else if (calcVal <= 0 - 15000) { InputCode.SetPlayerDirection(playerButtons, direction); } else { if (direction == Direction.Left || direction == Direction.Right) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Up || direction == Direction.Down) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } } } else { if (calcVal >= 0 + 15000) { InputCode.SetPlayerDirection(playerButtons, direction); } else if (calcVal <= 0 - 15000) { } else { if (direction == Direction.Left || direction == Direction.Right) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Up || direction == Direction.Down) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } } } } // Normal button if (button.IsButton) { if ((button.ButtonCode & (short)state.Gamepad.Buttons) != 0) { InputCode.SetPlayerDirection(playerButtons, direction); } else { if (direction == Direction.Left && !playerButtons.RightPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Right && !playerButtons.LeftPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Up && !playerButtons.DownPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } if (direction == Direction.Down && !playerButtons.UpPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } } } }
/// <summary> /// Handles special buttons Start, Test and Service. /// </summary> /// <param name="state"></param> /// <param name="xinputMapping"></param> /// <param name="playerButtons"></param> private static void HandleDefaultSpecialButtons(State state, XInputMapping xinputMapping, PlayerButtons playerButtons) { playerButtons.Start = GetButtonPress(xinputMapping.Start, state); playerButtons.Test = GetButtonPress(xinputMapping.Test, state); playerButtons.Service = GetButtonPress(xinputMapping.Service, state); }
/// <summary> /// Handles Lets Go Island controls. /// </summary> /// <param name="playerButtons"></param> /// <param name="playerNumber"></param> private void HandleLgiControls(PlayerButtons playerButtons, int playerNumber) { while (true) { if (KillMe) { return; } if (playerNumber == 1) { if (playerButtons.UpPressed()) { if (InputCode.AnalogBytes[0] <= 0xE0) { InputCode.AnalogBytes[0] += _player1GunMultiplier; } } if (playerButtons.DownPressed()) { if (InputCode.AnalogBytes[0] >= 10) { InputCode.AnalogBytes[0] -= _player1GunMultiplier; } } if (playerButtons.RightPressed()) { if (InputCode.AnalogBytes[2] >= 10) { InputCode.AnalogBytes[2] -= _player1GunMultiplier; } } if (playerButtons.LeftPressed()) { if (InputCode.AnalogBytes[2] <= 0xE0) { InputCode.AnalogBytes[2] += _player1GunMultiplier; } } } if (playerNumber == 2) { if (playerButtons.UpPressed()) { if (InputCode.AnalogBytes[4] <= 0xE0) { InputCode.AnalogBytes[4] += _player2GunMultiplier; } } if (playerButtons.DownPressed()) { if (InputCode.AnalogBytes[4] >= 10) { InputCode.AnalogBytes[4] -= _player2GunMultiplier; } } if (playerButtons.RightPressed()) { if (InputCode.AnalogBytes[6] >= 10) { InputCode.AnalogBytes[6] -= _player2GunMultiplier; } } if (playerButtons.LeftPressed()) { if (InputCode.AnalogBytes[6] <= 0xE0) { InputCode.AnalogBytes[6] += _player2GunMultiplier; } } } Thread.Sleep(10); } }
/// <summary> /// Get directional press from button, POV and analog. /// </summary> /// <param name="playerButtons"></param> /// <param name="button"></param> /// <param name="state"></param> /// <param name="direction"></param> private static void GetDirectionPress(PlayerButtons playerButtons, JoystickButton button, JoystickUpdate state, Direction direction) { if (button == null) { return; } if ((JoystickOffset)button.Button != state.Offset) { return; } // POV if (button.Button >= 32 && button.Button <= 44) { switch (state.Value) { case -1: InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); break; case 0: InputCode.SetPlayerDirection(playerButtons, Direction.Up); break; case 4500: InputCode.SetPlayerDirection(playerButtons, Direction.Up); InputCode.SetPlayerDirection(playerButtons, Direction.Right); break; case 9000: InputCode.SetPlayerDirection(playerButtons, Direction.Right); break; case 13500: InputCode.SetPlayerDirection(playerButtons, Direction.Down); InputCode.SetPlayerDirection(playerButtons, Direction.Right); break; case 18000: InputCode.SetPlayerDirection(playerButtons, Direction.Down); break; case 22500: InputCode.SetPlayerDirection(playerButtons, Direction.Left); InputCode.SetPlayerDirection(playerButtons, Direction.Down); break; case 27000: InputCode.SetPlayerDirection(playerButtons, Direction.Left); break; case 31500: InputCode.SetPlayerDirection(playerButtons, Direction.Left); InputCode.SetPlayerDirection(playerButtons, Direction.Up); break; } } // Analog Axis, we expect that the both direction are on same axis!!!! if (state.Offset == JoystickOffset.X || state.Offset == JoystickOffset.Y || state.Offset == JoystickOffset.Z || state.Offset == JoystickOffset.RotationX || state.Offset == JoystickOffset.RotationY || state.Offset == JoystickOffset.RotationZ || state.Offset == JoystickOffset.Sliders0 || state.Offset == JoystickOffset.Sliders1 || state.Offset == JoystickOffset.AccelerationX || state.Offset == JoystickOffset.AccelerationY || state.Offset == JoystickOffset.AccelerationZ) { if (button.IsAxisMinus) { if (state.Value >= 32064 + 15000) { } else if (state.Value <= 32064 - 15000) { InputCode.SetPlayerDirection(playerButtons, direction); } else { if (direction == Direction.Left || direction == Direction.Right) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Up || direction == Direction.Down) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } } } else { if (state.Value >= 32064 + 15000) { InputCode.SetPlayerDirection(playerButtons, direction); } else if (state.Value <= 32064 - 15000) { } else { if (direction == Direction.Left || direction == Direction.Right) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Up || direction == Direction.Down) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } } } } // Normal button if (button.Button >= 48 && button.Button <= 175) { if (state.Value != 0) { InputCode.SetPlayerDirection(playerButtons, direction); } else { if (direction == Direction.Left && !playerButtons.RightPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Right && !playerButtons.LeftPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.HorizontalCenter); } if (direction == Direction.Up && !playerButtons.DownPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } if (direction == Direction.Down && !playerButtons.UpPressed()) { InputCode.SetPlayerDirection(playerButtons, Direction.VerticalCenter); } } } }
/// <summary> /// Handles special buttons Start, Test and Service. /// </summary> /// <param name="state"></param> /// <param name="joystickMapping"></param> /// <param name="playerButtons"></param> private static void HandleDefaultSpecialButtons(JoystickUpdate state, JoystickMapping joystickMapping, PlayerButtons playerButtons) { playerButtons.Start = GetButtonPress(joystickMapping.Start, state); playerButtons.Test = GetButtonPress(joystickMapping.Test, state); playerButtons.Service = GetButtonPress(joystickMapping.Service, state); }