|
|
@ -111,12 +111,12 @@ static int SDLash_JoyInit_Old( int numjoy ) |
|
|
|
int num; |
|
|
|
int num; |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
MsgDev( D_INFO, "Joystick: SDL\n" ); |
|
|
|
Con_Reportf( "Joystick: SDL\n" ); |
|
|
|
|
|
|
|
|
|
|
|
if( SDL_WasInit( SDL_INIT_JOYSTICK ) != SDL_INIT_JOYSTICK && |
|
|
|
if( SDL_WasInit( SDL_INIT_JOYSTICK ) != SDL_INIT_JOYSTICK && |
|
|
|
SDL_InitSubSystem( SDL_INIT_JOYSTICK ) ) |
|
|
|
SDL_InitSubSystem( SDL_INIT_JOYSTICK ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MsgDev( D_INFO, "Failed to initialize SDL Joysitck: %s\n", SDL_GetError() ); |
|
|
|
Con_Reportf( "Failed to initialize SDL Joysitck: %s\n", SDL_GetError() ); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -128,27 +128,27 @@ static int SDLash_JoyInit_Old( int numjoy ) |
|
|
|
num = SDL_NumJoysticks(); |
|
|
|
num = SDL_NumJoysticks(); |
|
|
|
|
|
|
|
|
|
|
|
if( num > 0 ) |
|
|
|
if( num > 0 ) |
|
|
|
MsgDev( D_INFO, "%i joysticks found:\n", num ); |
|
|
|
Con_Reportf( "%i joysticks found:\n", num ); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
MsgDev( D_INFO, "No joystick found.\n" ); |
|
|
|
Con_Reportf( "No joystick found.\n" ); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < num; i++ ) |
|
|
|
for( i = 0; i < num; i++ ) |
|
|
|
MsgDev( D_INFO, "%i\t: %s\n", i, SDL_JoystickNameForIndex( i ) ); |
|
|
|
Con_Reportf( "%i\t: %s\n", i, SDL_JoystickNameForIndex( i ) ); |
|
|
|
|
|
|
|
|
|
|
|
MsgDev( D_INFO, "Pass +set joy_index N to command line, where N is number, to select active joystick\n" ); |
|
|
|
Con_Reportf( "Pass +set joy_index N to command line, where N is number, to select active joystick\n" ); |
|
|
|
|
|
|
|
|
|
|
|
joy = SDL_JoystickOpen( numjoy ); |
|
|
|
joy = SDL_JoystickOpen( numjoy ); |
|
|
|
|
|
|
|
|
|
|
|
if( !joy ) |
|
|
|
if( !joy ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MsgDev( D_INFO, "Failed to select joystick: %s\n", SDL_GetError( ) ); |
|
|
|
Con_Reportf( "Failed to select joystick: %s\n", SDL_GetError( ) ); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
MsgDev( D_INFO, "Selected joystick: %s\n" |
|
|
|
Con_Reportf( "Selected joystick: %s\n" |
|
|
|
"\tAxes: %i\n" |
|
|
|
"\tAxes: %i\n" |
|
|
|
"\tHats: %i\n" |
|
|
|
"\tHats: %i\n" |
|
|
|
"\tButtons: %i\n" |
|
|
|
"\tButtons: %i\n" |
|
|
@ -173,12 +173,12 @@ static int SDLash_JoyInit_New( int numjoy ) |
|
|
|
int temp, num; |
|
|
|
int temp, num; |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
|
|
MsgDev( D_INFO, "Joystick: SDL GameController API\n" ); |
|
|
|
Con_Reportf( "Joystick: SDL GameController API\n" ); |
|
|
|
|
|
|
|
|
|
|
|
if( SDL_WasInit( SDL_INIT_GAMECONTROLLER ) != SDL_INIT_GAMECONTROLLER && |
|
|
|
if( SDL_WasInit( SDL_INIT_GAMECONTROLLER ) != SDL_INIT_GAMECONTROLLER && |
|
|
|
SDL_InitSubSystem( SDL_INIT_GAMECONTROLLER ) ) |
|
|
|
SDL_InitSubSystem( SDL_INIT_GAMECONTROLLER ) ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MsgDev( D_INFO, "Failed to initialize SDL GameController API: %s\n", SDL_GetError() ); |
|
|
|
Con_Reportf( "Failed to initialize SDL GameController API: %s\n", SDL_GetError() ); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -200,28 +200,28 @@ static int SDLash_JoyInit_New( int numjoy ) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if( num > 0 ) |
|
|
|
if( num > 0 ) |
|
|
|
MsgDev( D_INFO, "%i joysticks found:\n", num ); |
|
|
|
Con_Reportf( "%i joysticks found:\n", num ); |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
MsgDev( D_INFO, "No joystick found.\n" ); |
|
|
|
Con_Reportf( "No joystick found.\n" ); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for( i = 0; i < num; i++ ) |
|
|
|
for( i = 0; i < num; i++ ) |
|
|
|
MsgDev( D_INFO, "%i\t: %s\n", i, SDL_GameControllerNameForIndex( i ) ); |
|
|
|
Con_Reportf( "%i\t: %s\n", i, SDL_GameControllerNameForIndex( i ) ); |
|
|
|
|
|
|
|
|
|
|
|
MsgDev( D_INFO, "Pass +set joy_index N to command line, where N is number, to select active joystick\n" ); |
|
|
|
Con_Reportf( "Pass +set joy_index N to command line, where N is number, to select active joystick\n" ); |
|
|
|
|
|
|
|
|
|
|
|
gamecontroller = SDL_GameControllerOpen( numjoy ); |
|
|
|
gamecontroller = SDL_GameControllerOpen( numjoy ); |
|
|
|
|
|
|
|
|
|
|
|
if( !gamecontroller ) |
|
|
|
if( !gamecontroller ) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MsgDev( D_INFO, "Failed to select joystick: %s\n", SDL_GetError( ) ); |
|
|
|
Con_Reportf( "Failed to select joystick: %s\n", SDL_GetError( ) ); |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
// was added in SDL2-2.0.6, allow build with earlier versions just in case
|
|
|
|
// was added in SDL2-2.0.6, allow build with earlier versions just in case
|
|
|
|
#if SDL_MAJOR_VERSION > 2 || SDL_MINOR_VERSION > 0 || SDL_PATCHLEVEL >= 6 |
|
|
|
#if SDL_MAJOR_VERSION > 2 || SDL_MINOR_VERSION > 0 || SDL_PATCHLEVEL >= 6 |
|
|
|
MsgDev( D_INFO, "Selected joystick: %s (%i:%i:%i)\n", |
|
|
|
Con_Reportf( "Selected joystick: %s (%i:%i:%i)\n", |
|
|
|
SDL_GameControllerName( gamecontroller ), |
|
|
|
SDL_GameControllerName( gamecontroller ), |
|
|
|
SDL_GameControllerGetVendor( gamecontroller ), |
|
|
|
SDL_GameControllerGetVendor( gamecontroller ), |
|
|
|
SDL_GameControllerGetProduct( gamecontroller ), |
|
|
|
SDL_GameControllerGetProduct( gamecontroller ), |
|
|
|