11#include "SDL_haptic.h"
12#include "SDL_joystick.h"
40 for (
int i=0; i < SDL_NumJoysticks(); i++) {
41 const char *jname = SDL_JoystickNameForIndex(i);
42 if (strstr( jname, namjoystick ))
46 WARN(_(
"Joystick '%s' not found, using default joystick '%s'"),
47 namjoystick, SDL_JoystickName(0));
62 if ((indjoystick < 0) || (indjoystick >= SDL_NumJoysticks())) {
63 WARN(_(
"Joystick of index number %d does not exist, switching to default 0"),
75 joystick = SDL_JoystickOpen(indjoystick);
76 jname = SDL_JoystickNameForIndex(indjoystick);
78 WARN(_(
"Error opening joystick %d [%s]"), indjoystick, jname);
81 LOG(_(
"Using joystick %d - %s"), indjoystick, jname);
82 DEBUG(_(
" with %d axes, %d buttons, %d balls and %d hats"),
112 WARN(_(
"Unable to initialize force feedback: %s"), SDL_GetError());
124 DEBUG(_(
" force feedback enabled"));
131static void joystick_debug (
void)
134 int numjoysticks = SDL_NumJoysticks();
135 DEBUG( n_(
"%d joystick detected",
"%d joysticks detected", numjoysticks), numjoysticks );
136 for (
int i=0; i < numjoysticks; i++) {
137 const char *jname = SDL_JoystickNameForIndex(i);
138 DEBUG(
" %d. %s", i, jname);
151 if (SDL_InitSubSystem(SDL_INIT_JOYSTICK)) {
152 WARN(_(
"Unable to initialize the joystick subsystem"));
156 if (SDL_InitSubSystem(SDL_INIT_HAPTIC) == 0)
164 SDL_JoystickEventState(SDL_ENABLE);
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.
Header file with generic functions and naev-specifics.