public bool GetButtonUp(GamepadButton button, GamepadIndex gamepad) { GamePadState state = GetCurrentState(gamepad); GamePadState oldState = GetPreviousState(gamepad); return(!GetButton(button, state) && GetButton(button, oldState)); }
public bool AnyInput(GamepadIndex gamepad) { if (m_adapter == null) { return(false); } for (int bi = 0; bi < NUMBER_OF_BUTTONS; bi++) { if (m_buttonStates[(int)gamepad, bi]) { return(true); } } for (int ai = 0; ai < NUMBER_OF_AXES; ai++) { if (m_axisStates[(int)gamepad, ai]) { return(true); } } return(false); }
public bool GetButtonDown(GamepadButton button, GamepadIndex gamepad) { GamepadReading?state = GetCurrentState(gamepad); GamepadReading?oldState = GetPreviousState(gamepad); return(GetButton(button, state) && !GetButton(button, oldState)); }
protected override void OnAssignGamepadProfile(GamepadIndex gamepad) { if (!Adapter.IsConnected(gamepad)) { return; } string gamepadName = Adapter.GetName(gamepad); for (int i = 0; i < m_profiles.Count; i++) { if (IsMatch(m_profiles[i], gamepadName)) { Adapter.SetProfile(gamepad, m_profiles[i].GamepadProfile); Debug.LogFormat("Profile '{0}' assigned to '{1}'.", m_profiles[i].GamepadProfile.Name, gamepadName); return; } } if (m_defaultProfile != null) { Adapter.SetProfile(gamepad, m_defaultProfile); Debug.LogFormat("No profile found for '{0}'. Assigning default profile '{1}'.", gamepadName, m_defaultProfile.Name); } else { Debug.LogFormat("No profile found for '{0}'.", gamepadName); } }
public static bool AnyInput(GamepadIndex gamepad) { PrintMissingAdapterWarningIfNecessary(); GamepadStateService service = InputManager.GetService <GamepadStateService>(); return(service != null?service.AnyInput(gamepad) : false); }
public static void SetVibration(GamepadVibration vibration, GamepadIndex gamepad) { PrintMissingAdapterWarningIfNecessary(); if (Adapter != null) { Adapter.SetVibration(vibration, gamepad); } }
public GamepadDevice(GamepadIndex index) { if (index == GamepadIndex.Other) { throw new System.InvalidOperationException($"To use other indices, please use {nameof(GamepadDevice)}(int id) constructor directly."); } Id = (int)index; }
public static PlayerIndex ToPlayerIndex(this GamepadIndex gamepadIndex) { if ((int)gamepadIndex > (int)PlayerIndex.Four) { throw new System.InvalidOperationException($"{nameof(GamepadIndex)} '{gamepadIndex}' doesn't contains a valid associated {nameof(PlayerIndex)}."); } return((PlayerIndex)((int)gamepadIndex)); }
public void ChangeGamepad(GamepadIndex gamepad) { foreach (var action in m_actions) { foreach (var binding in action.Bindings) { binding.GamepadIndex = gamepad; } } }
public void SetVibration(LumiVibration vibration, GamepadIndex gamepad) { Gamepad gamepadDevice = GetGamepad(gamepad); if (gamepadDevice != null) { gamepadDevice.Vibration = new WinVibration { LeftMotor = vibration.LeftMotor, RightMotor = vibration.RightMotor, LeftTrigger = vibration.LeftTrigger, RightTrigger = vibration.RightTrigger }; } }
public float GetAxis(GamepadAxis axis, GamepadIndex gamepad) { GenericGamepadProfile profile = GetProfile(gamepad); if (profile == null) { return(0.0f); } int joyID = (int)gamepad, axisID = -1; switch (axis) { case GamepadAxis.LeftThumbstickX: axisID = profile.LeftStickXAxis; break; case GamepadAxis.LeftThumbstickY: axisID = profile.LeftStickYAxis; break; case GamepadAxis.RightThumbstickX: axisID = profile.RightStickXAxis; break; case GamepadAxis.RightThumbstickY: axisID = profile.RightStickYAxis; break; case GamepadAxis.DPadX: axisID = profile.DPadXAxis; break; case GamepadAxis.DPadY: axisID = profile.DPadYAxis; break; case GamepadAxis.LeftTrigger: axisID = profile.LeftTriggerAxis; break; case GamepadAxis.RightTrigger: axisID = profile.RightTriggerAxis; break; } return(axisID >= 0 ? Input.GetAxis(m_axisNameLookupTable[joyID * InputBinding.MAX_JOYSTICK_AXES + axisID]) : 0.0f); }
public void Copy(InputBinding source) { m_positive = source.m_positive; m_negative = source.m_negative; m_deadZone = source.m_deadZone; m_gravity = source.m_gravity; m_sensitivity = source.m_sensitivity; m_snap = source.m_snap; m_invert = source.m_invert; m_type = source.m_type; m_axis = source.m_axis; m_joystick = source.m_joystick; m_gamepadAxis = source.m_gamepadAxis; m_gamepadButton = source.m_gamepadButton; m_gamepadIndex = source.m_gamepadIndex; }
public LumiVibration GetVibration(GamepadIndex gamepad) { Gamepad gamepadDevice = GetGamepad(gamepad); if (gamepadDevice != null) { return(new LumiVibration { LeftMotor = (float)gamepadDevice.Vibration.LeftMotor, RightMotor = (float)gamepadDevice.Vibration.RightMotor, LeftTrigger = (float)gamepadDevice.Vibration.LeftTrigger, RightTrigger = (float)gamepadDevice.Vibration.RightTrigger }); } return(new LumiVibration()); }
public float GetAxis(GamepadAxis axis, GamepadIndex gamepad) { GamePadState state = GetCurrentState(gamepad); float value = 0.0f; if (state.IsConnected) { switch (axis) { case GamepadAxis.LeftThumbstickX: value = state.ThumbSticks.Left.X; break; case GamepadAxis.LeftThumbstickY: value = state.ThumbSticks.Left.Y; break; case GamepadAxis.RightThumbstickX: value = state.ThumbSticks.Right.X; break; case GamepadAxis.RightThumbstickY: value = state.ThumbSticks.Right.Y; break; case GamepadAxis.LeftTrigger: value = state.Triggers.Left; break; case GamepadAxis.RightTrigger: value = state.Triggers.Right; break; case GamepadAxis.DPadX: value = GetDPADState(gamepad).X; break; case GamepadAxis.DPadY: value = GetDPADState(gamepad).Y; break; } } return(value); }
public float GetAxis(GamepadAxis axis, GamepadIndex gamepad) { GamepadReading?state = GetCurrentState(gamepad); double value = 0.0; if (state.HasValue) { switch (axis) { case GamepadAxis.LeftThumbstickX: value = state.Value.LeftThumbstickX; break; case GamepadAxis.LeftThumbstickY: value = state.Value.LeftThumbstickY; break; case GamepadAxis.RightThumbstickX: value = state.Value.RightThumbstickX; break; case GamepadAxis.RightThumbstickY: value = state.Value.RightThumbstickY; break; case GamepadAxis.DPadX: value = m_dpadState[(int)gamepad].X; break; case GamepadAxis.DPadY: value = m_dpadState[(int)gamepad].Y; break; case GamepadAxis.LeftTrigger: value = state.Value.LeftTrigger; break; case GamepadAxis.RightTrigger: value = state.Value.RightTrigger; break; } } return((float)value); }
private XPlayerIndex ToPlayerIndex(GamepadIndex gamepad) { switch (gamepad) { case GamepadIndex.GamepadOne: return(XPlayerIndex.One); case GamepadIndex.GamepadTwo: return(XPlayerIndex.Two); case GamepadIndex.GamepadThree: return(XPlayerIndex.Three); case GamepadIndex.GamepadFour: return(XPlayerIndex.Four); default: return(XPlayerIndex.One); } }
public GenericGamepadProfile GetProfile(GamepadIndex gamepad) { switch (gamepad) { case GamepadIndex.GamepadOne: return(m_gamepadOne); case GamepadIndex.GamepadTwo: return(m_gamepadTwo); case GamepadIndex.GamepadThree: return(m_gamepadThree); case GamepadIndex.GamepadFour: return(m_gamepadFour); default: throw new System.ArgumentException(string.Format("Gamepad '{0}' is not valid.", gamepad), "gamepad"); } }
public void SetProfile(GamepadIndex gamepad, GenericGamepadProfile profile) { switch (gamepad) { case GamepadIndex.GamepadOne: m_gamepadOne = profile; break; case GamepadIndex.GamepadTwo: m_gamepadTwo = profile; break; case GamepadIndex.GamepadThree: m_gamepadThree = profile; break; case GamepadIndex.GamepadFour: m_gamepadFour = profile; break; default: throw new System.ArgumentException(string.Format("Gamepad '{0}' is not valid.", gamepad), "gamepad"); } }
public bool GetButtonUp(GamepadButton button, GamepadIndex gamepad) { GenericGamepadProfile profile = GetProfile(gamepad); if (profile == null) { return(false); } switch (button) { case GamepadButton.LeftStick: return(GetButtonUp(profile.LeftStickButton, (int)gamepad)); case GamepadButton.RightStick: return(GetButtonUp(profile.RightStickButton, (int)gamepad)); case GamepadButton.LeftBumper: return(GetButtonUp(profile.LeftBumperButton, (int)gamepad)); case GamepadButton.RightBumper: return(GetButtonUp(profile.RightBumperButton, (int)gamepad)); case GamepadButton.DPadUp: return(profile.DPadType == GamepadDPadType.Button ? GetButtonUp(profile.DPadUpButton, (int)gamepad) : m_dpadState[(int)gamepad].Up == ButtonState.JustReleased); case GamepadButton.DPadDown: return(profile.DPadType == GamepadDPadType.Button ? GetButtonUp(profile.DPadUpButton, (int)gamepad) : m_dpadState[(int)gamepad].Down == ButtonState.JustReleased); case GamepadButton.DPadLeft: return(profile.DPadType == GamepadDPadType.Button ? GetButtonUp(profile.DPadUpButton, (int)gamepad) : m_dpadState[(int)gamepad].Left == ButtonState.JustReleased); case GamepadButton.DPadRight: return(profile.DPadType == GamepadDPadType.Button ? GetButtonUp(profile.DPadUpButton, (int)gamepad) : m_dpadState[(int)gamepad].Right == ButtonState.JustReleased); case GamepadButton.Back: return(GetButtonUp(profile.BackButton, (int)gamepad)); case GamepadButton.Start: return(GetButtonUp(profile.StartButton, (int)gamepad)); case GamepadButton.ActionBottom: return(GetButtonUp(profile.ActionBottomButton, (int)gamepad)); case GamepadButton.ActionRight: return(GetButtonUp(profile.ActionRightButton, (int)gamepad)); case GamepadButton.ActionLeft: return(GetButtonUp(profile.ActionLeftButton, (int)gamepad)); case GamepadButton.ActionTop: return(GetButtonUp(profile.ActionTopButton, (int)gamepad)); default: return(false); } }
public float GetAxisRaw(GamepadAxis axis, GamepadIndex gamepad) { float value = GetAxis(axis, gamepad); return(Mathf.Approximately(value, 0) ? 0.0f : Mathf.Sign(value)); }
public GamepadState(GamepadIndex userIndex) { UserIndex = userIndex; Controller = new Controller((UserIndex)userIndex); }
public bool IsConnected(GamepadIndex gamepad) { return(m_gamepadStatus[(int)gamepad].IsConnected); }
public string GetName(GamepadIndex gamepad) { return(m_gamepadStatus[(int)gamepad].Name); }
public GenericGamepadProfile this[GamepadIndex gamepad] { get { return(GetProfile(gamepad)); } }
public GamepadCapabilities(GamepadIndex index) : this((int)index) { }
public void SetVibration(GamepadVibration vibration, GamepadIndex gamepad) { }
public bool IsConnected(GamepadIndex gamepad) { return(m_joystickState[(int)gamepad]); }
public GamepadVibration GetVibration(GamepadIndex gamepad) { return(new GamepadVibration()); }
public bool GetButtonUp(GamepadButton button, GamepadIndex gamepad) { return(false); }
public GamepadVibration GetVibration(GamepadIndex gamepad) { return(GamepadVibration.None); }
public float GetAxisRaw(GamepadAxis axis, GamepadIndex gamepad) { return(0); }