|
SDL
2.0
|
#include "SDL_stdinc.h"#include "SDL_error.h"#include "SDL_rwops.h"#include "SDL_sensor.h"#include "SDL_joystick.h"#include "begin_code.h"#include "close_code.h"
Include dependency graph for SDL_gamecontroller.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Data Structures | |
| struct | SDL_GameControllerButtonBind |
Macros | |
| #define | SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) |
Include file for SDL game controller event handling
In order to use these functions, SDL_Init() must have been called with the SDL_INIT_GAMECONTROLLER flag. This causes SDL to scan the system for game controllers, and load appropriate drivers.
If you would like to receive controller updates while the application is in the background, you should set the following hint before calling SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
Definition in file SDL_gamecontroller.h.
| #define SDL_GameControllerAddMappingsFromFile | ( | file | ) | SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1) |
Load a set of mappings from a file, filtered by the current SDL_GetPlatform()
Convenience macro.
Definition at line 141 of file SDL_gamecontroller.h.
| enum SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 SDL_AssertionHandler void SDL_SpinLock SDL_atomic_t int int return SDL_atomic_t return void void void return void return int return SDL_AudioSpec SDL_AudioSpec return int int return return int SDL_RWops int SDL_AudioSpec Uint8 Uint32 return SDL_AudioCVT SDL_AudioFormat Uint8 int SDL_AudioFormat Uint8 int return Uint8 const Uint8 Uint32 int const char return return return return return return return return Uint32 return Uint32 SDL_Event return SDL_Event int return SDL_EventFilter void SDL_EventFilter void SDL_EventFilter void int return const char const char return SDL_JoystickGUID return int return int return SDL_GameController return int return const char return SDL_GameController SDL_GameControllerAxis return const char return SDL_GameController SDL_GameControllerButton return SDL_GameController SDL_RWops return SDL_TouchID SDL_RWops return int return int return return SDL_Joystick return SDL_Haptic SDL_Haptic return SDL_Haptic return SDL_Haptic SDL_HapticEffect return SDL_Haptic int Uint32 return SDL_Haptic int SDL_Haptic int return SDL_Haptic return SDL_Haptic return SDL_Haptic return SDL_Haptic return const char const char return const char SDL_HintCallback void int return SDL_Joystick return SDL_Joystick return const char return SDL_Joystick return SDL_Joystick return SDL_Joystick return int return SDL_Joystick int return SDL_Joystick int return return return SDL_Scancode return SDL_Scancode return SDL_Keycode return return const char return void int SDL_LogPriority SDL_LogOutputFunction void Uint32 const char const char SDL_Window return int int return SDL_Window int int return SDL_Surface int int return SDL_Cursor return int return SDL_mutex return SDL_mutex return Uint32 return SDL_sem return SDL_sem Uint32 return SDL_sem return SDL_cond SDL_cond return SDL_cond SDL_mutex Uint32 return Uint32 int Uint32 Uint32 Uint32 Uint32 return Uint32 return int return SDL_Palette const SDL_Color int int return const SDL_PixelFormat Uint8 Uint8 Uint8 return Uint32 const SDL_PixelFormat Uint8 Uint8 Uint8 float Uint16 int int return const SDL_Rect const SDL_Rect SDL_Rect return const SDL_Point int const SDL_Rect SDL_Rect return return int int Uint32 SDL_Window SDL_Renderer return SDL_Surface return SDL_Renderer SDL_RendererInfo return SDL_Renderer Uint32 int int int return SDL_Texture Uint32 int int int return SDL_Texture Uint8 Uint8 Uint8 return SDL_Texture Uint8 return SDL_Texture SDL_BlendMode return SDL_Texture const SDL_Rect const Uint8 int const Uint8 int const Uint8 int return SDL_Texture SDL_Renderer SDL_Texture return SDL_Renderer int int return SDL_Renderer const SDL_Rect return SDL_Renderer const SDL_Rect return SDL_Renderer float float return SDL_Renderer Uint8 Uint8 Uint8 Uint8 return SDL_Renderer SDL_BlendMode return SDL_Renderer return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Point int return SDL_Renderer const SDL_Rect int return SDL_Renderer const SDL_Rect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_Rect const double const SDL_Point const SDL_RendererFlip return SDL_Renderer SDL_Renderer SDL_Texture return void int return return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops return SDL_RWops Uint16 return SDL_RWops Uint32 return SDL_RWops Uint64 return const char unsigned int unsigned int unsigned int unsigned int Uint32 return SDL_Window SDL_Surface SDL_WindowShapeMode return size_t return void size_t return const char return void size_t size_t int(*) b int return int return int size_t return size_t return const wchar_t return const wchar_t size_t return const char size_t return const char size_t return char return char return const char int return int char int return long char int return Sint64 char int return const char return const char char int return const char char int return const char char return const char const char size_t return const char const char size_t return double return double return double return double return double return double return double int return float return const char const char return SDL_iconv_t const char size_t char size_t return Uint32 int int int Uint32 Uint32 Uint32 Uint32 return SDL_Surface SDL_Surface return SDL_RWops int return SDL_Surface int return SDL_Surface Uint32 return SDL_Surface Uint8 Uint8 Uint8 return SDL_Surface Uint8 return SDL_Surface SDL_BlendMode return SDL_Surface SDL_Rect SDL_Surface Uint32 Uint32 return SDL_Surface const SDL_Rect Uint32 return SDL_Surface const SDL_Rect SDL_Surface SDL_Rect return SDL_Surface const SDL_Rect SDL_Surface const SDL_Rect return SDL_Surface SDL_Rect SDL_Surface SDL_Rect return SDL_Thread return SDL_Thread return SDL_Thread int return SDL_TLSID const void void(*) return return Uint32 SDL_TimerID return int return SDL_TouchID int return return return const char return return int return int return int SDL_DisplayMode return int const SDL_DisplayMode SDL_DisplayMode return SDL_Window const SDL_DisplayMode return SDL_Window return const void return Uint32 return SDL_Window const char SDL_Window SDL_Surface SDL_Window const char return SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window int int SDL_Window SDL_Window SDL_Window SDL_Window Uint32 return SDL_Window return SDL_Window SDL_bool SDL_Window float return SDL_Window const Uint16 const Uint16 const Uint16 return SDL_Window const char return SDL_GLattr int return SDL_Window return return SDL_Window int int return SDL_GLContext SDL_RWops int return return void return int int return double return SDL_bool return int int return SDL_AudioDeviceID const void Uint32 return SDL_AudioDeviceID int float float float return SDL_JoystickID return int SDL_Rect return SDL_Window float return SDL_Window return SDL_Renderer SDL_bool return SDL_AudioDeviceID void Uint32 return Uint32 int int int Uint32 return const char SDL_bool return int return SDL_Joystick return SDL_Joystick return SDL_GameController return return int return int return int return SDL_RWops size_t int return SDL_BlendFactor SDL_BlendFactor SDL_BlendOperation SDL_BlendFactor SDL_BlendFactor SDL_BlendOperation return const char return SDL_Window VkInstance VkSurfaceKHR return SDL_malloc_func SDL_calloc_func SDL_realloc_func SDL_free_func return SDL_AudioStream const void int return SDL_AudioStream SDL_AudioStream float return float return float return float return float return float int return float float return return SDL_Renderer return double return int return double return const wchar_t return SDL_Joystick Uint16 Uint16 Uint32 return int return int return int return SDL_Sensor return SDL_Sensor return SDL_Sensor float int return int return SDL_ThreadFunction const char const size_t void return SDL_Joystick return SDL_Renderer return SDL_Renderer const SDL_FPoint int return SDL_Renderer const SDL_FPoint int return SDL_Renderer const SDL_FRect int return SDL_Renderer const SDL_FRect int return SDL_Renderer SDL_Texture const SDL_Rect const SDL_FRect const double const SDL_FPoint const SDL_RendererFlip return return void SDL_RWops Sint64 int return SDL_RWops void size_t size_t return SDL_RWops return SDL_Window return SDL_Texture const SDL_Rect SDL_Surface return char const char char return const wchar_t const wchar_t size_t return SDL_GameController return SDL_GameController int SDL_Joystick int SDL_Texture SDL_ScaleMode return int return int return SDL_Joystick int Sint16 return SDL_Joystick int Uint8 return SDL_MetalView return double return return const char return SDL_GameController return SDL_Joystick return SDL_GameController Uint16 Uint16 Uint32 return SDL_GameController SDL_GameControllerAxis |
The list of axes available from a controller
Thumbstick axis values range from SDL_JOYSTICK_AXIS_MIN to SDL_JOYSTICK_AXIS_MAX, and are centered within ~8000 of zero, though advanced UI will allow users to set or autodetect the dead zone, which varies between controllers.
Trigger axis values range from 0 to SDL_JOYSTICK_AXIS_MAX.
Definition at line 312 of file SDL_gamecontroller.h.
| Enumerator | |
|---|---|
| SDL_CONTROLLER_BINDTYPE_NONE | |
| SDL_CONTROLLER_BINDTYPE_BUTTON | |
| SDL_CONTROLLER_BINDTYPE_AXIS | |
| SDL_CONTROLLER_BINDTYPE_HAT | |
Definition at line 73 of file SDL_gamecontroller.h.
The list of buttons available from a controller
Definition at line 361 of file SDL_gamecontroller.h.
Definition at line 61 of file SDL_gamecontroller.h.
| int SDL_GameControllerAddMapping | ( | const char * | mappingString | ) |
Add or update an existing mapping configuration
Definition at line 1455 of file SDL_gamecontroller.c.
References SDL_CONTROLLER_MAPPING_PRIORITY_API, and SDL_PrivateGameControllerAddMapping().
Referenced by SDL_GameControllerAddMappingsFromRW().
To count the number of game controllers in the system for the following: int nJoysticks = SDL_NumJoysticks(); int nGameControllers = 0; for (int i = 0; i < nJoysticks; i++) { if (SDL_IsGameController(i)) { nGameControllers++; } }
Using the SDL_HINT_GAMECONTROLLERCONFIG hint or the SDL_GameControllerAddMapping() you can add support for controllers SDL is unaware of or cause an existing controller to have a different binding. The format is: guid,name,mappings
Where GUID is the string value from SDL_JoystickGetGUIDString(), name is the human readable string for the device and mappings are controller mappings to joystick ones. Under Windows there is a reserved GUID of "xinput" that covers any XInput devices. The mapping format for joystick is: bX - a joystick button, index X hX.Y - hat X with value Y aX - axis X of the joystick Buttons can be used as a controller axis and vice versa.
This string shows an example of a valid mapping for a controller "03000000341a00003608000000000000,PS3 Controller,a:b1,b:b2,y:b3,x:b0,start:b9,guide:b12,back:b8,dpup:h0.1,dpleft:h0.8,dpdown:h0.4,dpright:h0.2,leftshoulder:b4,rightshoulder:b5,leftstick:b10,rightstick:b11,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:b6,righttrigger:b7", Load a set of mappings from a seekable SDL data stream (memory or file), filtered by the current SDL_GetPlatform() A community sourced database of controllers is available at https://raw.github.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt
If freerw is non-zero, the stream will be closed after being read.
Definition at line 1276 of file SDL_gamecontroller.c.
References sort_controllers::controllers, NULL, SDL_arraysize, SDL_CONTROLLER_PLATFORM_FIELD, SDL_free, SDL_GameControllerAddMapping(), SDL_GetPlatform, SDL_malloc, SDL_RWclose, SDL_RWread, SDL_RWsize, SDL_SetError, SDL_strchr, SDL_strlcpy, SDL_strlen, SDL_strncasecmp, and SDL_strstr.
| void SDL_GameControllerClose | ( | SDL_GameController * | gamecontroller | ) |
Close a controller previously opened with SDL_GameControllerOpen().
Definition at line 2393 of file SDL_gamecontroller.c.
References gamecontroller, NULL, SDL_free, SDL_gamecontrollers, SDL_JoystickClose, SDL_LockJoysticks, and SDL_UnlockJoysticks.
Referenced by SDL_GameControllerQuit().
Enable/disable controller event polling.
If controller events are disabled, you must call SDL_GameControllerUpdate() yourself and check the state of the controller when you want controller information.
The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
Definition at line 2564 of file SDL_gamecontroller.c.
References i, SDL_arraysize, SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP, SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMAPPED, SDL_CONTROLLERDEVICEREMOVED, SDL_ENABLE, SDL_EventState, SDL_IGNORE, SDL_QUERY, and state.
| SDL_GameController* SDL_GameControllerFromInstanceID | ( | SDL_JoystickID | joyid | ) |
Return the SDL_GameController associated with an instance id.
Definition at line 2274 of file SDL_gamecontroller.c.
References gamecontroller, NULL, SDL_gamecontrollers, SDL_LockJoysticks, and SDL_UnlockJoysticks.
Referenced by SDL_GameControllerFromPlayerIndex().
| SDL_GameController* SDL_GameControllerFromPlayerIndex | ( | int | player_index | ) |
Return the SDL_GameController associated with a player index.
Definition at line 2295 of file SDL_gamecontroller.c.
References joystick, NULL, SDL_GameControllerFromInstanceID(), and SDL_JoystickFromPlayerIndex.
| SDL_bool SDL_GameControllerGetAttached | ( | SDL_GameController * | gamecontroller | ) |
Returns SDL_TRUE if the controller has been opened and currently connected, or SDL_FALSE if it has not.
Definition at line 2249 of file SDL_gamecontroller.c.
References gamecontroller, SDL_FALSE, and SDL_JoystickGetAttached.
| Sint16 SDL_GameControllerGetAxis | ( | SDL_GameController * | gamecontroller, |
| SDL_GameControllerAxis | axis | ||
| ) |
Get the current state of an axis control on a game controller.
The state is a value ranging from -32768 to 32767 (except for the triggers, which range from 0 to 32767).
The axis indices start at index 0.
Definition at line 1910 of file SDL_gamecontroller.c.
References SDL_ExtendedGameControllerBind::axis, axis, SDL_ExtendedGameControllerBind::button, gamecontroller, SDL_ExtendedGameControllerBind::hat, i, SDL_ExtendedGameControllerBind::input, SDL_ExtendedGameControllerBind::inputType, int(), SDL_ExtendedGameControllerBind::output, SDL_ExtendedGameControllerBind::outputType, SDL_CONTROLLER_BINDTYPE_AXIS, SDL_CONTROLLER_BINDTYPE_BUTTON, SDL_CONTROLLER_BINDTYPE_HAT, SDL_JoystickGetAxis, SDL_JoystickGetButton, SDL_JoystickGetHat, and SDL_PRESSED.
Referenced by RecenterGameController().
| SDL_GameControllerAxis SDL_GameControllerGetAxisFromString | ( | const char * | pchString | ) |
turn this string into a axis mapping
Definition at line 687 of file SDL_gamecontroller.c.
References map_StringForControllerAxis, SDL_CONTROLLER_AXIS_INVALID, and SDL_strcasecmp.
Referenced by SDL_PrivateGameControllerParseElement().
| SDL_GameControllerButtonBind SDL_GameControllerGetBindForAxis | ( | SDL_GameController * | gamecontroller, |
| SDL_GameControllerAxis | axis | ||
| ) |
Get the SDL joystick layer binding for this controller button mapping
Definition at line 2308 of file SDL_gamecontroller.c.
References SDL_GameControllerButtonBind::axis, SDL_ExtendedGameControllerBind::axis, axis, SDL_GameControllerButtonBind::bindType, SDL_GameControllerButtonBind::button, SDL_ExtendedGameControllerBind::button, gamecontroller, SDL_GameControllerButtonBind::hat, SDL_ExtendedGameControllerBind::hat, i, SDL_ExtendedGameControllerBind::input, SDL_ExtendedGameControllerBind::inputType, SDL_ExtendedGameControllerBind::output, SDL_ExtendedGameControllerBind::outputType, SDL_CONTROLLER_AXIS_INVALID, SDL_CONTROLLER_BINDTYPE_AXIS, SDL_CONTROLLER_BINDTYPE_BUTTON, SDL_CONTROLLER_BINDTYPE_HAT, SDL_zero, and SDL_GameControllerButtonBind::value.
Referenced by SDL_GameControllerHasAxis().
| SDL_GameControllerButtonBind SDL_GameControllerGetBindForButton | ( | SDL_GameController * | gamecontroller, |
| SDL_GameControllerButton | button | ||
| ) |
Get the SDL joystick layer binding for this controller button mapping
Definition at line 2340 of file SDL_gamecontroller.c.
References SDL_GameControllerButtonBind::axis, SDL_ExtendedGameControllerBind::axis, SDL_GameControllerButtonBind::bindType, SDL_GameControllerButtonBind::button, SDL_ExtendedGameControllerBind::button, button, gamecontroller, SDL_GameControllerButtonBind::hat, SDL_ExtendedGameControllerBind::hat, i, SDL_ExtendedGameControllerBind::input, SDL_ExtendedGameControllerBind::inputType, SDL_ExtendedGameControllerBind::output, SDL_ExtendedGameControllerBind::outputType, SDL_CONTROLLER_BINDTYPE_AXIS, SDL_CONTROLLER_BINDTYPE_BUTTON, SDL_CONTROLLER_BINDTYPE_HAT, SDL_CONTROLLER_BUTTON_INVALID, SDL_zero, and SDL_GameControllerButtonBind::value.
Referenced by SDL_GameControllerHasButton().
| Uint8 SDL_GameControllerGetButton | ( | SDL_GameController * | gamecontroller, |
| SDL_GameControllerButton | button | ||
| ) |
Get the current state of a button on a game controller.
The button indices start at index 0.
Definition at line 1979 of file SDL_gamecontroller.c.
References SDL_ExtendedGameControllerBind::axis, SDL_ExtendedGameControllerBind::button, button, gamecontroller, SDL_ExtendedGameControllerBind::hat, i, SDL_ExtendedGameControllerBind::input, SDL_ExtendedGameControllerBind::inputType, SDL_ExtendedGameControllerBind::output, SDL_ExtendedGameControllerBind::outputType, SDL_CONTROLLER_BINDTYPE_AXIS, SDL_CONTROLLER_BINDTYPE_BUTTON, SDL_CONTROLLER_BINDTYPE_HAT, SDL_JoystickGetAxis, SDL_JoystickGetButton, SDL_JoystickGetHat, SDL_PRESSED, and SDL_RELEASED.
Referenced by RecenterGameController().
| SDL_GameControllerButton SDL_GameControllerGetButtonFromString | ( | const char * | pchString | ) |
turn this string into a button mapping
Definition at line 745 of file SDL_gamecontroller.c.
References map_StringForControllerButton, SDL_CONTROLLER_BUTTON_INVALID, and SDL_strcasecmp.
Referenced by SDL_PrivateGameControllerParseElement().
| SDL_Joystick* SDL_GameControllerGetJoystick | ( | SDL_GameController * | gamecontroller | ) |
Get the underlying joystick object used by a controller
Definition at line 2261 of file SDL_gamecontroller.c.
References gamecontroller, and NULL.
Referenced by SDL_GameControllerGetNumTouchpadFingers(), SDL_GameControllerGetNumTouchpads(), SDL_GameControllerGetPlayerIndex(), SDL_GameControllerGetProduct(), SDL_GameControllerGetProductVersion(), SDL_GameControllerGetSensorData(), SDL_GameControllerGetSerial(), SDL_GameControllerGetTouchpadFinger(), SDL_GameControllerGetType(), SDL_GameControllerGetVendor(), SDL_GameControllerHasLED(), SDL_GameControllerHasSensor(), SDL_GameControllerIsSensorEnabled(), SDL_GameControllerName(), SDL_GameControllerRumble(), SDL_GameControllerRumbleTriggers(), SDL_GameControllerSetLED(), SDL_GameControllerSetPlayerIndex(), and SDL_GameControllerSetSensorEnabled().
Get the number of supported simultaneous fingers on a touchpad on a game controller.
Definition at line 2033 of file SDL_gamecontroller.c.
References gamecontroller, joystick, and SDL_GameControllerGetJoystick().
| int SDL_GameControllerGetNumTouchpads | ( | SDL_GameController * | gamecontroller | ) |
Get the number of touchpads on a game controller.
Definition at line 2020 of file SDL_gamecontroller.c.
References gamecontroller, joystick, and SDL_GameControllerGetJoystick().
| int SDL_GameControllerGetPlayerIndex | ( | SDL_GameController * | gamecontroller | ) |
Get the player index of an opened game controller, or -1 if it's not available
For XInput controllers this returns the XInput user index.
Definition at line 2206 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickGetPlayerIndex.
| Uint16 SDL_GameControllerGetProduct | ( | SDL_GameController * | gamecontroller | ) |
Get the USB product ID of an opened controller, if available. If the product ID isn't available this function returns 0.
Definition at line 2227 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickGetProduct.
| Uint16 SDL_GameControllerGetProductVersion | ( | SDL_GameController * | gamecontroller | ) |
Get the product version of an opened controller, if available. If the product version isn't available this function returns 0.
Definition at line 2233 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickGetProductVersion.
| int SDL_GameControllerGetSensorData | ( | SDL_GameController * | gamecontroller, |
| SDL_SensorType | type, | ||
| float * | data, | ||
| int | num_values | ||
| ) |
Get the current state of a game controller sensor.
The number of values and interpretation of the data is sensor dependent. See SDL_sensor.h for the details for each type of sensor.
| gamecontroller | The controller to query |
| type | The type of sensor to query |
| data | A pointer filled with the current sensor state |
| num_values | The number of values to write to data |
Definition at line 2165 of file SDL_gamecontroller.c.
References SDL_JoystickSensorInfo::data, gamecontroller, i, joystick, SDL_arraysize, SDL_GameControllerGetJoystick(), SDL_InvalidParamError, SDL_memcpy, SDL_min, SDL_Unsupported, and SDL_JoystickSensorInfo::type.
| const char* SDL_GameControllerGetSerial | ( | SDL_GameController * | gamecontroller | ) |
Get the serial number of an opened controller, if available.
Returns the serial number of the controller, or NULL if it is not available.
Definition at line 2239 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickGetSerial.
| const char* SDL_GameControllerGetStringForAxis | ( | SDL_GameControllerAxis | axis | ) |
turn this axis enum into a string mapping
Definition at line 709 of file SDL_gamecontroller.c.
References axis, map_StringForControllerAxis, NULL, SDL_CONTROLLER_AXIS_INVALID, and SDL_CONTROLLER_AXIS_MAX.
| const char* SDL_GameControllerGetStringForButton | ( | SDL_GameControllerButton | button | ) |
turn this button enum into a string mapping
Definition at line 761 of file SDL_gamecontroller.c.
References axis, map_StringForControllerButton, NULL, SDL_CONTROLLER_BUTTON_INVALID, and SDL_CONTROLLER_BUTTON_MAX.
| int SDL_GameControllerGetTouchpadFinger | ( | SDL_GameController * | gamecontroller, |
| int | touchpad, | ||
| int | finger, | ||
| Uint8 * | state, | ||
| float * | x, | ||
| float * | y, | ||
| float * | pressure | ||
| ) |
Get the current state of a finger on a touchpad on a game controller.
Definition at line 2047 of file SDL_gamecontroller.c.
References SDL_JoystickTouchpadInfo::fingers, gamecontroller, joystick, SDL_JoystickTouchpadFingerInfo::pressure, SDL_GameControllerGetJoystick(), SDL_InvalidParamError, SDL_JoystickTouchpadFingerInfo::state, state, SDL_JoystickTouchpadFingerInfo::x, and SDL_JoystickTouchpadFingerInfo::y.
| SDL_GameControllerType SDL_GameControllerGetType | ( | SDL_GameController * | gamecontroller | ) |
Return the type of this currently opened controller
Definition at line 2200 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), SDL_GetJoystickGameControllerTypeFromGUID(), SDL_JoystickGetGUID, and SDL_JoystickName.
| Uint16 SDL_GameControllerGetVendor | ( | SDL_GameController * | gamecontroller | ) |
Get the USB vendor ID of an opened controller, if available. If the vendor ID isn't available this function returns 0.
Definition at line 2221 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickGetVendor.
| SDL_bool SDL_GameControllerHasAxis | ( | SDL_GameController * | gamecontroller, |
| SDL_GameControllerAxis | axis | ||
| ) |
Return whether a game controller has a given axis
Definition at line 1900 of file SDL_gamecontroller.c.
References axis, SDL_GameControllerButtonBind::bindType, gamecontroller, SDL_CONTROLLER_BINDTYPE_NONE, SDL_FALSE, SDL_GameControllerGetBindForAxis(), and SDL_TRUE.
| SDL_bool SDL_GameControllerHasButton | ( | SDL_GameController * | gamecontroller, |
| SDL_GameControllerButton | button | ||
| ) |
Return whether a game controller has a given button
Definition at line 1969 of file SDL_gamecontroller.c.
References SDL_GameControllerButtonBind::bindType, button, gamecontroller, SDL_CONTROLLER_BINDTYPE_NONE, SDL_FALSE, SDL_GameControllerGetBindForButton(), and SDL_TRUE.
| SDL_bool SDL_GameControllerHasLED | ( | SDL_GameController * | gamecontroller | ) |
Return whether a controller has an LED
| gamecontroller | The controller to query |
Definition at line 2381 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickHasLED.
| SDL_bool SDL_GameControllerHasSensor | ( | SDL_GameController * | gamecontroller, |
| SDL_SensorType | type | ||
| ) |
Return whether a game controller has a particular sensor.
| gamecontroller | The controller to query |
| type | The type of sensor to query |
Return whether a game controller has a particular sensor.
Definition at line 2085 of file SDL_gamecontroller.c.
References gamecontroller, i, joystick, SDL_FALSE, SDL_GameControllerGetJoystick(), and SDL_TRUE.
| SDL_bool SDL_GameControllerIsSensorEnabled | ( | SDL_GameController * | gamecontroller, |
| SDL_SensorType | type | ||
| ) |
Query whether sensor data reporting is enabled for a game controller
| gamecontroller | The controller to query |
| type | The type of sensor to query |
Definition at line 2146 of file SDL_gamecontroller.c.
References gamecontroller, i, joystick, SDL_FALSE, and SDL_GameControllerGetJoystick().
| char* SDL_GameControllerMapping | ( | SDL_GameController * | gamecontroller | ) |
Get a mapping string for an open GameController
Definition at line 1539 of file SDL_gamecontroller.c.
References gamecontroller, NULL, and SDL_GameControllerMappingForGUID().
| char* SDL_GameControllerMappingForDeviceIndex | ( | int | joystick_index | ) |
Get the mapping of a game controller. This can be called before any controllers are opened.
Get the mapping of a game controller. This can be called before any controllers are opened. If no mapping can be found, this function returns NULL.
Definition at line 1684 of file SDL_gamecontroller.c.
References NULL, SDL_JoystickGetDeviceGUID, SDL_JoystickGetGUIDString, SDL_LockJoysticks, SDL_malloc, SDL_OutOfMemory, SDL_PrivateGetControllerMapping(), SDL_snprintf, SDL_strlen, and SDL_UnlockJoysticks.
| char* SDL_GameControllerMappingForGUID | ( | SDL_JoystickGUID | guid | ) |
Get a mapping string for a GUID
Definition at line 1515 of file SDL_gamecontroller.c.
References NULL, SDL_FALSE, SDL_JoystickGetGUIDString, SDL_malloc, SDL_OutOfMemory, SDL_PrivateGetControllerMappingForGUID(), SDL_snprintf, and SDL_strlen.
Referenced by SDL_GameControllerMapping().
| char* SDL_GameControllerMappingForIndex | ( | int | mapping_index | ) |
Get the mapping at a particular index.
Definition at line 1482 of file SDL_gamecontroller.c.
References NULL, s_pSupportedControllers, s_zeroGUID, SDL_JoystickGetGUIDString, SDL_malloc, SDL_memcmp, SDL_OutOfMemory, SDL_snprintf, and SDL_strlen.
| const char* SDL_GameControllerName | ( | SDL_GameController * | gamecontroller | ) |
Return the name for this currently opened controller
Definition at line 2187 of file SDL_gamecontroller.c.
References gamecontroller, NULL, SDL_GameControllerGetJoystick(), SDL_JoystickName, and SDL_strcmp.
| const char* SDL_GameControllerNameForIndex | ( | int | joystick_index | ) |
Get the implementation dependent name of a game controller. This can be called before any controllers are opened. If no name can be found, this function returns NULL.
Definition at line 1654 of file SDL_gamecontroller.c.
References ControllerMapping_t::name, NULL, SDL_JoystickNameForIndex, SDL_PrivateGetControllerMapping(), and SDL_strcmp.
Get the number of mappings installed
Definition at line 1464 of file SDL_gamecontroller.c.
References s_pSupportedControllers, s_zeroGUID, and SDL_memcmp.
| SDL_GameController* SDL_GameControllerOpen | ( | int | joystick_index | ) |
Open a game controller for use. The index passed as an argument refers to the N'th game controller on the system. This index is not the value which will identify this controller in future controller events. The joystick's instance id (SDL_JoystickID) will be used there instead.
Definition at line 1806 of file SDL_gamecontroller.c.
References gamecontroller, ControllerMapping_t::mapping, ControllerMapping_t::name, NULL, SDL_calloc, SDL_free, SDL_gamecontrollers, SDL_JoystickClose, SDL_JoystickGetDeviceInstanceID, SDL_JoystickOpen, SDL_LockJoysticks, SDL_OutOfMemory, SDL_PrivateGetControllerMapping(), SDL_PrivateLoadButtonMapping(), SDL_SetError, and SDL_UnlockJoysticks.
| int SDL_GameControllerRumble | ( | SDL_GameController * | gamecontroller, |
| Uint16 | low_frequency_rumble, | ||
| Uint16 | high_frequency_rumble, | ||
| Uint32 | duration_ms | ||
| ) |
Start a rumble effect Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling.
| gamecontroller | The controller to vibrate |
| low_frequency_rumble | The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF |
| high_frequency_rumble | The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF |
| duration_ms | The duration of the rumble effect, in milliseconds |
Definition at line 2369 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickRumble.
| int SDL_GameControllerRumbleTriggers | ( | SDL_GameController * | gamecontroller, |
| Uint16 | left_rumble, | ||
| Uint16 | right_rumble, | ||
| Uint32 | duration_ms | ||
| ) |
Start a rumble effect in the game controller's triggers Each call to this function cancels any previous trigger rumble effect, and calling it with 0 intensity stops any rumbling.
| gamecontroller | The controller to vibrate |
| left_rumble | The intensity of the left trigger rumble motor, from 0 to 0xFFFF |
| right_rumble | The intensity of the right trigger rumble motor, from 0 to 0xFFFF |
| duration_ms | The duration of the rumble effect, in milliseconds |
Definition at line 2375 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickRumbleTriggers.
| int SDL_GameControllerSetLED | ( | SDL_GameController * | gamecontroller, |
| Uint8 | red, | ||
| Uint8 | green, | ||
| Uint8 | blue | ||
| ) |
Update a controller's LED color.
| gamecontroller | The controller to update |
| red | The intensity of the red LED |
| green | The intensity of the green LED |
| blue | The intensity of the blue LED |
Definition at line 2387 of file SDL_gamecontroller.c.
References gamecontroller, red, SDL_GameControllerGetJoystick(), and SDL_JoystickSetLED.
Set the player index of an opened game controller
Definition at line 2215 of file SDL_gamecontroller.c.
References gamecontroller, SDL_GameControllerGetJoystick(), and SDL_JoystickSetPlayerIndex.
| int SDL_GameControllerSetSensorEnabled | ( | SDL_GameController * | gamecontroller, |
| SDL_SensorType | type, | ||
| SDL_bool | enabled | ||
| ) |
Set whether data reporting for a game controller sensor is enabled
| gamecontroller | The controller to update |
| type | The type of sensor to enable/disable |
| enabled | Whether data reporting should be enabled |
Definition at line 2103 of file SDL_gamecontroller.c.
References SDL_JoystickSensorInfo::enabled, gamecontroller, i, joystick, SDL_FALSE, SDL_GameControllerGetJoystick(), SDL_InvalidParamError, SDL_TRUE, SDL_Unsupported, and SDL_JoystickSensorInfo::type.
| SDL_GameControllerType SDL_GameControllerTypeForIndex | ( | int | joystick_index | ) |
Get the type of a game controller. This can be called before any controllers are opened.
Get the type of a game controller.
Definition at line 1672 of file SDL_gamecontroller.c.
References SDL_GetJoystickGameControllerTypeFromGUID(), SDL_JoystickGetDeviceGUID, and SDL_JoystickNameForIndex.
Update the current state of the open game controllers.
This is called automatically by the event loop if any game controller events are enabled.
Definition at line 1890 of file SDL_gamecontroller.c.
References SDL_JoystickUpdate.
Is the joystick on this index supported by the game controller interface?
Definition at line 1729 of file SDL_gamecontroller.c.
References SDL_FALSE, SDL_PrivateGetControllerMapping(), and SDL_TRUE.
Referenced by SDL_GameControllerEventWatcher(), and SDL_GameControllerInit().