My Project
Loading...
Searching...
No Matches
SDL_gamecontroller.h
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
28#ifndef SDL_gamecontroller_h_
29#define SDL_gamecontroller_h_
30
31#include "SDL_stdinc.h"
32#include "SDL_error.h"
33#include "SDL_rwops.h"
34#include "SDL_sensor.h"
35#include "SDL_joystick.h"
36
37#include "begin_code.h"
38/* Set up for C function definitions, even when using C++ */
39#ifdef __cplusplus
40extern "C" {
41#endif
42
58struct _SDL_GameController;
59typedef struct _SDL_GameController SDL_GameController;
60
61typedef enum
62{
63 SDL_CONTROLLER_TYPE_UNKNOWN = 0,
64 SDL_CONTROLLER_TYPE_XBOX360,
65 SDL_CONTROLLER_TYPE_XBOXONE,
66 SDL_CONTROLLER_TYPE_PS3,
67 SDL_CONTROLLER_TYPE_PS4,
68 SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO,
69 SDL_CONTROLLER_TYPE_VIRTUAL,
70 SDL_CONTROLLER_TYPE_PS5,
71 SDL_CONTROLLER_TYPE_AMAZON_LUNA,
72 SDL_CONTROLLER_TYPE_GOOGLE_STADIA,
73 SDL_CONTROLLER_TYPE_NVIDIA_SHIELD,
74 SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_LEFT,
75 SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
76 SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_JOYCON_PAIR
77} SDL_GameControllerType;
78
79typedef enum
80{
81 SDL_CONTROLLER_BINDTYPE_NONE = 0,
82 SDL_CONTROLLER_BINDTYPE_BUTTON,
83 SDL_CONTROLLER_BINDTYPE_AXIS,
84 SDL_CONTROLLER_BINDTYPE_HAT
85} SDL_GameControllerBindType;
86
91{
92 SDL_GameControllerBindType bindType;
93 union
94 {
95 int button;
96 int axis;
97 struct {
98 int hat;
99 int hat_mask;
100 } hat;
101 } value;
102
104
105
165extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
166
172#define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
173
201extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
202
210extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
211
220extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
221
236extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
237
255extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller);
256
273extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
274
294extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
295
313extern DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_index);
314
326extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index);
327
340extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index);
341
364extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
365
375extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
376
392extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index);
393
410extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
411
427extern DECLSPEC const char *SDLCALL SDL_GameControllerPath(SDL_GameController *gamecontroller);
428
440extern DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller);
441
452extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller);
453
463extern DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index);
464
475extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller);
476
487extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller);
488
499extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller);
500
511extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller);
512
524extern DECLSPEC const char * SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller);
525
539extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
540
560extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
561
580extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
581
591extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
592
593
603typedef enum
604{
605 SDL_CONTROLLER_AXIS_INVALID = -1,
606 SDL_CONTROLLER_AXIS_LEFTX,
607 SDL_CONTROLLER_AXIS_LEFTY,
608 SDL_CONTROLLER_AXIS_RIGHTX,
609 SDL_CONTROLLER_AXIS_RIGHTY,
610 SDL_CONTROLLER_AXIS_TRIGGERLEFT,
611 SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
612 SDL_CONTROLLER_AXIS_MAX
614
635extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str);
636
651extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
652
666extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
667SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
669
682extern DECLSPEC SDL_bool SDLCALL
683SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
684
702extern DECLSPEC Sint16 SDLCALL
703SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
704
708typedef enum
709{
710 SDL_CONTROLLER_BUTTON_INVALID = -1,
711 SDL_CONTROLLER_BUTTON_A,
712 SDL_CONTROLLER_BUTTON_B,
713 SDL_CONTROLLER_BUTTON_X,
714 SDL_CONTROLLER_BUTTON_Y,
715 SDL_CONTROLLER_BUTTON_BACK,
716 SDL_CONTROLLER_BUTTON_GUIDE,
717 SDL_CONTROLLER_BUTTON_START,
718 SDL_CONTROLLER_BUTTON_LEFTSTICK,
719 SDL_CONTROLLER_BUTTON_RIGHTSTICK,
720 SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
721 SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
722 SDL_CONTROLLER_BUTTON_DPAD_UP,
723 SDL_CONTROLLER_BUTTON_DPAD_DOWN,
724 SDL_CONTROLLER_BUTTON_DPAD_LEFT,
725 SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
726 SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
727 SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
728 SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
729 SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
730 SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
731 SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
732 SDL_CONTROLLER_BUTTON_MAX
734
750
765extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
766
780extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
781SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
783
796extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller,
798
811extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
813
819extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller);
820
827extern DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad);
828
834extern DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
835
845extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type);
846
857extern DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled);
858
868extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type);
869
880extern DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type);
881
896extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values);
897
915extern DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values);
916
935extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms);
936
960extern DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms);
961
971extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller);
972
984extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller);
985
997extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller);
998
1010extern DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue);
1011
1023extern DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size);
1024
1035extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
1036
1049extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button);
1050
1063extern DECLSPEC const char* SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis);
1064
1065
1066/* Ends C function definitions when using C++ */
1067#ifdef __cplusplus
1068}
1069#endif
1070#include "close_code.h"
1071
1072#endif /* SDL_gamecontroller_h_ */
1073
1074/* vi: set ts=4 sw=4 expandtab: */
DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw)
DECLSPEC char *SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
DECLSPEC Sint16 SDLCALL SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC const char *SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button)
DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller)
DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index)
DECLSPEC int SDLCALL SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 left_rumble, Uint16 right_rumble, Uint32 duration_ms)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerIsSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type)
DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller)
DECLSPEC int SDLCALL SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void *data, int size)
DECLSPEC const char *SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index)
DECLSPEC int SDLCALL SDL_GameControllerEventState(int state)
DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index)
DECLSPEC int SDLCALL SDL_GameControllerGetTouchpadFinger(SDL_GameController *gamecontroller, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure)
DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpads(SDL_GameController *gamecontroller)
DECLSPEC int SDLCALL SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint8 green, Uint8 blue)
DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *str)
DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char *mappingString)
DECLSPEC const char *SDLCALL SDL_GameControllerGetSerial(SDL_GameController *gamecontroller)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
DECLSPEC int SDLCALL SDL_GameControllerGetNumTouchpadFingers(SDL_GameController *gamecontroller, int touchpad)
DECLSPEC const char *SDLCALL SDL_GameControllerGetAppleSFSymbolsNameForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC Uint16 SDLCALL SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller)
DECLSPEC void SDLCALL SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int player_index)
DECLSPEC float SDLCALL SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type)
DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerTypeForIndex(int joystick_index)
DECLSPEC const char *SDLCALL SDL_GameControllerPathForIndex(int joystick_index)
DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *str)
DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller)
DECLSPEC int SDLCALL SDL_GameControllerGetSensorDataWithTimestamp(SDL_GameController *gamecontroller, SDL_SensorType type, Uint64 *timestamp, float *data, int num_values)
DECLSPEC void SDLCALL SDL_GameControllerUpdate(void)
DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid)
SDL_GameControllerAxis
Definition: SDL_gamecontroller.h:604
DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller)
DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller)
SDL_GameControllerButton
Definition: SDL_gamecontroller.h:709
DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumble(SDL_GameController *gamecontroller)
DECLSPEC SDL_GameControllerType SDLCALL SDL_GameControllerGetType(SDL_GameController *gamecontroller)
DECLSPEC char *SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller)
DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller)
DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void)
DECLSPEC int SDLCALL SDL_GameControllerGetSensorData(SDL_GameController *gamecontroller, SDL_SensorType type, float *data, int num_values)
DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC int SDLCALL SDL_GameControllerSetSensorEnabled(SDL_GameController *gamecontroller, SDL_SensorType type, SDL_bool enabled)
DECLSPEC const char *SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis)
DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller)
DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index)
DECLSPEC char *SDLCALL SDL_GameControllerMappingForIndex(int mapping_index)
DECLSPEC const char *SDLCALL SDL_GameControllerPath(SDL_GameController *gamecontroller)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasLED(SDL_GameController *gamecontroller)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller)
DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromPlayerIndex(int player_index)
DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type)
DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:82
SDL_SensorType
Definition: SDL_sensor.h:70
Definition: SDL_guid.h:55
Definition: SDL_gamecontroller.h:91
Definition: SDL_rwops.h:53