Joystick Snippet reference for ericw

Discuss programming topics for the various GPL'd game engine sources.
Post Reply
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Joystick Snippet reference for ericw

Post by Baker »

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)) {
	} else {
		Con_SafePrintLinef ("Joystick not attached"); // Does this happen
	return false;
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
Post Reply