forked from Green-Sky/tomato
Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
155
external/sdl/SDL/include/SDL3/SDL_gamepad.h
vendored
155
external/sdl/SDL/include/SDL3/SDL_gamepad.h
vendored
@ -1,6 +1,6 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -22,7 +22,7 @@
|
||||
/**
|
||||
* \file SDL_gamepad.h
|
||||
*
|
||||
* \brief Include file for SDL gamepad event handling
|
||||
* Include file for SDL gamepad event handling
|
||||
*/
|
||||
|
||||
#ifndef SDL_gamepad_h_
|
||||
@ -30,9 +30,10 @@
|
||||
|
||||
#include <SDL3/SDL_stdinc.h>
|
||||
#include <SDL3/SDL_error.h>
|
||||
#include <SDL3/SDL_joystick.h>
|
||||
#include <SDL3/SDL_properties.h>
|
||||
#include <SDL3/SDL_rwops.h>
|
||||
#include <SDL3/SDL_sensor.h>
|
||||
#include <SDL3/SDL_joystick.h>
|
||||
|
||||
#include <SDL3/SDL_begin_code.h>
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
@ -76,14 +77,31 @@ typedef enum
|
||||
|
||||
/**
|
||||
* The list of buttons available on a gamepad
|
||||
*
|
||||
* For controllers that use a diamond pattern for the face buttons,
|
||||
* the south/east/west/north buttons below correspond to the locations
|
||||
* in the diamond pattern. For Xbox controllers, this would be A/B/X/Y,
|
||||
* for Nintendo Switch controllers, this would be B/A/Y/X, for
|
||||
* PlayStation controllers this would be Cross/Circle/Square/Triangle.
|
||||
*
|
||||
* For controllers that don't use a diamond pattern for the face buttons,
|
||||
* the south/east/west/north buttons indicate the buttons labeled A, B,
|
||||
* C, D, or 1, 2, 3, 4, or for controllers that aren't labeled, they are
|
||||
* the primary, secondary, etc. buttons.
|
||||
*
|
||||
* The activate action is often the south button and the cancel action
|
||||
* is often the east button, but in some regions this is reversed, so
|
||||
* your game should allow remapping actions based on user preferences.
|
||||
*
|
||||
* You can query the labels for the face buttons using SDL_GetGamepadButtonLabel()
|
||||
*/
|
||||
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, /* Bottom face button (e.g. Xbox A button) */
|
||||
SDL_GAMEPAD_BUTTON_EAST, /* Right face button (e.g. Xbox B button) */
|
||||
SDL_GAMEPAD_BUTTON_WEST, /* Left face button (e.g. Xbox X button) */
|
||||
SDL_GAMEPAD_BUTTON_NORTH, /* Top face button (e.g. Xbox Y button) */
|
||||
SDL_GAMEPAD_BUTTON_BACK,
|
||||
SDL_GAMEPAD_BUTTON_GUIDE,
|
||||
SDL_GAMEPAD_BUTTON_START,
|
||||
@ -95,15 +113,35 @@ typedef enum
|
||||
SDL_GAMEPAD_BUTTON_DPAD_DOWN,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_LEFT,
|
||||
SDL_GAMEPAD_BUTTON_DPAD_RIGHT,
|
||||
SDL_GAMEPAD_BUTTON_MISC1, /* Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button) */
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /* Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */
|
||||
SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /* Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /* Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */
|
||||
SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /* Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */
|
||||
SDL_GAMEPAD_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
|
||||
SDL_GAMEPAD_BUTTON_MISC1, /* Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button) */
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1, /* Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1) */
|
||||
SDL_GAMEPAD_BUTTON_LEFT_PADDLE1, /* Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3) */
|
||||
SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2, /* Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2) */
|
||||
SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, /* Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4) */
|
||||
SDL_GAMEPAD_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
|
||||
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,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_B,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_X,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_Y,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_CROSS,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_CIRCLE,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_SQUARE,
|
||||
SDL_GAMEPAD_BUTTON_LABEL_TRIANGLE
|
||||
} SDL_GamepadButtonLabel;
|
||||
|
||||
/**
|
||||
* The list of axes available on a gamepad
|
||||
*
|
||||
@ -111,7 +149,9 @@ typedef enum
|
||||
* and are centered within ~8000 of zero, though advanced UI will allow users to set
|
||||
* or autodetect the dead zone, which varies between gamepads.
|
||||
*
|
||||
* Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.
|
||||
* Trigger axis values range from 0 (released) to SDL_JOYSTICK_AXIS_MAX
|
||||
* (fully pressed) when reported by SDL_GetGamepadAxis(). Note that this is not the
|
||||
* same range that will be reported by the lower-level SDL_GetJoystickAxis().
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
@ -273,25 +313,20 @@ extern DECLSPEC int SDLCALL SDL_AddGamepadMappingsFromFile(const char *file);
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_ReloadGamepadMappings(void);
|
||||
|
||||
/**
|
||||
* Get the number of mappings installed.
|
||||
*
|
||||
* \returns the number of mappings.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumGamepadMappings(void);
|
||||
|
||||
/**
|
||||
* Get the mapping at a particular index.
|
||||
*
|
||||
* \param mapping_index mapping index
|
||||
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
|
||||
* the index is out of range.
|
||||
* You must free the returned pointer with SDL_free() when you are done with
|
||||
* it, but you do _not_ free each string in the array.
|
||||
*
|
||||
* \param count a pointer filled in with the number of mappings returned, can
|
||||
* be NULL.
|
||||
* \returns an array of the mapping strings, NULL-terminated. Must be freed
|
||||
* with SDL_free(). Returns NULL on error.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC char * SDLCALL SDL_GetGamepadMappingForIndex(int mapping_index);
|
||||
extern DECLSPEC char ** SDLCALL SDL_GetGamepadMappings(int *count);
|
||||
|
||||
/**
|
||||
* Get the gamepad mapping string for a given GUID.
|
||||
@ -554,6 +589,23 @@ extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromInstanceID(SDL_JoystickID
|
||||
*/
|
||||
extern DECLSPEC SDL_Gamepad *SDLCALL SDL_GetGamepadFromPlayerIndex(int player_index);
|
||||
|
||||
/**
|
||||
* Get the properties associated with an opened gamepad.
|
||||
*
|
||||
* These properties are shared with the underlying joystick object.
|
||||
*
|
||||
* \param gamepad a gamepad identifier previously returned by
|
||||
* SDL_OpenGamepad()
|
||||
* \returns a valid property ID on success or 0 on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetProperty
|
||||
* \sa SDL_SetProperty
|
||||
*/
|
||||
extern DECLSPEC SDL_PropertiesID SDLCALL SDL_GetGamepadProperties(SDL_Gamepad *gamepad);
|
||||
|
||||
/**
|
||||
* Get the instance ID of an opened gamepad.
|
||||
*
|
||||
@ -708,6 +760,19 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepa
|
||||
*/
|
||||
extern DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
|
||||
|
||||
/**
|
||||
* Get the Steam Input handle of an opened gamepad, if available.
|
||||
*
|
||||
* Returns an InputHandle_t for the gamepad that can be used with Steam Input
|
||||
* API: https://partner.steamgames.com/doc/api/ISteamInput
|
||||
*
|
||||
* \param gamepad the gamepad object to query.
|
||||
* \returns the gamepad handle, or 0 if unavailable.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
|
||||
|
||||
/**
|
||||
* Get the battery level of a gamepad, if available.
|
||||
*
|
||||
@ -898,8 +963,12 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GamepadHasAxis(SDL_Gamepad *gamepad, SDL_Ga
|
||||
*
|
||||
* The axis indices start at index 0.
|
||||
*
|
||||
* The state is a value ranging from -32768 to 32767. Triggers, however, range
|
||||
* from 0 to 32767 (they never return a negative value).
|
||||
* For thumbsticks, the state is a value ranging from -32768 (up/left) to
|
||||
* 32767 (down/right).
|
||||
*
|
||||
* Triggers range from 0 when released to 32767 when fully pressed, and never
|
||||
* return a negative value. Note that this differs from the value reported by
|
||||
* the lower-level SDL_GetJoystickAxis(), which normally uses the full range.
|
||||
*
|
||||
* \param gamepad a gamepad
|
||||
* \param axis an axis index (one of the SDL_GamepadAxis values)
|
||||
@ -922,7 +991,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_Game
|
||||
*
|
||||
* \param str string representing a SDL_Gamepad axis
|
||||
* \returns the SDL_GamepadButton enum corresponding to the input string, or
|
||||
* `SDL_GAMEPAD_AXIS_INVALID` if no match was found.
|
||||
* `SDL_GAMEPAD_BUTTON_INVALID` if no match was found.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
@ -972,6 +1041,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.
|
||||
*
|
||||
|
Reference in New Issue
Block a user