CJoystick::CJoystick()
{
- Reset();
+ Reset(true);
m_NumAxes = 0;
m_AxisId = 0;
m_JoyId = 0;
m_HatId = 0;
m_HatState = SDL_HAT_CENTERED;
m_ActiveFlags = JACTIVE_NONE;
- for (int i = 0 ; i<MAX_AXES ; i++)
- m_Amount[i] = 0;
SetDeadzone(0);
}
SDL_JoystickEventState(SDL_DISABLE);
}
-void CJoystick::Reset(bool axis)
+void CJoystick::Reset(bool axis /*=false*/)
{
if (axis)
{
bool CJoystick::GetHat(int &id, int &position,bool consider_repeat)
{
if (!IsHatActive())
+ {
+ id = position = 0;
return false;
+ }
position = m_HatState;
id = m_HatId;
if (!consider_repeat)
bool CJoystick::GetButton(int &id, bool consider_repeat)
{
if (!IsButtonActive())
+ {
+ id = 0;
return false;
+ }
if (!consider_repeat)
{
id = m_ButtonId;
return true;
}
+bool CJoystick::GetAxis (int &id)
+{
+ if (!IsAxisActive())
+ {
+ id = 0;
+ return false;
+ }
+ id = m_AxisId;
+ return true;
+}
+
int CJoystick::GetAxisWithMaxAmount()
{
static int maxAmount;
void Update();
void Update(SDL_Event& event);
bool GetButton (int& id, bool consider_repeat=true);
- bool GetAxis (int &id) { if (!IsAxisActive()) return false; id=m_AxisId; return true; }
+ bool GetAxis (int &id);
bool GetHat (int &id, int &position, bool consider_repeat=true);
std::string GetJoystick() { return (m_JoyId>-1)?m_JoystickNames[m_JoyId]:""; }
int GetAxisWithMaxAmount();
CJoystick::CJoystick()
{
- Reset();
+ Reset(true);
m_NumAxes = 0;
m_AxisId = 0;
m_JoyId = 0;
m_HatId = 0;
m_HatState = SDL_HAT_CENTERED;
m_ActiveFlags = JACTIVE_NONE;
- for (int i = 0 ; i<MAX_AXES ; i++)
- m_Amount[i] = 0;
SetDeadzone(0);
m_pDI = NULL;
m_pJoysticks.clear();
m_JoystickNames.clear();
m_devCaps.clear();
+ m_HatId = 0;
+ m_ButtonId = 0;
+ m_HatState = SDL_HAT_CENTERED;
+ m_ActiveFlags = JACTIVE_NONE;
+ Reset(true);
+ m_lastPressTicks = 0;
+ m_lastTicks = 0;
// Release any DirectInput objects.
SAFE_RELEASE( m_pDI );
}
SetDeadzone(g_advancedSettings.m_controllerDeadzone);
}
-void CJoystick::Reset(bool axis)
+void CJoystick::Reset(bool axis /*=true*/)
{
if (axis)
{
bool CJoystick::GetHat(int &id, int &position,bool consider_repeat)
{
if (!IsHatActive())
+ {
+ id = position = 0;
return false;
+ }
position = m_HatState;
id = m_HatId;
if (!consider_repeat)
bool CJoystick::GetButton(int &id, bool consider_repeat)
{
if (!IsButtonActive())
+ {
+ id = 0;
return false;
+ }
if (!consider_repeat)
{
id = m_ButtonId;
return true;
}
+bool CJoystick::GetAxis (int &id)
+{
+ if (!IsAxisActive())
+ {
+ id = 0;
+ return false;
+ }
+ id = m_AxisId;
+ return true;
+}
+
int CJoystick::GetAxisWithMaxAmount()
{
int maxAmount = 0;
void ResetAxis(int axisId) { m_Amount[axisId] = 0; }
void Update();
bool GetButton (int& id, bool consider_repeat=true);
- bool GetAxis (int &id) { if (!IsAxisActive()) return false; id=m_AxisId; return true; }
+ bool GetAxis (int &id);
bool GetHat (int &id, int &position, bool consider_repeat=true);
std::string GetJoystick() { return (m_JoyId>-1)?m_JoystickNames[m_JoyId]:""; }
int GetAxisWithMaxAmount();