public float GetAxis(GamePadID controllerID, GamePadAxis axis) { int id = (int)controllerID; if (!m_gamePads[id].playerIndexSet) { return(0f); } switch (axis) { case GamePadAxis.LeftJoystickX: return(m_gamePads[id].state.ThumbSticks.Left.X); case GamePadAxis.LeftJoystickY: return(m_gamePads[id].state.ThumbSticks.Left.Y); case GamePadAxis.RightJoystickX: return(m_gamePads[id].state.ThumbSticks.Right.X); case GamePadAxis.RightJoystickY: return(m_gamePads[id].state.ThumbSticks.Right.Y); case GamePadAxis.LeftTrigger: return(m_gamePads[id].state.Triggers.Left); case GamePadAxis.RightTrigger: return(m_gamePads[id].state.Triggers.Left); default: return(0f); } }
public InputEvent GetEvent(GamePadID controllerID, GamePadInput input) { int id = (int)controllerID; switch (input) { case GamePadInput.ButtonA: return(m_gamePads[id].padEvent.OnButtonA); case GamePadInput.ButtonB: return(m_gamePads[id].padEvent.OnButtonB); case GamePadInput.ButtonX: return(m_gamePads[id].padEvent.OnButtonX); case GamePadInput.ButtonY: return(m_gamePads[id].padEvent.OnButtonY); case GamePadInput.ButtonARelease: return(m_gamePads[id].padEvent.OnButtonARelease); case GamePadInput.RightBumper: return(m_gamePads[id].padEvent.OnButtonRightBumper); case GamePadInput.LeftBumper: return(m_gamePads[id].padEvent.OnButtonLeftBumper); case GamePadInput.ButtonStart: return(m_gamePads[id].padEvent.OnButtonStart); case GamePadInput.DPadDown: return(m_gamePads[id].padEvent.OnDPadDown); case GamePadInput.DPadLeft: return(m_gamePads[id].padEvent.OnDPadLeft); case GamePadInput.DPadUp: return(m_gamePads[id].padEvent.OnDPadUp); case GamePadInput.DPadRight: return(m_gamePads[id].padEvent.OnDPadRight); default: return(null); } }
public void AssignGamePad(GamePadID newGamePad) { if (m_currGamePadID == newGamePad) { return; } if (m_currGamePadID != GamePadID.None) { DisableInputEvent(); } m_currGamePadID = newGamePad; if (isActiveAndEnabled) { EnableInputEvent(); } }
public void CleanGamePadEvent(GamePadID controllerID) { int id = (int)controllerID; m_gamePads[id].padEvent.OnButtonA.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonB.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonX.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonY.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonARelease.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonRightBumper.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonLeftBumper.RemoveAllListeners(); m_gamePads[id].padEvent.OnButtonStart.RemoveAllListeners(); m_gamePads[id].padEvent.OnDPadDown.RemoveAllListeners(); m_gamePads[id].padEvent.OnDPadLeft.RemoveAllListeners(); m_gamePads[id].padEvent.OnDPadRight.RemoveAllListeners(); m_gamePads[id].padEvent.OnDPadUp.RemoveAllListeners(); }
public void ShakeGamePad(GamePadID id, float left, float right) { GamePad.SetVibration((PlayerIndex)id, left, right); }