src/joystick/SDL_gamecontroller.c
changeset 6842 6ea07537baa2
parent 6841 90bba8d8e42a
child 6843 a52016007a7e
equal deleted inserted replaced
6841:90bba8d8e42a 6842:6ea07537baa2
    51 	SDL_JoystickGUID guid;
    51 	SDL_JoystickGUID guid;
    52 	const char *name;
    52 	const char *name;
    53 
    53 
    54 	// mapping of axis/button id to controller version
    54 	// mapping of axis/button id to controller version
    55 	int axes[SDL_CONTROLLER_AXIS_MAX];
    55 	int axes[SDL_CONTROLLER_AXIS_MAX];
       
    56 	int buttonasaxis[SDL_CONTROLLER_AXIS_MAX];
       
    57 
    56 	int buttons[SDL_CONTROLLER_BUTTON_MAX];
    58 	int buttons[SDL_CONTROLLER_BUTTON_MAX];
    57 
       
    58 	int axesasbutton[SDL_CONTROLLER_BUTTON_MAX];
    59 	int axesasbutton[SDL_CONTROLLER_BUTTON_MAX];
    59 	struct _SDL_HatAsButton hatasbutton[SDL_CONTROLLER_BUTTON_MAX];
    60 	struct _SDL_HatAsButton hatasbutton[SDL_CONTROLLER_BUTTON_MAX];
    60 	int buttonasaxis[SDL_CONTROLLER_AXIS_MAX];
       
    61 
    61 
    62 	// reverse mapping, joystick indices to buttons
    62 	// reverse mapping, joystick indices to buttons
    63 	SDL_CONTROLLER_AXIS raxes[k_nMaxReverseEntries];
    63 	SDL_CONTROLLER_AXIS raxes[k_nMaxReverseEntries];
       
    64 	SDL_CONTROLLER_AXIS rbuttonasaxis[k_nMaxReverseEntries];
       
    65 
    64 	SDL_CONTROLLER_BUTTON rbuttons[k_nMaxReverseEntries];
    66 	SDL_CONTROLLER_BUTTON rbuttons[k_nMaxReverseEntries];
    65 	SDL_CONTROLLER_BUTTON raxesasbutton[k_nMaxReverseEntries];
    67 	SDL_CONTROLLER_BUTTON raxesasbutton[k_nMaxReverseEntries];
       
    68 
    66 	struct _SDL_HatAsButton rhatasbutton[k_nMaxReverseEntries];
    69 	struct _SDL_HatAsButton rhatasbutton[k_nMaxReverseEntries];
    67 	SDL_CONTROLLER_AXIS rbuttonasaxis[k_nMaxReverseEntries];
       
    68 };
    70 };
    69 
    71 
    70 
    72 
    71 /* our hard coded list of mapping support */
    73 /* our hard coded list of mapping support */
    72 typedef struct _ControllerMapping_t
    74 typedef struct _ControllerMapping_t
   353 			pMapping->axes[ axis ] = iSDLButton;
   355 			pMapping->axes[ axis ] = iSDLButton;
   354 			pMapping->raxes[ iSDLButton ] = axis;
   356 			pMapping->raxes[ iSDLButton ] = axis;
   355 		}
   357 		}
   356 		else if ( button != SDL_CONTROLLER_BUTTON_INVALID )
   358 		else if ( button != SDL_CONTROLLER_BUTTON_INVALID )
   357 		{
   359 		{
   358 			pMapping->buttonasaxis[ button ] = iSDLButton;
   360 			pMapping->axesasbutton[ button ] = iSDLButton;
   359 			pMapping->rbuttonasaxis[ iSDLButton ] = button;
   361 			pMapping->raxesasbutton[ iSDLButton ] = button;
   360 		}
   362 		}
   361 		else
   363 		else
   362 		{
   364 		{
   363 			SDL_assert( !"How did we get here?" );
   365 			SDL_assert( !"How did we get here?" );
   364 		}
   366 		}
   492 	}
   494 	}
   493 
   495 
   494 	for ( j = 0; j < k_nMaxReverseEntries; j++ )
   496 	for ( j = 0; j < k_nMaxReverseEntries; j++ )
   495 	{
   497 	{
   496 		pMapping->raxes[j] = SDL_CONTROLLER_AXIS_INVALID;
   498 		pMapping->raxes[j] = SDL_CONTROLLER_AXIS_INVALID;
       
   499 		pMapping->rbuttonasaxis[j] = SDL_CONTROLLER_AXIS_INVALID;
   497 		pMapping->rbuttons[j] = SDL_CONTROLLER_BUTTON_INVALID;
   500 		pMapping->rbuttons[j] = SDL_CONTROLLER_BUTTON_INVALID;
   498 		pMapping->raxesasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID;
   501 		pMapping->raxesasbutton[j] = SDL_CONTROLLER_BUTTON_INVALID;
   499 		pMapping->rhatasbutton[j].hat = -1;
   502 		pMapping->rhatasbutton[j].hat = -1;
   500 		pMapping->rbuttonasaxis[j] = SDL_CONTROLLER_AXIS_INVALID;
       
   501 	}
   503 	}
   502 
   504 
   503 	SDL_PrivateGameControllerParseControllerConfigString( pMapping, pchMapping );
   505 	SDL_PrivateGameControllerParseControllerConfigString( pMapping, pchMapping );
   504 }
   506 }
   505 
   507