11#include "SDL_haptic.h"
12#include "SDL_joystick.h"
37 for (
int i = 0; i < SDL_NumJoysticks(); i++ ) {
38 const char *jname = SDL_JoystickNameForIndex( i );
39 if ( strstr( jname, namjoystick ) )
43 WARN( _(
"Joystick '%s' not found, using default joystick '%s'" ),
44 namjoystick, SDL_JoystickName( 0 ) );
59 if ( ( indjoystick < 0 ) || ( indjoystick >= SDL_NumJoysticks() ) ) {
60 WARN( _(
"Joystick of index number %d does not exist, switching to "
73 joystick = SDL_JoystickOpen( indjoystick );
74 jname = SDL_JoystickNameForIndex( indjoystick );
76 WARN( _(
"Error opening joystick %d [%s]" ), indjoystick, jname );
79 LOG( _(
"Using joystick %d - %s" ), indjoystick, jname );
80 DEBUG( _(
" with %d axes, %d buttons, %d balls and %d hats" ),
103 SDL_HapticClose(
haptic );
110 WARN( _(
"Unable to initialize force feedback: %s" ), SDL_GetError() );
117 SDL_HapticClose(
haptic );
122 DEBUG( _(
" force feedback enabled" ) );
129static void joystick_debug(
void )
132 int numjoysticks = SDL_NumJoysticks();
133 DEBUG( n_(
"%d joystick detected",
"%d joysticks detected", numjoysticks ),
135 for (
int i = 0; i < numjoysticks; i++ ) {
136 const char *jname = SDL_JoystickNameForIndex( i );
137 DEBUG(
" %d. %s", i, jname );
150 if ( SDL_InitSubSystem( SDL_INIT_JOYSTICK ) ) {
151 WARN( _(
"Unable to initialize the joystick subsystem" ) );
155 if ( SDL_InitSubSystem( SDL_INIT_HAPTIC ) == 0 )
163 SDL_JoystickEventState( SDL_ENABLE );
174 SDL_HapticClose(
haptic );
int joystick_get(const char *namjoystick)
Gets the joystick index by name.
int joystick_init(void)
Initializes the joystick subsystem.
static SDL_Joystick * joystick
unsigned int haptic_query
int joystick_use(int indjoystick)
Makes the game use a joystick by index.
static void joystick_initHaptic(void)
Initializes force feedback for the loaded device.
void joystick_exit(void)
Exits the joystick subsystem.