Add in_availableJoysticks to list usable joysticks, similar to s_alAvailableDevices. Some parts of the patch provided by Zack Middleton

This commit is contained in:
Thilo Schulz 2011-03-07 22:56:03 +00:00
parent c0cca7a0a8
commit dd0161f475
2 changed files with 16 additions and 6 deletions

1
README
View File

@ -158,6 +158,7 @@ New cvars
next frame when set to non-zero value
in_joystickNo - select which joystick to use
in_availableJoysticks - list of available Joysticks
in_keyboardDebug - print keyboard debug info
sv_dlURL - the base of the HTTP or FTP site that

View File

@ -574,6 +574,7 @@ static void IN_InitJoystick( void )
{
int i = 0;
int total = 0;
char buf[MAX_STRING_CHARS] = "";
if (stick != NULL)
SDL_JoystickClose(stick);
@ -581,11 +582,6 @@ static void IN_InitJoystick( void )
stick = NULL;
memset(&stick_state, '\0', sizeof (stick_state));
if( !in_joystick->integer ) {
Com_DPrintf( "Joystick is not active.\n" );
return;
}
if (!SDL_WasInit(SDL_INIT_JOYSTICK))
{
Com_DPrintf("Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
@ -599,8 +595,21 @@ static void IN_InitJoystick( void )
total = SDL_NumJoysticks();
Com_DPrintf("%d possible joysticks\n", total);
// Print list and build cvar to allow ui to select joystick.
for (i = 0; i < total; i++)
Com_DPrintf("[%d] %s\n", i, SDL_JoystickName(i));
{
Q_strcat(buf, sizeof(buf), SDL_JoystickName(i));
Q_strcat(buf, sizeof(buf), "\n");
}
Cvar_Get( "in_availableJoysticks", buf, CVAR_ROM );
if( !in_joystick->integer ) {
Com_DPrintf( "Joystick is not active.\n" );
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
return;
}
in_joystickNo = Cvar_Get( "in_joystickNo", "0", CVAR_ARCHIVE );
if( in_joystickNo->integer < 0 || in_joystickNo->integer >= total )