Disable joystick on non-android by default

This commit is contained in:
def 2014-08-17 16:33:43 +02:00
parent 038129f9ce
commit 5b058b9941
2 changed files with 22 additions and 11 deletions

View file

@ -313,5 +313,10 @@ MACRO_CONFIG_INT(ClAutoUpdate, cl_auto_update, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLI
MACRO_CONFIG_INT(ClOldGunPosition, cl_old_gun_position, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Tees hold gun a bit higher like in TW 0.6.1 and older")
MACRO_CONFIG_INT(ClConfirmDisconnect, cl_confirm_disconnect, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Confirmation popup before disconnecting")
MACRO_CONFIG_STR(ClTimeoutCode, cl_timeout_code, 64, "", CFGFLAG_SAVE|CFGFLAG_CLIENT, "Timeout code to use")
#if defined(__ANDROID__)
MACRO_CONFIG_INT(InpJoystick, inp_joystick, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Try to use a joystick as input")
#else
MACRO_CONFIG_INT(InpJoystick, inp_joystick, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Try to use a joystick as input")
#endif
#endif

View file

@ -28,23 +28,29 @@ CControls::CControls()
m_LastDummy = 0;
m_OtherFire = 0;
SDL_Init(SDL_INIT_JOYSTICK);
m_Joystick = SDL_JoystickOpen(0);
if( m_Joystick && SDL_JoystickNumAxes(m_Joystick) < NUM_JOYSTICK_AXES )
if (g_Config.m_InpJoystick)
{
SDL_JoystickClose(m_Joystick);
m_Joystick = NULL;
}
SDL_Init(SDL_INIT_JOYSTICK);
m_Joystick = SDL_JoystickOpen(0);
if( m_Joystick && SDL_JoystickNumAxes(m_Joystick) < NUM_JOYSTICK_AXES )
{
SDL_JoystickClose(m_Joystick);
m_Joystick = NULL;
}
m_Gamepad = SDL_JoystickOpen(2);
m_Gamepad = SDL_JoystickOpen(2);
SDL_JoystickEventState(SDL_QUERY);
SDL_JoystickEventState(SDL_QUERY);
m_UsingGamepad = false;
m_UsingGamepad = false;
#if defined(CONF_FAMILY_UNIX)
if( getenv("OUYA") )
m_UsingGamepad = true;
if( getenv("OUYA") )
m_UsingGamepad = true;
#endif
}
else
m_Joystick = NULL;
m_UsingGamepad = false;
}
void CControls::OnReset()