My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
SDL_joystick.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2014 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 
39 #ifndef _SDL_joystick_h
40 #define _SDL_joystick_h
41 
42 #include "SDL_stdinc.h"
43 #include "SDL_error.h"
44 
45 #include "begin_code.h"
46 /* Set up for C function definitions, even when using C++ */
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
63 /* The joystick structure used to identify an SDL joystick */
64 struct _SDL_Joystick;
65 typedef struct _SDL_Joystick SDL_Joystick;
66 
67 /* A structure that encodes the stable unique id for a joystick device */
68 typedef struct {
69  Uint8 data[16];
71 
72 typedef Sint32 SDL_JoystickID;
73 
74 
75 /* Function prototypes */
79 extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
80 
86 extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
87 
96 extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
97 
102 extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
103 
107 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
108 
112 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
113 
118 extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
119 
123 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
124 
128 extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
129 
133 extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
134 
138 extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
139 
146 extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
147 
151 extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
152 
156 extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
157 
164 extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
165 
175 extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
176 
184 extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
185  int axis);
186 
190 /* @{ */
191 #define SDL_HAT_CENTERED 0x00
192 #define SDL_HAT_UP 0x01
193 #define SDL_HAT_RIGHT 0x02
194 #define SDL_HAT_DOWN 0x04
195 #define SDL_HAT_LEFT 0x08
196 #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
197 #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
198 #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
199 #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
200 /* @} */
201 
218 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
219  int hat);
220 
228 extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
229  int ball, int *dx, int *dy);
230 
236 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
237  int button);
238 
242 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
243 
244 
245 /* Ends C function definitions when using C++ */
246 #ifdef __cplusplus
247 }
248 #endif
249 #include "close_code.h"
250 
251 #endif /* _SDL_joystick_h */
252 
253 /* vi: set ts=4 sw=4 expandtab: */
DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick *joystick)
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID)
DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index)
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index)
DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick *joystick)
DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick *joystick)
DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick)
DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
Definition: SDL_joystick.h:68
DECLSPEC int SDLCALL SDL_NumJoysticks(void)
DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index)
DECLSPEC int SDLCALL SDL_JoystickEventState(int state)
DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID)
DECLSPEC void SDLCALL SDL_JoystickUpdate(void)
DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick *joystick)
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick)