Code: Select all
static cbool IN_Joystick_Consider_Opened (SDL_Joystick *joy_consider)
{ DEBUG_ASSERT (!joy_active_controller); {
int buttons = SDL_JoystickNumButtons(joy_consider);
const char *joyname = SDL_JoystickName (joy_consider);
if (buttons >= 4) {
// Set the 3 variables
joy_active_controller = joy_consider;
joy_active_instance_idx = SDL_JoystickInstanceID(joy_consider);
c_strlcpy (joy_active_name, joy_active_name);
Con_SafePrintLinef ("Controller detected: " QUOTED_S " with instance id %d", joy_active_name, joy_active_instance_idx);
return true;
}
Con_WarningLinef ("Ignoring controller due to lack of buttons: %s", joyname != NULL ? joyname : "NULL");
if (SDL_JoystickGetAttached(joy_consider)) {
SDL_JoystickClose(joy_consider);
} else {
Con_SafePrintLinef ("Joystick not attached"); // Does this happen
}
return false;
}}