My Project
SDL_joystick.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 
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 typedef enum
75 {
76  SDL_JOYSTICK_POWER_UNKNOWN = -1,
77  SDL_JOYSTICK_POWER_EMPTY,
78  SDL_JOYSTICK_POWER_LOW,
79  SDL_JOYSTICK_POWER_MEDIUM,
80  SDL_JOYSTICK_POWER_FULL,
81  SDL_JOYSTICK_POWER_WIRED,
82  SDL_JOYSTICK_POWER_MAX
83 } SDL_JoystickPowerLevel;
84 
85 /* Function prototypes */
89 extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
90 
96 extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
97 
107 extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
108 
112 extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID joyid);
113 
118 extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
119 
123 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
124 
128 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
129 
134 extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
135 
139 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
140 
144 extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
145 
149 extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
150 
154 extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
155 
162 extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
163 
167 extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
168 
172 extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
173 
180 extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
181 
191 extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
192 
200 extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
201  int axis);
202 
206 /* @{ */
207 #define SDL_HAT_CENTERED 0x00
208 #define SDL_HAT_UP 0x01
209 #define SDL_HAT_RIGHT 0x02
210 #define SDL_HAT_DOWN 0x04
211 #define SDL_HAT_LEFT 0x08
212 #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
213 #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
214 #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
215 #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
216 /* @} */
217 
234 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
235  int hat);
236 
244 extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
245  int ball, int *dx, int *dy);
246 
252 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
253  int button);
254 
258 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
259 
263 extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick);
264 
265 /* Ends C function definitions when using C++ */
266 #ifdef __cplusplus
267 }
268 #endif
269 #include "close_code.h"
270 
271 #endif /* _SDL_joystick_h */
272 
273 /* vi: set ts=4 sw=4 expandtab: */
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:143
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 SDL_JoystickPowerLevel SDLCALL SDL_JoystickCurrentPowerLevel(SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick *joystick)
int32_t Sint32
A signed 32-bit integer type.
Definition: SDL_stdinc.h:155
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)
int16_t Sint16
A signed 16-bit integer type.
Definition: SDL_stdinc.h:147
DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick *joystick)
DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick *joystick)
DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickFromInstanceID(SDL_JoystickID joyid)