SDL Library

Dependents:   H261_decoder

Committer:
miruga27
Date:
Thu Sep 22 00:03:09 2016 +0000
Revision:
0:7fb6877b5d7c
SDL

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miruga27 0:7fb6877b5d7c 1 /*
miruga27 0:7fb6877b5d7c 2 Simple DirectMedia Layer
miruga27 0:7fb6877b5d7c 3 Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
miruga27 0:7fb6877b5d7c 4
miruga27 0:7fb6877b5d7c 5 This software is provided 'as-is', without any express or implied
miruga27 0:7fb6877b5d7c 6 warranty. In no event will the authors be held liable for any damages
miruga27 0:7fb6877b5d7c 7 arising from the use of this software.
miruga27 0:7fb6877b5d7c 8
miruga27 0:7fb6877b5d7c 9 Permission is granted to anyone to use this software for any purpose,
miruga27 0:7fb6877b5d7c 10 including commercial applications, and to alter it and redistribute it
miruga27 0:7fb6877b5d7c 11 freely, subject to the following restrictions:
miruga27 0:7fb6877b5d7c 12
miruga27 0:7fb6877b5d7c 13 1. The origin of this software must not be misrepresented; you must not
miruga27 0:7fb6877b5d7c 14 claim that you wrote the original software. If you use this software
miruga27 0:7fb6877b5d7c 15 in a product, an acknowledgment in the product documentation would be
miruga27 0:7fb6877b5d7c 16 appreciated but is not required.
miruga27 0:7fb6877b5d7c 17 2. Altered source versions must be plainly marked as such, and must not be
miruga27 0:7fb6877b5d7c 18 misrepresented as being the original software.
miruga27 0:7fb6877b5d7c 19 3. This notice may not be removed or altered from any source distribution.
miruga27 0:7fb6877b5d7c 20 */
miruga27 0:7fb6877b5d7c 21
miruga27 0:7fb6877b5d7c 22 /**
miruga27 0:7fb6877b5d7c 23 * \file SDL_joystick.h
miruga27 0:7fb6877b5d7c 24 *
miruga27 0:7fb6877b5d7c 25 * Include file for SDL joystick event handling
miruga27 0:7fb6877b5d7c 26 *
miruga27 0:7fb6877b5d7c 27 * The term "device_index" identifies currently plugged in joystick devices between 0 and SDL_NumJoysticks, with the exact joystick
miruga27 0:7fb6877b5d7c 28 * behind a device_index changing as joysticks are plugged and unplugged.
miruga27 0:7fb6877b5d7c 29 *
miruga27 0:7fb6877b5d7c 30 * The term "instance_id" is the current instantiation of a joystick device in the system, if the joystick is removed and then re-inserted
miruga27 0:7fb6877b5d7c 31 * then it will get a new instance_id, instance_id's are monotonically increasing identifiers of a joystick plugged in.
miruga27 0:7fb6877b5d7c 32 *
miruga27 0:7fb6877b5d7c 33 * The term JoystickGUID is a stable 128-bit identifier for a joystick device that does not change over time, it identifies class of
miruga27 0:7fb6877b5d7c 34 * the device (a X360 wired controller for example). This identifier is platform dependent.
miruga27 0:7fb6877b5d7c 35 *
miruga27 0:7fb6877b5d7c 36 *
miruga27 0:7fb6877b5d7c 37 */
miruga27 0:7fb6877b5d7c 38
miruga27 0:7fb6877b5d7c 39 #ifndef _SDL_joystick_h
miruga27 0:7fb6877b5d7c 40 #define _SDL_joystick_h
miruga27 0:7fb6877b5d7c 41
miruga27 0:7fb6877b5d7c 42 #include "SDL_stdinc.h"
miruga27 0:7fb6877b5d7c 43 #include "SDL_error.h"
miruga27 0:7fb6877b5d7c 44
miruga27 0:7fb6877b5d7c 45 #include "begin_code.h"
miruga27 0:7fb6877b5d7c 46 /* Set up for C function definitions, even when using C++ */
miruga27 0:7fb6877b5d7c 47 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 48 extern "C" {
miruga27 0:7fb6877b5d7c 49 #endif
miruga27 0:7fb6877b5d7c 50
miruga27 0:7fb6877b5d7c 51 /**
miruga27 0:7fb6877b5d7c 52 * \file SDL_joystick.h
miruga27 0:7fb6877b5d7c 53 *
miruga27 0:7fb6877b5d7c 54 * In order to use these functions, SDL_Init() must have been called
miruga27 0:7fb6877b5d7c 55 * with the ::SDL_INIT_JOYSTICK flag. This causes SDL to scan the system
miruga27 0:7fb6877b5d7c 56 * for joysticks, and load appropriate drivers.
miruga27 0:7fb6877b5d7c 57 *
miruga27 0:7fb6877b5d7c 58 * If you would like to receive joystick updates while the application
miruga27 0:7fb6877b5d7c 59 * is in the background, you should set the following hint before calling
miruga27 0:7fb6877b5d7c 60 * SDL_Init(): SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS
miruga27 0:7fb6877b5d7c 61 */
miruga27 0:7fb6877b5d7c 62
miruga27 0:7fb6877b5d7c 63 /* The joystick structure used to identify an SDL joystick */
miruga27 0:7fb6877b5d7c 64 struct _SDL_Joystick;
miruga27 0:7fb6877b5d7c 65 typedef struct _SDL_Joystick SDL_Joystick;
miruga27 0:7fb6877b5d7c 66
miruga27 0:7fb6877b5d7c 67 /* A structure that encodes the stable unique id for a joystick device */
miruga27 0:7fb6877b5d7c 68 typedef struct {
miruga27 0:7fb6877b5d7c 69 Uint8 data[16];
miruga27 0:7fb6877b5d7c 70 } SDL_JoystickGUID;
miruga27 0:7fb6877b5d7c 71
miruga27 0:7fb6877b5d7c 72 typedef Sint32 SDL_JoystickID;
miruga27 0:7fb6877b5d7c 73
miruga27 0:7fb6877b5d7c 74
miruga27 0:7fb6877b5d7c 75 /* Function prototypes */
miruga27 0:7fb6877b5d7c 76 /**
miruga27 0:7fb6877b5d7c 77 * Count the number of joysticks attached to the system right now
miruga27 0:7fb6877b5d7c 78 */
miruga27 0:7fb6877b5d7c 79 extern DECLSPEC int SDLCALL SDL_NumJoysticks(void);
miruga27 0:7fb6877b5d7c 80
miruga27 0:7fb6877b5d7c 81 /**
miruga27 0:7fb6877b5d7c 82 * Get the implementation dependent name of a joystick.
miruga27 0:7fb6877b5d7c 83 * This can be called before any joysticks are opened.
miruga27 0:7fb6877b5d7c 84 * If no name can be found, this function returns NULL.
miruga27 0:7fb6877b5d7c 85 */
miruga27 0:7fb6877b5d7c 86 extern DECLSPEC const char *SDLCALL SDL_JoystickNameForIndex(int device_index);
miruga27 0:7fb6877b5d7c 87
miruga27 0:7fb6877b5d7c 88 /**
miruga27 0:7fb6877b5d7c 89 * Open a joystick for use.
miruga27 0:7fb6877b5d7c 90 * The index passed as an argument refers tothe N'th joystick on the system.
miruga27 0:7fb6877b5d7c 91 * This index is the value which will identify this joystick in future joystick
miruga27 0:7fb6877b5d7c 92 * events.
miruga27 0:7fb6877b5d7c 93 *
miruga27 0:7fb6877b5d7c 94 * \return A joystick identifier, or NULL if an error occurred.
miruga27 0:7fb6877b5d7c 95 */
miruga27 0:7fb6877b5d7c 96 extern DECLSPEC SDL_Joystick *SDLCALL SDL_JoystickOpen(int device_index);
miruga27 0:7fb6877b5d7c 97
miruga27 0:7fb6877b5d7c 98 /**
miruga27 0:7fb6877b5d7c 99 * Return the name for this currently opened joystick.
miruga27 0:7fb6877b5d7c 100 * If no name can be found, this function returns NULL.
miruga27 0:7fb6877b5d7c 101 */
miruga27 0:7fb6877b5d7c 102 extern DECLSPEC const char *SDLCALL SDL_JoystickName(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 103
miruga27 0:7fb6877b5d7c 104 /**
miruga27 0:7fb6877b5d7c 105 * Return the GUID for the joystick at this index
miruga27 0:7fb6877b5d7c 106 */
miruga27 0:7fb6877b5d7c 107 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetDeviceGUID(int device_index);
miruga27 0:7fb6877b5d7c 108
miruga27 0:7fb6877b5d7c 109 /**
miruga27 0:7fb6877b5d7c 110 * Return the GUID for this opened joystick
miruga27 0:7fb6877b5d7c 111 */
miruga27 0:7fb6877b5d7c 112 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUID(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 113
miruga27 0:7fb6877b5d7c 114 /**
miruga27 0:7fb6877b5d7c 115 * Return a string representation for this guid. pszGUID must point to at least 33 bytes
miruga27 0:7fb6877b5d7c 116 * (32 for the string plus a NULL terminator).
miruga27 0:7fb6877b5d7c 117 */
miruga27 0:7fb6877b5d7c 118 extern DECLSPEC void SDLCALL SDL_JoystickGetGUIDString(SDL_JoystickGUID guid, char *pszGUID, int cbGUID);
miruga27 0:7fb6877b5d7c 119
miruga27 0:7fb6877b5d7c 120 /**
miruga27 0:7fb6877b5d7c 121 * convert a string into a joystick formatted guid
miruga27 0:7fb6877b5d7c 122 */
miruga27 0:7fb6877b5d7c 123 extern DECLSPEC SDL_JoystickGUID SDLCALL SDL_JoystickGetGUIDFromString(const char *pchGUID);
miruga27 0:7fb6877b5d7c 124
miruga27 0:7fb6877b5d7c 125 /**
miruga27 0:7fb6877b5d7c 126 * Returns SDL_TRUE if the joystick has been opened and currently connected, or SDL_FALSE if it has not.
miruga27 0:7fb6877b5d7c 127 */
miruga27 0:7fb6877b5d7c 128 extern DECLSPEC SDL_bool SDLCALL SDL_JoystickGetAttached(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 129
miruga27 0:7fb6877b5d7c 130 /**
miruga27 0:7fb6877b5d7c 131 * Get the instance ID of an opened joystick or -1 if the joystick is invalid.
miruga27 0:7fb6877b5d7c 132 */
miruga27 0:7fb6877b5d7c 133 extern DECLSPEC SDL_JoystickID SDLCALL SDL_JoystickInstanceID(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 134
miruga27 0:7fb6877b5d7c 135 /**
miruga27 0:7fb6877b5d7c 136 * Get the number of general axis controls on a joystick.
miruga27 0:7fb6877b5d7c 137 */
miruga27 0:7fb6877b5d7c 138 extern DECLSPEC int SDLCALL SDL_JoystickNumAxes(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 139
miruga27 0:7fb6877b5d7c 140 /**
miruga27 0:7fb6877b5d7c 141 * Get the number of trackballs on a joystick.
miruga27 0:7fb6877b5d7c 142 *
miruga27 0:7fb6877b5d7c 143 * Joystick trackballs have only relative motion events associated
miruga27 0:7fb6877b5d7c 144 * with them and their state cannot be polled.
miruga27 0:7fb6877b5d7c 145 */
miruga27 0:7fb6877b5d7c 146 extern DECLSPEC int SDLCALL SDL_JoystickNumBalls(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 147
miruga27 0:7fb6877b5d7c 148 /**
miruga27 0:7fb6877b5d7c 149 * Get the number of POV hats on a joystick.
miruga27 0:7fb6877b5d7c 150 */
miruga27 0:7fb6877b5d7c 151 extern DECLSPEC int SDLCALL SDL_JoystickNumHats(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 152
miruga27 0:7fb6877b5d7c 153 /**
miruga27 0:7fb6877b5d7c 154 * Get the number of buttons on a joystick.
miruga27 0:7fb6877b5d7c 155 */
miruga27 0:7fb6877b5d7c 156 extern DECLSPEC int SDLCALL SDL_JoystickNumButtons(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 157
miruga27 0:7fb6877b5d7c 158 /**
miruga27 0:7fb6877b5d7c 159 * Update the current state of the open joysticks.
miruga27 0:7fb6877b5d7c 160 *
miruga27 0:7fb6877b5d7c 161 * This is called automatically by the event loop if any joystick
miruga27 0:7fb6877b5d7c 162 * events are enabled.
miruga27 0:7fb6877b5d7c 163 */
miruga27 0:7fb6877b5d7c 164 extern DECLSPEC void SDLCALL SDL_JoystickUpdate(void);
miruga27 0:7fb6877b5d7c 165
miruga27 0:7fb6877b5d7c 166 /**
miruga27 0:7fb6877b5d7c 167 * Enable/disable joystick event polling.
miruga27 0:7fb6877b5d7c 168 *
miruga27 0:7fb6877b5d7c 169 * If joystick events are disabled, you must call SDL_JoystickUpdate()
miruga27 0:7fb6877b5d7c 170 * yourself and check the state of the joystick when you want joystick
miruga27 0:7fb6877b5d7c 171 * information.
miruga27 0:7fb6877b5d7c 172 *
miruga27 0:7fb6877b5d7c 173 * The state can be one of ::SDL_QUERY, ::SDL_ENABLE or ::SDL_IGNORE.
miruga27 0:7fb6877b5d7c 174 */
miruga27 0:7fb6877b5d7c 175 extern DECLSPEC int SDLCALL SDL_JoystickEventState(int state);
miruga27 0:7fb6877b5d7c 176
miruga27 0:7fb6877b5d7c 177 /**
miruga27 0:7fb6877b5d7c 178 * Get the current state of an axis control on a joystick.
miruga27 0:7fb6877b5d7c 179 *
miruga27 0:7fb6877b5d7c 180 * The state is a value ranging from -32768 to 32767.
miruga27 0:7fb6877b5d7c 181 *
miruga27 0:7fb6877b5d7c 182 * The axis indices start at index 0.
miruga27 0:7fb6877b5d7c 183 */
miruga27 0:7fb6877b5d7c 184 extern DECLSPEC Sint16 SDLCALL SDL_JoystickGetAxis(SDL_Joystick * joystick,
miruga27 0:7fb6877b5d7c 185 int axis);
miruga27 0:7fb6877b5d7c 186
miruga27 0:7fb6877b5d7c 187 /**
miruga27 0:7fb6877b5d7c 188 * \name Hat positions
miruga27 0:7fb6877b5d7c 189 */
miruga27 0:7fb6877b5d7c 190 /* @{ */
miruga27 0:7fb6877b5d7c 191 #define SDL_HAT_CENTERED 0x00
miruga27 0:7fb6877b5d7c 192 #define SDL_HAT_UP 0x01
miruga27 0:7fb6877b5d7c 193 #define SDL_HAT_RIGHT 0x02
miruga27 0:7fb6877b5d7c 194 #define SDL_HAT_DOWN 0x04
miruga27 0:7fb6877b5d7c 195 #define SDL_HAT_LEFT 0x08
miruga27 0:7fb6877b5d7c 196 #define SDL_HAT_RIGHTUP (SDL_HAT_RIGHT|SDL_HAT_UP)
miruga27 0:7fb6877b5d7c 197 #define SDL_HAT_RIGHTDOWN (SDL_HAT_RIGHT|SDL_HAT_DOWN)
miruga27 0:7fb6877b5d7c 198 #define SDL_HAT_LEFTUP (SDL_HAT_LEFT|SDL_HAT_UP)
miruga27 0:7fb6877b5d7c 199 #define SDL_HAT_LEFTDOWN (SDL_HAT_LEFT|SDL_HAT_DOWN)
miruga27 0:7fb6877b5d7c 200 /* @} */
miruga27 0:7fb6877b5d7c 201
miruga27 0:7fb6877b5d7c 202 /**
miruga27 0:7fb6877b5d7c 203 * Get the current state of a POV hat on a joystick.
miruga27 0:7fb6877b5d7c 204 *
miruga27 0:7fb6877b5d7c 205 * The hat indices start at index 0.
miruga27 0:7fb6877b5d7c 206 *
miruga27 0:7fb6877b5d7c 207 * \return The return value is one of the following positions:
miruga27 0:7fb6877b5d7c 208 * - ::SDL_HAT_CENTERED
miruga27 0:7fb6877b5d7c 209 * - ::SDL_HAT_UP
miruga27 0:7fb6877b5d7c 210 * - ::SDL_HAT_RIGHT
miruga27 0:7fb6877b5d7c 211 * - ::SDL_HAT_DOWN
miruga27 0:7fb6877b5d7c 212 * - ::SDL_HAT_LEFT
miruga27 0:7fb6877b5d7c 213 * - ::SDL_HAT_RIGHTUP
miruga27 0:7fb6877b5d7c 214 * - ::SDL_HAT_RIGHTDOWN
miruga27 0:7fb6877b5d7c 215 * - ::SDL_HAT_LEFTUP
miruga27 0:7fb6877b5d7c 216 * - ::SDL_HAT_LEFTDOWN
miruga27 0:7fb6877b5d7c 217 */
miruga27 0:7fb6877b5d7c 218 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetHat(SDL_Joystick * joystick,
miruga27 0:7fb6877b5d7c 219 int hat);
miruga27 0:7fb6877b5d7c 220
miruga27 0:7fb6877b5d7c 221 /**
miruga27 0:7fb6877b5d7c 222 * Get the ball axis change since the last poll.
miruga27 0:7fb6877b5d7c 223 *
miruga27 0:7fb6877b5d7c 224 * \return 0, or -1 if you passed it invalid parameters.
miruga27 0:7fb6877b5d7c 225 *
miruga27 0:7fb6877b5d7c 226 * The ball indices start at index 0.
miruga27 0:7fb6877b5d7c 227 */
miruga27 0:7fb6877b5d7c 228 extern DECLSPEC int SDLCALL SDL_JoystickGetBall(SDL_Joystick * joystick,
miruga27 0:7fb6877b5d7c 229 int ball, int *dx, int *dy);
miruga27 0:7fb6877b5d7c 230
miruga27 0:7fb6877b5d7c 231 /**
miruga27 0:7fb6877b5d7c 232 * Get the current state of a button on a joystick.
miruga27 0:7fb6877b5d7c 233 *
miruga27 0:7fb6877b5d7c 234 * The button indices start at index 0.
miruga27 0:7fb6877b5d7c 235 */
miruga27 0:7fb6877b5d7c 236 extern DECLSPEC Uint8 SDLCALL SDL_JoystickGetButton(SDL_Joystick * joystick,
miruga27 0:7fb6877b5d7c 237 int button);
miruga27 0:7fb6877b5d7c 238
miruga27 0:7fb6877b5d7c 239 /**
miruga27 0:7fb6877b5d7c 240 * Close a joystick previously opened with SDL_JoystickOpen().
miruga27 0:7fb6877b5d7c 241 */
miruga27 0:7fb6877b5d7c 242 extern DECLSPEC void SDLCALL SDL_JoystickClose(SDL_Joystick * joystick);
miruga27 0:7fb6877b5d7c 243
miruga27 0:7fb6877b5d7c 244
miruga27 0:7fb6877b5d7c 245 /* Ends C function definitions when using C++ */
miruga27 0:7fb6877b5d7c 246 #ifdef __cplusplus
miruga27 0:7fb6877b5d7c 247 }
miruga27 0:7fb6877b5d7c 248 #endif
miruga27 0:7fb6877b5d7c 249 #include "close_code.h"
miruga27 0:7fb6877b5d7c 250
miruga27 0:7fb6877b5d7c 251 #endif /* _SDL_joystick_h */
miruga27 0:7fb6877b5d7c 252
miruga27 0:7fb6877b5d7c 253 /* vi: set ts=4 sw=4 expandtab: */