Changed the game controller enum types to match SDL naming conventions.
This commit is contained in:
parent
db73a392c2
commit
a5862a96a3
4 changed files with 32 additions and 31 deletions
|
@ -314,7 +314,7 @@ typedef struct SDL_ControllerAxisEvent
|
|||
Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
SDL_CONTROLLER_AXIS axis; /**< The joystick axis index */
|
||||
SDL_GameControllerAxis axis; /**< The joystick axis index */
|
||||
int value; /**< The axis value (range: -32768 to 32767) */
|
||||
} SDL_ControllerAxisEvent;
|
||||
|
||||
|
@ -327,7 +327,7 @@ typedef struct SDL_ControllerButtonEvent
|
|||
Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
SDL_CONTROLLER_BUTTON button; /**< The joystick button index */
|
||||
SDL_GameControllerButton button; /**< The joystick button index */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
} SDL_ControllerButtonEvent;
|
||||
|
||||
|
|
|
@ -59,7 +59,8 @@ typedef enum
|
|||
SDL_CONTROLLER_BINDTYPE_BUTTON,
|
||||
SDL_CONTROLLER_BINDTYPE_AXIS,
|
||||
SDL_CONTROLLER_BINDTYPE_HAT
|
||||
} SDL_CONTROLLER_BINDTYPE;
|
||||
} SDL_GameControllerBindType;
|
||||
|
||||
/**
|
||||
* get the sdl joystick layer binding for this controller button/axis mapping
|
||||
*/
|
||||
|
@ -71,7 +72,7 @@ struct _SDL_GameControllerHatBind
|
|||
|
||||
typedef struct _SDL_GameControllerButtonBind
|
||||
{
|
||||
SDL_CONTROLLER_BINDTYPE m_eBindType;
|
||||
SDL_GameControllerBindType m_eBindType;
|
||||
union
|
||||
{
|
||||
int button;
|
||||
|
@ -172,19 +173,19 @@ typedef enum
|
|||
SDL_CONTROLLER_AXIS_TRIGGERLEFT,
|
||||
SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
|
||||
SDL_CONTROLLER_AXIS_MAX
|
||||
} SDL_CONTROLLER_AXIS;
|
||||
} SDL_GameControllerAxis;
|
||||
|
||||
/**
|
||||
* turn this string into a axis mapping
|
||||
*/
|
||||
extern DECLSPEC SDL_CONTROLLER_AXIS SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
|
||||
extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
|
||||
|
||||
/**
|
||||
* get the sdl joystick layer binding for this controller button mapping
|
||||
*/
|
||||
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
|
||||
SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
|
||||
SDL_CONTROLLER_AXIS button);
|
||||
SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* Get the current state of an axis control on a game controller.
|
||||
|
@ -195,7 +196,7 @@ SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
|
|||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL
|
||||
SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
|
||||
SDL_CONTROLLER_AXIS axis);
|
||||
SDL_GameControllerAxis axis);
|
||||
|
||||
/**
|
||||
* The list of buttons available from a controller
|
||||
|
@ -219,12 +220,12 @@ typedef enum
|
|||
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
||||
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
|
||||
SDL_CONTROLLER_BUTTON_MAX
|
||||
} SDL_CONTROLLER_BUTTON;
|
||||
} SDL_GameControllerButton;
|
||||
|
||||
/**
|
||||
* turn this string into a button mapping
|
||||
*/
|
||||
extern DECLSPEC SDL_CONTROLLER_BUTTON SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
|
||||
extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -232,7 +233,7 @@ extern DECLSPEC SDL_CONTROLLER_BUTTON SDLCALL SDL_GameControllerGetButtonFromStr
|
|||
*/
|
||||
extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
|
||||
SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
|
||||
SDL_CONTROLLER_BUTTON button);
|
||||
SDL_GameControllerButton button);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -241,7 +242,7 @@ SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
|
|||
* The button indices start at index 0.
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
|
||||
SDL_CONTROLLER_BUTTON button);
|
||||
SDL_GameControllerButton button);
|
||||
|
||||
/**
|
||||
* Close a controller previously opened with SDL_GameControllerOpen().
|
||||
|
|
|
@ -64,12 +64,12 @@ struct _SDL_ControllerMapping
|
|||
struct _SDL_HatMapping hatasbutton[SDL_CONTROLLER_BUTTON_MAX];
|
||||
|
||||
// reverse mapping, joystick indices to buttons
|
||||
SDL_CONTROLLER_AXIS raxes[k_nMaxReverseEntries];
|
||||
SDL_CONTROLLER_AXIS rbuttonasaxis[k_nMaxReverseEntries];
|
||||
SDL_GameControllerAxis raxes[k_nMaxReverseEntries];
|
||||
SDL_GameControllerAxis rbuttonasaxis[k_nMaxReverseEntries];
|
||||
|
||||
SDL_CONTROLLER_BUTTON rbuttons[k_nMaxReverseEntries];
|
||||
SDL_CONTROLLER_BUTTON raxesasbutton[k_nMaxReverseEntries];
|
||||
SDL_CONTROLLER_BUTTON rhatasbutton[k_nMaxHatEntries];
|
||||
SDL_GameControllerButton rbuttons[k_nMaxReverseEntries];
|
||||
SDL_GameControllerButton raxesasbutton[k_nMaxReverseEntries];
|
||||
SDL_GameControllerButton rhatasbutton[k_nMaxHatEntries];
|
||||
|
||||
};
|
||||
|
||||
|
@ -118,8 +118,8 @@ struct _SDL_GameController
|
|||
};
|
||||
|
||||
|
||||
int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_CONTROLLER_AXIS axis, Sint16 value);
|
||||
int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_CONTROLLER_BUTTON button, Uint8 state);
|
||||
int SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value);
|
||||
int SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state);
|
||||
|
||||
/*
|
||||
* Event filter to fire controller events from joystick ones
|
||||
|
@ -296,7 +296,7 @@ ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index)
|
|||
/*
|
||||
* convert a string to its enum equivalent
|
||||
*/
|
||||
SDL_CONTROLLER_AXIS SDL_GameControllerGetAxisFromString( const char *pchString )
|
||||
SDL_GameControllerAxis SDL_GameControllerGetAxisFromString( const char *pchString )
|
||||
{
|
||||
if ( !pchString || !pchString[0] )
|
||||
return SDL_CONTROLLER_AXIS_INVALID;
|
||||
|
@ -321,7 +321,7 @@ SDL_CONTROLLER_AXIS SDL_GameControllerGetAxisFromString( const char *pchString )
|
|||
/*
|
||||
* convert a string to its enum equivalent
|
||||
*/
|
||||
SDL_CONTROLLER_BUTTON SDL_GameControllerGetButtonFromString( const char *pchString )
|
||||
SDL_GameControllerButton SDL_GameControllerGetButtonFromString( const char *pchString )
|
||||
{
|
||||
if ( !pchString || !pchString[0] )
|
||||
return SDL_CONTROLLER_BUTTON_INVALID;
|
||||
|
@ -367,8 +367,8 @@ SDL_CONTROLLER_BUTTON SDL_GameControllerGetButtonFromString( const char *pchStri
|
|||
void SDL_PrivateGameControllerParseButton( const char *szGameButton, const char *szJoystickButton, struct _SDL_ControllerMapping *pMapping )
|
||||
{
|
||||
int iSDLButton = 0;
|
||||
SDL_CONTROLLER_BUTTON button;
|
||||
SDL_CONTROLLER_AXIS axis;
|
||||
SDL_GameControllerButton button;
|
||||
SDL_GameControllerAxis axis;
|
||||
button = SDL_GameControllerGetButtonFromString( szGameButton );
|
||||
axis = SDL_GameControllerGetAxisFromString( szGameButton );
|
||||
iSDLButton = SDL_atoi( &szJoystickButton[1] );
|
||||
|
@ -829,7 +829,7 @@ SDL_GameControllerOpen(int device_index)
|
|||
* Get the current state of an axis control on a controller
|
||||
*/
|
||||
Sint16
|
||||
SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_CONTROLLER_AXIS axis)
|
||||
SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis)
|
||||
{
|
||||
if ( !gamecontroller )
|
||||
return 0;
|
||||
|
@ -854,7 +854,7 @@ SDL_GameControllerGetAxis(SDL_GameController * gamecontroller, SDL_CONTROLLER_AX
|
|||
* Get the current state of a button on a controller
|
||||
*/
|
||||
Uint8
|
||||
SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_CONTROLLER_BUTTON button)
|
||||
SDL_GameControllerGetButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
|
||||
{
|
||||
if ( !gamecontroller )
|
||||
return 0;
|
||||
|
@ -925,7 +925,7 @@ SDL_Joystick *SDL_GameControllerGetJoystick(SDL_GameController * gamecontroller)
|
|||
/**
|
||||
* get the sdl joystick layer binding for this controller axi mapping
|
||||
*/
|
||||
SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis( SDL_GameController * gamecontroller, SDL_CONTROLLER_AXIS axis )
|
||||
SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis)
|
||||
{
|
||||
SDL_GameControllerButtonBind bind;
|
||||
SDL_memset( &bind, 0x0, sizeof(bind) );
|
||||
|
@ -951,7 +951,7 @@ SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis( SDL_GameControlle
|
|||
/**
|
||||
* get the sdl joystick layer binding for this controller button mapping
|
||||
*/
|
||||
SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton( SDL_GameController * gamecontroller, SDL_CONTROLLER_BUTTON button )
|
||||
SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button)
|
||||
{
|
||||
SDL_GameControllerButtonBind bind;
|
||||
SDL_memset( &bind, 0x0, sizeof(bind) );
|
||||
|
@ -1053,7 +1053,7 @@ SDL_GameControllerQuit(void)
|
|||
* Event filter to transform joystick events into appropriate game controller ones
|
||||
*/
|
||||
int
|
||||
SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_CONTROLLER_AXIS axis, Sint16 value)
|
||||
SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_GameControllerAxis axis, Sint16 value)
|
||||
{
|
||||
int posted;
|
||||
|
||||
|
@ -1077,7 +1077,7 @@ SDL_PrivateGameControllerAxis(SDL_GameController * gamecontroller, SDL_CONTROLLE
|
|||
* Event filter to transform joystick events into appropriate game controller ones
|
||||
*/
|
||||
int
|
||||
SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_CONTROLLER_BUTTON button, Uint8 state)
|
||||
SDL_PrivateGameControllerButton(SDL_GameController * gamecontroller, SDL_GameControllerButton button, Uint8 state)
|
||||
{
|
||||
int posted;
|
||||
#if !SDL_EVENTS_DISABLED
|
||||
|
|
|
@ -41,7 +41,7 @@ DrawRect(SDL_Renderer *r, const int x, const int y, const int w, const int h)
|
|||
}
|
||||
|
||||
static const char *
|
||||
ControllerAxisName(const SDL_CONTROLLER_AXIS axis)
|
||||
ControllerAxisName(const SDL_GameControllerAxis axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ ControllerAxisName(const SDL_CONTROLLER_AXIS axis)
|
|||
}
|
||||
|
||||
static const char *
|
||||
ControllerButtonName(const SDL_CONTROLLER_BUTTON button)
|
||||
ControllerButtonName(const SDL_GameControllerButton button)
|
||||
{
|
||||
switch (button)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue