mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-02 18:07:40 +00:00
SDL now represents gamepad buttons as positional elements with a separate label
This gives applications and binding systems a clearer view of what the hardware is so they can make intelligent decisions about how to present things to the user. Gamepad mappings continue to use abxy for the face buttons for simplicity and compatibility with earlier versions of SDL, however the "SDL_GAMECONTROLLER_USE_BUTTON_LABELS" hint no longer has any effect. Fixes https://github.com/libsdl-org/SDL/issues/6117
This commit is contained in:
parent
8708ba7393
commit
2991b9f6ac
32 changed files with 852 additions and 611 deletions
|
@ -81,10 +81,10 @@ typedef enum
|
|||
typedef enum
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_INVALID = -1,
|
||||
SDL_GAMEPAD_BUTTON_A,
|
||||
SDL_GAMEPAD_BUTTON_B,
|
||||
SDL_GAMEPAD_BUTTON_X,
|
||||
SDL_GAMEPAD_BUTTON_Y,
|
||||
SDL_GAMEPAD_BUTTON_SOUTH,
|
||||
SDL_GAMEPAD_BUTTON_EAST,
|
||||
SDL_GAMEPAD_BUTTON_WEST,
|
||||
SDL_GAMEPAD_BUTTON_NORTH,
|
||||
SDL_GAMEPAD_BUTTON_BACK,
|
||||
SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
SDL_GAMEPAD_BUTTON_START,
|
||||
|
@ -105,6 +105,26 @@ typedef enum
|
|||
SDL_GAMEPAD_BUTTON_MAX
|
||||
} SDL_GamepadButton;
|
||||
|
||||
/**
|
||||
* The set of gamepad button labels
|
||||
*
|
||||
* This isn't a complete set, just the face buttons to make it easy to show button prompts.
|
||||
*
|
||||
* For a complete set, you should look at the button and gamepad type and have a set of symbols that work well with your art style.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
SDL_GAMEPAD_BUTTON_LABEL_UNKNOWN,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_A, /**< The south button for Xbox controllers, the east button for Nintendo controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_B, /**< The east button for Xbox controllers, the south button for Nintendo controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_X, /**< The west button for Xbox controllers, the north button for Nintendo controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_Y, /**< The north button for Xbox controllers, the west button for Nintendo controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_CROSS, /**< The south button for Playstation controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_CIRCLE, /**< The east button for Playstation controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_SQUARE, /**< The west button for Playstation controllers */
|
||||
SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE /**< The north button for Playstation controllers */
|
||||
} SDL_GamepadButtonLabel;
|
||||
|
||||
/**
|
||||
* The list of axes available on a gamepad
|
||||
*
|
||||
|
@ -990,6 +1010,32 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasButton(SDL_Gamepad *gamepad, SDL_
|
|||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_GamepadButton button);
|
||||
|
||||
/**
|
||||
* Get the label of a button on a gamepad.
|
||||
*
|
||||
* \param type the type of gamepad to check
|
||||
* \param button a button index (one of the SDL_GamepadButton values)
|
||||
* \returns the SDL_GamepadButtonLabel enum corresponding to the button label
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetGamepadButtonLabel
|
||||
*/
|
||||
extern DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabelForType(SDL_GamepadType type, SDL_GamepadButton button);
|
||||
|
||||
/**
|
||||
* Get the label of a button on a gamepad.
|
||||
*
|
||||
* \param gamepad a gamepad
|
||||
* \param button a button index (one of the SDL_GamepadButton values)
|
||||
* \returns the SDL_GamepadButtonLabel enum corresponding to the button label
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetGamepadButtonLabelForType
|
||||
*/
|
||||
extern DECLSPEC SDL_GamepadButtonLabel SDLCALL SDL_GetGamepadButtonLabel(SDL_Gamepad *gamepad, SDL_GamepadButton button);
|
||||
|
||||
/**
|
||||
* Get the number of touchpads on a gamepad.
|
||||
*
|
||||
|
|
|
@ -537,29 +537,6 @@ extern "C" {
|
|||
*/
|
||||
#define SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT "SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT"
|
||||
|
||||
/**
|
||||
* If set, game controller face buttons report their values according to their labels instead of their positional layout.
|
||||
*
|
||||
* For example, on Nintendo Switch controllers, normally you'd get:
|
||||
*
|
||||
* (Y)
|
||||
* (X) (B)
|
||||
* (A)
|
||||
*
|
||||
* but if this hint is set, you'll get:
|
||||
*
|
||||
* (X)
|
||||
* (Y) (A)
|
||||
* (B)
|
||||
*
|
||||
* The variable can be set to the following values:
|
||||
* "0" - Report the face buttons by position, as though they were on an Xbox controller.
|
||||
* "1" - Report the face buttons by label instead of position
|
||||
*
|
||||
* The default value is "1". This hint may be set at any time.
|
||||
*/
|
||||
#define SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS "SDL_GAMECONTROLLER_USE_BUTTON_LABELS"
|
||||
|
||||
/**
|
||||
* Controls whether the device's built-in accelerometer and gyro should be used as sensors for gamepads.
|
||||
*
|
||||
|
|
|
@ -343,7 +343,7 @@ typedef struct SDL_VirtualJoystickDesc
|
|||
Uint16 product_id; /**< the USB product ID of this joystick */
|
||||
Uint16 padding; /**< unused */
|
||||
Uint32 button_mask; /**< A mask of which buttons are valid for this controller
|
||||
e.g. (1 << SDL_GAMEPAD_BUTTON_A) */
|
||||
e.g. (1 << SDL_GAMEPAD_BUTTON_SOUTH) */
|
||||
Uint32 axis_mask; /**< A mask of which axes are valid for this controller
|
||||
e.g. (1 << SDL_GAMEPAD_AXIS_LEFTX) */
|
||||
const char *name; /**< the name of the joystick */
|
||||
|
|
|
@ -160,8 +160,8 @@
|
|||
#define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_GAMEPAD_BINDTYPE_BUTTON
|
||||
#define SDL_CONTROLLER_BINDTYPE_HAT SDL_GAMEPAD_BINDTYPE_HAT
|
||||
#define SDL_CONTROLLER_BINDTYPE_NONE SDL_GAMEPAD_BINDTYPE_NONE
|
||||
#define SDL_CONTROLLER_BUTTON_A SDL_GAMEPAD_BUTTON_A
|
||||
#define SDL_CONTROLLER_BUTTON_B SDL_GAMEPAD_BUTTON_B
|
||||
#define SDL_CONTROLLER_BUTTON_A SDL_GAMEPAD_BUTTON_SOUTH
|
||||
#define SDL_CONTROLLER_BUTTON_B SDL_GAMEPAD_BUTTON_EAST
|
||||
#define SDL_CONTROLLER_BUTTON_BACK SDL_GAMEPAD_BUTTON_BACK
|
||||
#define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_GAMEPAD_BUTTON_DPAD_DOWN
|
||||
#define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_GAMEPAD_BUTTON_DPAD_LEFT
|
||||
|
@ -181,8 +181,8 @@
|
|||
#define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_GAMEPAD_BUTTON_RIGHT_STICK
|
||||
#define SDL_CONTROLLER_BUTTON_START SDL_GAMEPAD_BUTTON_START
|
||||
#define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_GAMEPAD_BUTTON_TOUCHPAD
|
||||
#define SDL_CONTROLLER_BUTTON_X SDL_GAMEPAD_BUTTON_X
|
||||
#define SDL_CONTROLLER_BUTTON_Y SDL_GAMEPAD_BUTTON_Y
|
||||
#define SDL_CONTROLLER_BUTTON_X SDL_GAMEPAD_BUTTON_WEST
|
||||
#define SDL_CONTROLLER_BUTTON_Y SDL_GAMEPAD_BUTTON_NORTH
|
||||
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
|
||||
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
|
||||
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
|
||||
|
@ -603,8 +603,8 @@
|
|||
#define SDL_CONTROLLER_BINDTYPE_BUTTON SDL_CONTROLLER_BINDTYPE_BUTTON_renamed_SDL_GAMEPAD_BINDTYPE_BUTTON
|
||||
#define SDL_CONTROLLER_BINDTYPE_HAT SDL_CONTROLLER_BINDTYPE_HAT_renamed_SDL_GAMEPAD_BINDTYPE_HAT
|
||||
#define SDL_CONTROLLER_BINDTYPE_NONE SDL_CONTROLLER_BINDTYPE_NONE_renamed_SDL_GAMEPAD_BINDTYPE_NONE
|
||||
#define SDL_CONTROLLER_BUTTON_A SDL_CONTROLLER_BUTTON_A_renamed_SDL_GAMEPAD_BUTTON_A
|
||||
#define SDL_CONTROLLER_BUTTON_B SDL_CONTROLLER_BUTTON_B_renamed_SDL_GAMEPAD_BUTTON_B
|
||||
#define SDL_CONTROLLER_BUTTON_A SDL_CONTROLLER_BUTTON_A_renamed_SDL_GAMEPAD_BUTTON_SOUTH
|
||||
#define SDL_CONTROLLER_BUTTON_B SDL_CONTROLLER_BUTTON_B_renamed_SDL_GAMEPAD_BUTTON_EAST
|
||||
#define SDL_CONTROLLER_BUTTON_BACK SDL_CONTROLLER_BUTTON_BACK_renamed_SDL_GAMEPAD_BUTTON_BACK
|
||||
#define SDL_CONTROLLER_BUTTON_DPAD_DOWN SDL_CONTROLLER_BUTTON_DPAD_DOWN_renamed_SDL_GAMEPAD_BUTTON_DPAD_DOWN
|
||||
#define SDL_CONTROLLER_BUTTON_DPAD_LEFT SDL_CONTROLLER_BUTTON_DPAD_LEFT_renamed_SDL_GAMEPAD_BUTTON_DPAD_LEFT
|
||||
|
@ -624,8 +624,8 @@
|
|||
#define SDL_CONTROLLER_BUTTON_RIGHTSTICK SDL_CONTROLLER_BUTTON_RIGHTSTICK_renamed_SDL_GAMEPAD_BUTTON_RIGHT_STICK
|
||||
#define SDL_CONTROLLER_BUTTON_START SDL_CONTROLLER_BUTTON_START_renamed_SDL_GAMEPAD_BUTTON_START
|
||||
#define SDL_CONTROLLER_BUTTON_TOUCHPAD SDL_CONTROLLER_BUTTON_TOUCHPAD_renamed_SDL_GAMEPAD_BUTTON_TOUCHPAD
|
||||
#define SDL_CONTROLLER_BUTTON_X SDL_CONTROLLER_BUTTON_X_renamed_SDL_GAMEPAD_BUTTON_X
|
||||
#define SDL_CONTROLLER_BUTTON_Y SDL_CONTROLLER_BUTTON_Y_renamed_SDL_GAMEPAD_BUTTON_Y
|
||||
#define SDL_CONTROLLER_BUTTON_X SDL_CONTROLLER_BUTTON_X_renamed_SDL_GAMEPAD_BUTTON_WEST
|
||||
#define SDL_CONTROLLER_BUTTON_Y SDL_CONTROLLER_BUTTON_Y_renamed_SDL_GAMEPAD_BUTTON_NORTH
|
||||
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_LEFT
|
||||
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
|
||||
#define SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT_renamed_SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue