My Project
SDL_gamecontroller.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2018 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 
57 struct _SDL_GameController;
58 typedef struct _SDL_GameController SDL_GameController;
59 
60 
61 typedef enum
62 {
63  SDL_CONTROLLER_BINDTYPE_NONE = 0,
64  SDL_CONTROLLER_BINDTYPE_BUTTON,
65  SDL_CONTROLLER_BINDTYPE_AXIS,
66  SDL_CONTROLLER_BINDTYPE_HAT
67 } SDL_GameControllerBindType;
68 
73 {
74  SDL_GameControllerBindType bindType;
75  union
76  {
77  int button;
78  int axis;
79  struct {
80  int hat;
81  int hat_mask;
82  } hat;
83  } value;
84 
86 
87 
122 extern DECLSPEC int SDLCALL SDL_GameControllerAddMappingsFromRW(SDL_RWops * rw, int freerw);
123 
129 #define SDL_GameControllerAddMappingsFromFile(file) SDL_GameControllerAddMappingsFromRW(SDL_RWFromFile(file, "rb"), 1)
130 
136 extern DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char* mappingString);
137 
143 extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void);
144 
150 extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForIndex(int mapping_index);
151 
157 extern DECLSPEC char * SDLCALL SDL_GameControllerMappingForGUID(SDL_JoystickGUID guid);
158 
164 extern DECLSPEC char * SDLCALL SDL_GameControllerMapping(SDL_GameController * gamecontroller);
165 
169 extern DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index);
170 
176 extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index);
177 
187 extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index);
188 
192 extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid);
193 
197 extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller);
198 
203 extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller);
204 
209 extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller);
210 
215 extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller);
216 
221 extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller);
222 
226 extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller);
227 
237 extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state);
238 
245 extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void);
246 
247 
257 typedef enum
258 {
259  SDL_CONTROLLER_AXIS_INVALID = -1,
260  SDL_CONTROLLER_AXIS_LEFTX,
261  SDL_CONTROLLER_AXIS_LEFTY,
262  SDL_CONTROLLER_AXIS_RIGHTX,
263  SDL_CONTROLLER_AXIS_RIGHTY,
264  SDL_CONTROLLER_AXIS_TRIGGERLEFT,
265  SDL_CONTROLLER_AXIS_TRIGGERRIGHT,
266  SDL_CONTROLLER_AXIS_MAX
268 
272 extern DECLSPEC SDL_GameControllerAxis SDLCALL SDL_GameControllerGetAxisFromString(const char *pchString);
273 
277 extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForAxis(SDL_GameControllerAxis axis);
278 
282 extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
283 SDL_GameControllerGetBindForAxis(SDL_GameController *gamecontroller,
284  SDL_GameControllerAxis axis);
285 
294 extern DECLSPEC Sint16 SDLCALL
295 SDL_GameControllerGetAxis(SDL_GameController *gamecontroller,
296  SDL_GameControllerAxis axis);
297 
301 typedef enum
302 {
303  SDL_CONTROLLER_BUTTON_INVALID = -1,
304  SDL_CONTROLLER_BUTTON_A,
305  SDL_CONTROLLER_BUTTON_B,
306  SDL_CONTROLLER_BUTTON_X,
307  SDL_CONTROLLER_BUTTON_Y,
308  SDL_CONTROLLER_BUTTON_BACK,
309  SDL_CONTROLLER_BUTTON_GUIDE,
310  SDL_CONTROLLER_BUTTON_START,
311  SDL_CONTROLLER_BUTTON_LEFTSTICK,
312  SDL_CONTROLLER_BUTTON_RIGHTSTICK,
313  SDL_CONTROLLER_BUTTON_LEFTSHOULDER,
314  SDL_CONTROLLER_BUTTON_RIGHTSHOULDER,
315  SDL_CONTROLLER_BUTTON_DPAD_UP,
316  SDL_CONTROLLER_BUTTON_DPAD_DOWN,
317  SDL_CONTROLLER_BUTTON_DPAD_LEFT,
318  SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
319  SDL_CONTROLLER_BUTTON_MAX
321 
325 extern DECLSPEC SDL_GameControllerButton SDLCALL SDL_GameControllerGetButtonFromString(const char *pchString);
326 
330 extern DECLSPEC const char* SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button);
331 
335 extern DECLSPEC SDL_GameControllerButtonBind SDLCALL
336 SDL_GameControllerGetBindForButton(SDL_GameController *gamecontroller,
337  SDL_GameControllerButton button);
338 
339 
345 extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller,
346  SDL_GameControllerButton button);
347 
351 extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller);
352 
353 
354 /* Ends C function definitions when using C++ */
355 #ifdef __cplusplus
356 }
357 #endif
358 #include "close_code.h"
359 
360 #endif /* SDL_gamecontroller_h_ */
361 
362 /* vi: set ts=4 sw=4 expandtab: */
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 Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController *gamecontroller)
DECLSPEC const char *SDLCALL SDL_GameControllerGetStringForButton(SDL_GameControllerButton button)
Definition: SDL_gamecontroller.h:72
SDL_GameControllerButton
Definition: SDL_gamecontroller.h:301
DECLSPEC int SDLCALL SDL_GameControllerAddMapping(const char *mappingString)
DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller)
SDL_GameControllerAxis
Definition: SDL_gamecontroller.h:257
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)
DECLSPEC int SDLCALL SDL_GameControllerNumMappings(void)
Definition: SDL_joystick.h:70
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:81
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 Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController *gamecontroller)
DECLSPEC SDL_bool SDLCALL SDL_IsGameController(int joystick_index)
DECLSPEC Sint16 SDLCALL SDL_GameControllerGetAxis(SDL_GameController *gamecontroller, SDL_GameControllerAxis axis)
DECLSPEC char *SDLCALL SDL_GameControllerMappingForIndex(int mapping_index)
DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index)
Definition: SDL_rwops.h:52