My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SDL_gamecontroller.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2016 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_joystick.h"
35 
36 #include "begin_code.h"
37 /* Set up for C function definitions, even when using C++ */
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
54 /* The gamecontroller structure used to identify an SDL game controller */
55 struct _SDL_GameController;
56 typedef struct _SDL_GameController SDL_GameController;
57 
58 
59 typedef enum
60 {
61  SDL_CONTROLLER_BINDTYPE_NONE = 0,
62  SDL_CONTROLLER_BINDTYPE_BUTTON,
63  SDL_CONTROLLER_BINDTYPE_AXIS,
64  SDL_CONTROLLER_BINDTYPE_HAT
65 } SDL_GameControllerBindType;
66 
71 {
72  SDL_GameControllerBindType bindType;
73  union
74  {
75  int button;
76  int axis;
77  struct {
78  int hat;
79  int hat_mask;
80  } hat;
81  } value;
82 
84 
85 
120 extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW( SDL_RWops * rw, int freerw );
121 
127 #define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
128 
134 extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping( const char* mappingString );
135 
141 extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID( SDL_JoystickGUID guid );
142 
148 extern DECLSPEC char * SDLCALL SDL_GameControllerMapping( SDL_GameController * gamecontroller );
149 
153 extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
154 
155 
161 extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
162 
172 extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
173 
177 extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
178 
182 extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
183 
188 extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
189 
193 extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
194 
204 extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
205 
212 extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
213 
214 
218 typedef enum
219 {
220  SDL_CONTROLLER_AXIS_INVALID = -1,
221  SDL_CONTROLLER_AXIS_LEFTX,
222  SDL_CONTROLLER_AXIS_LEFTY,
223  SDL_CONTROLLER_AXIS_RIGHTX,
224  SDL_CONTROLLER_AXIS_RIGHTY,
225  SDL_CONTROLLER_AXIS_TRIGGERLEFT,
226  SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
227  SDL_CONTROLLER_AXIS_MAX
229 
233 extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
234 
238 extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
239 
243 extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
244 SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
246 
255 extern DECLSPEC Sint16 SDLCALL
256 SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
258 
262 typedef enum
263 {
264  SDL_CONTROLLER_BUTTON_INVALID = -1,
265  SDL_CONTROLLER_BUTTON_A,
266  SDL_CONTROLLER_BUTTON_B,
267  SDL_CONTROLLER_BUTTON_X,
268  SDL_CONTROLLER_BUTTON_Y,
269  SDL_CONTROLLER_BUTTON_BACK,
270  SDL_CONTROLLER_BUTTON_GUIDE,
271  SDL_CONTROLLER_BUTTON_START,
272  SDL_CONTROLLER_BUTTON_LEFTSTICK,
273  SDL_CONTROLLER_BUTTON_RIGHTSTICK,
274  SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
275  SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
276  SDL_CONTROLLER_BUTTON_DPAD_UP,
277  SDL_CONTROLLER_BUTTON_DPAD_DOWN,
278  SDL_CONTROLLER_BUTTON_DPAD_LEFT,
279  SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
280  SDL_CONTROLLER_BUTTON_MAX
282 
286 extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
287 
291 extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
292 
296 extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
297 SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
298  SDL_GameControllerButton button);
299 
300 
306 extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
307  SDL_GameControllerButton button);
308 
312 extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
313 
314 
315 /* Ends C function definitions when using C++ */
316 #ifdef __cplusplus
317 }
318 #endif
319 #include "close_code.h"
320 
321 #endif /* _SDL_gamecontroller_h */
322 
323 /* vi: set ts=4 sw=4 expandtab: */
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller)
struct SDL_GameControllerButtonBind SDL_GameControllerButtonBind
DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
DECLSPEC const char *SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button)
Definition: SDL_gamecontroller.h:70
SDL_GameControllerButton
Definition: SDL_gamecontroller.h:262
DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char *mappingString)
SDL_GameControllerAxis
Definition: SDL_gamecontroller.h:218
DECLSPEC char *SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid)
DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller, SDL_GameControllerButton button)
DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller)
DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw)
DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller)
DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString)
DECLSPEC int SDLCALL SDL_GameControllerEventState(int state)
DECLSPEC const char *SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis)
Definition: SDL_joystick.h:68
DECLSPEC SDL_GameControllerButtonBind SDLCALL SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC char *SDLCALL SDL_GameControllerMapping(SDL_GameController *gamecontroller)
DECLSPEC void SDLCALL SDL_GameControllerUpdate(void)
DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller)
DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid)
DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString)
DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index)
DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index)
int16_t Sint16
A signed 16-bit integer type.
Definition: SDL_stdinc.h:143
DECLSPEC Sint16 SDLCALL SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index)
Definition: SDL_rwops.h:52