Rev 1 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1 | Rev 8 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /* |
1 | /* |
2 | Simple DirectMedia Layer |
2 | Simple DirectMedia Layer |
3 | Copyright (C) 1997- |
3 | Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org> |
4 | 4 | ||
5 | This software is provided 'as-is', without any express or implied |
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 |
6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. |
7 | arising from the use of this software. |
8 | 8 | ||
Line 172... | Line 172... | ||
172 | * Get the implementation dependent name of a game controller. |
172 | * Get the implementation dependent name of a game controller. |
173 | * This can be called before any controllers are opened. |
173 | * This can be called before any controllers are opened. |
174 | * If no name can be found, this function returns NULL. |
174 | * If no name can be found, this function returns NULL. |
175 | */ |
175 | */ |
176 | extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); |
176 | extern DECLSPEC const char *SDLCALL SDL_GameControllerNameForIndex(int joystick_index); |
- | 177 | ||
- | 178 | /** |
|
- | 179 | * Get the mapping of a game controller. |
|
- | 180 | * This can be called before any controllers are opened. |
|
- | 181 | * |
|
- | 182 | * \return the mapping string. Must be freed with SDL_free(). Returns NULL if no mapping is available |
|
- | 183 | */ |
|
- | 184 | extern DECLSPEC char *SDLCALL SDL_GameControllerMappingForDeviceIndex(int joystick_index); |
|
177 | 185 | ||
178 | /** |
186 | /** |
179 | * Open a game controller for use. |
187 | * Open a game controller for use. |
180 | * The index passed as an argument refers to the N'th game controller on the system. |
188 | * The index passed as an argument refers to the N'th game controller on the system. |
181 | * This index is not the value which will identify this controller in future |
189 | * This index is not the value which will identify this controller in future |
182 | * controller events. The joystick's instance id (::SDL_JoystickID) will be |
190 | * controller events. The joystick's instance id (::SDL_JoystickID) will be |
183 | * used there instead. |
191 | * used there instead. |
184 | * |
192 | * |
185 | * \return A controller identifier, or NULL if an error occurred. |
193 | * \return A controller identifier, or NULL if an error occurred. |
186 | */ |
194 | */ |
187 | extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); |
195 | extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerOpen(int joystick_index); |
188 | 196 | ||
189 | /** |
197 | /** |
190 | * Return the SDL_GameController associated with an instance id. |
198 | * Return the SDL_GameController associated with an instance id. |
191 | */ |
199 | */ |
192 | extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); |
200 | extern DECLSPEC SDL_GameController *SDLCALL SDL_GameControllerFromInstanceID(SDL_JoystickID joyid); |
193 | 201 | ||
194 | /** |
202 | /** |
195 | * Return the name for this currently opened controller |
203 | * Return the name for this currently opened controller |
196 | */ |
204 | */ |
197 | extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); |
205 | extern DECLSPEC const char *SDLCALL SDL_GameControllerName(SDL_GameController *gamecontroller); |
198 | 206 | ||
- | 207 | /** |
|
- | 208 | * Get the player index of an opened game controller, or -1 if it's not available |
|
- | 209 | * |
|
- | 210 | * For XInput controllers this returns the XInput user index. |
|
- | 211 | */ |
|
- | 212 | extern DECLSPEC int SDLCALL SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller); |
|
- | 213 | ||
199 | /** |
214 | /** |
200 | * Get the USB vendor ID of an opened controller, if available. |
215 | * Get the USB vendor ID of an opened controller, if available. |
201 | * If the vendor ID isn't available this function returns 0. |
216 | * If the vendor ID isn't available this function returns 0. |
202 | */ |
217 | */ |
203 | extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller); |
218 | extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetVendor(SDL_GameController * gamecontroller); |
204 | 219 | ||
205 | /** |
220 | /** |
206 | * Get the USB product ID of an opened controller, if available. |
221 | * Get the USB product ID of an opened controller, if available. |
207 | * If the product ID isn't available this function returns 0. |
222 | * If the product ID isn't available this function returns 0. |
208 | */ |
223 | */ |
209 | extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller); |
224 | extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProduct(SDL_GameController * gamecontroller); |
210 | 225 | ||
211 | /** |
226 | /** |
212 | * Get the product version of an opened controller, if available. |
227 | * Get the product version of an opened controller, if available. |
213 | * If the product version isn't available this function returns 0. |
228 | * If the product version isn't available this function returns 0. |
214 | */ |
229 | */ |
215 | extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller); |
230 | extern DECLSPEC Uint16 SDLCALL SDL_GameControllerGetProductVersion(SDL_GameController * gamecontroller); |
216 | 231 | ||
217 | /** |
232 | /** |
218 | * Returns SDL_TRUE if the controller has been opened and currently connected, |
233 | * Returns SDL_TRUE if the controller has been opened and currently connected, |
219 | * or SDL_FALSE if it has not. |
234 | * or SDL_FALSE if it has not. |
220 | */ |
235 | */ |
221 | extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); |
236 | extern DECLSPEC SDL_bool SDLCALL SDL_GameControllerGetAttached(SDL_GameController *gamecontroller); |
222 | 237 | ||
223 | /** |
238 | /** |
224 | * Get the underlying joystick object used by a controller |
239 | * Get the underlying joystick object used by a controller |
225 | */ |
240 | */ |
226 | extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); |
241 | extern DECLSPEC SDL_Joystick *SDLCALL SDL_GameControllerGetJoystick(SDL_GameController *gamecontroller); |
227 | 242 | ||
228 | /** |
243 | /** |
229 | * Enable/disable controller event polling. |
244 | * Enable/disable controller event polling. |
230 | * |
245 | * |
231 | * If controller events are disabled, you must call SDL_GameControllerUpdate() |
246 | * If controller events are disabled, you must call SDL_GameControllerUpdate() |
232 | * yourself and check the state of the controller when you want controller |
247 | * yourself and check the state of the controller when you want controller |
233 | * information. |
248 | * information. |
Line 236... | Line 251... | ||
236 | */ |
251 | */ |
237 | extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); |
252 | extern DECLSPEC int SDLCALL SDL_GameControllerEventState(int state); |
238 | 253 | ||
239 | /** |
254 | /** |
240 | * Update the current state of the open game controllers. |
255 | * Update the current state of the open game controllers. |
241 | * |
256 | * |
242 | * This is called automatically by the event loop if any game controller |
257 | * This is called automatically by the event loop if any game controller |
243 | * events are enabled. |
258 | * events are enabled. |
244 | */ |
259 | */ |
245 | extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); |
260 | extern DECLSPEC void SDLCALL SDL_GameControllerUpdate(void); |
246 | 261 | ||
Line 342... | Line 357... | ||
342 | * |
357 | * |
343 | * The button indices start at index 0. |
358 | * The button indices start at index 0. |
344 | */ |
359 | */ |
345 | extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, |
360 | extern DECLSPEC Uint8 SDLCALL SDL_GameControllerGetButton(SDL_GameController *gamecontroller, |
346 | SDL_GameControllerButton button); |
361 | SDL_GameControllerButton button); |
- | 362 | ||
- | 363 | /** |
|
- | 364 | * Trigger a rumble effect |
|
- | 365 | * Each call to this function cancels any previous rumble effect, and calling it with 0 intensity stops any rumbling. |
|
- | 366 | * |
|
- | 367 | * \param gamecontroller The controller to vibrate |
|
- | 368 | * \param low_frequency_rumble The intensity of the low frequency (left) rumble motor, from 0 to 0xFFFF |
|
- | 369 | * \param high_frequency_rumble The intensity of the high frequency (right) rumble motor, from 0 to 0xFFFF |
|
- | 370 | * \param duration_ms The duration of the rumble effect, in milliseconds |
|
- | 371 | * |
|
- | 372 | * \return 0, or -1 if rumble isn't supported on this joystick |
|
- | 373 | */ |
|
- | 374 | extern DECLSPEC int SDLCALL SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble, Uint32 duration_ms); |
|
347 | 375 | ||
348 | /** |
376 | /** |
349 | * Close a controller previously opened with SDL_GameControllerOpen(). |
377 | * Close a controller previously opened with SDL_GameControllerOpen(). |
350 | */ |
378 | */ |
351 | extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); |
379 | extern DECLSPEC void SDLCALL SDL_GameControllerClose(SDL_GameController *gamecontroller); |