mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-01-19 07:30:53 +00:00
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:
parent
c0cca7a0a8
commit
dd0161f475
2 changed files with 16 additions and 6 deletions
1
README
1
README
|
@ -158,6 +158,7 @@ New cvars
|
||||||
next frame when set to non-zero value
|
next frame when set to non-zero value
|
||||||
|
|
||||||
in_joystickNo - select which joystick to use
|
in_joystickNo - select which joystick to use
|
||||||
|
in_availableJoysticks - list of available Joysticks
|
||||||
in_keyboardDebug - print keyboard debug info
|
in_keyboardDebug - print keyboard debug info
|
||||||
|
|
||||||
sv_dlURL - the base of the HTTP or FTP site that
|
sv_dlURL - the base of the HTTP or FTP site that
|
||||||
|
|
|
@ -574,6 +574,7 @@ static void IN_InitJoystick( void )
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
char buf[MAX_STRING_CHARS] = "";
|
||||||
|
|
||||||
if (stick != NULL)
|
if (stick != NULL)
|
||||||
SDL_JoystickClose(stick);
|
SDL_JoystickClose(stick);
|
||||||
|
@ -581,11 +582,6 @@ static void IN_InitJoystick( void )
|
||||||
stick = NULL;
|
stick = NULL;
|
||||||
memset(&stick_state, '\0', sizeof (stick_state));
|
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))
|
if (!SDL_WasInit(SDL_INIT_JOYSTICK))
|
||||||
{
|
{
|
||||||
Com_DPrintf("Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
|
Com_DPrintf("Calling SDL_Init(SDL_INIT_JOYSTICK)...\n");
|
||||||
|
@ -599,8 +595,21 @@ static void IN_InitJoystick( void )
|
||||||
|
|
||||||
total = SDL_NumJoysticks();
|
total = SDL_NumJoysticks();
|
||||||
Com_DPrintf("%d possible joysticks\n", total);
|
Com_DPrintf("%d possible joysticks\n", total);
|
||||||
|
|
||||||
|
// Print list and build cvar to allow ui to select joystick.
|
||||||
for (i = 0; i < total; i++)
|
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 );
|
in_joystickNo = Cvar_Get( "in_joystickNo", "0", CVAR_ARCHIVE );
|
||||||
if( in_joystickNo->integer < 0 || in_joystickNo->integer >= total )
|
if( in_joystickNo->integer < 0 || in_joystickNo->integer >= total )
|
||||||
|
|
Loading…
Reference in a new issue