SDL  2.0
SDL_sysjoystick.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 #include "../SDL_internal.h"
22 
23 #ifndef _SDL_sysjoystick_h
24 #define _SDL_sysjoystick_h
25 
26 /* This is the system specific header for the SDL joystick API */
27 
28 #include "SDL_joystick.h"
29 #include "SDL_joystick_c.h"
30 
31 /* The SDL joystick structure */
33 {
34  SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
35  char *name; /* Joystick name - system dependent */
36 
37  int naxes; /* Number of axis controls on the joystick */
38  Sint16 *axes; /* Current axis states */
39 
40  int nhats; /* Number of hats on the joystick */
41  Uint8 *hats; /* Current hat states */
42 
43  int nballs; /* Number of trackballs on the joystick */
44  struct balldelta {
45  int dx;
46  int dy;
47  } *balls; /* Current ball motion deltas */
48 
49  int nbuttons; /* Number of buttons on the joystick */
50  Uint8 *buttons; /* Current button states */
51 
52  struct joystick_hwdata *hwdata; /* Driver dependent information */
53 
54  int ref_count; /* Reference count for multiple opens */
55 
56  SDL_bool force_recentering; /* SDL_TRUE if this device needs to have its state reset to 0 */
57  SDL_JoystickPowerLevel epowerlevel; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
58  struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
59 };
60 
61 /* Function to scan the system for joysticks.
62  * Joystick 0 should be the system default joystick.
63  * This function should return the number of available joysticks, or -1
64  * on an unrecoverable fatal error.
65  */
66 extern int SDL_SYS_JoystickInit(void);
67 
68 /* Function to return the number of joystick devices plugged in right now */
69 extern int SDL_SYS_NumJoysticks();
70 
71 /* Function to cause any queued joystick insertions to be processed */
72 extern void SDL_SYS_JoystickDetect();
73 
74 /* Function to get the device-dependent name of a joystick */
75 extern const char *SDL_SYS_JoystickNameForDeviceIndex(int device_index);
76 
77 /* Function to get the current instance id of the joystick located at device_index */
78 extern SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index);
79 
80 /* Function to open a joystick for use.
81  The joystick to open is specified by the device index.
82  This should fill the nbuttons and naxes fields of the joystick structure.
83  It returns 0, or -1 if there is an error.
84  */
85 extern int SDL_SYS_JoystickOpen(SDL_Joystick * joystick, int device_index);
86 
87 /* Function to query if the joystick is currently attached
88  * It returns SDL_TRUE if attached, SDL_FALSE otherwise.
89  */
90 extern SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick * joystick);
91 
92 /* Function to update the state of a joystick - called as a device poll.
93  * This function shouldn't update the joystick structure directly,
94  * but instead should call SDL_PrivateJoystick*() to deliver events
95  * and update joystick device state.
96  */
97 extern void SDL_SYS_JoystickUpdate(SDL_Joystick * joystick);
98 
99 /* Function to close a joystick after use */
100 extern void SDL_SYS_JoystickClose(SDL_Joystick * joystick);
101 
102 /* Function to perform any system-specific joystick related cleanup */
103 extern void SDL_SYS_JoystickQuit(void);
104 
105 /* Function to return the stable GUID for a plugged in device */
106 extern SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index);
107 
108 /* Function to return the stable GUID for a opened joystick */
109 extern SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick * joystick);
110 
111 #if SDL_JOYSTICK_XINPUT
112 /* Function returns SDL_TRUE if this device is an XInput gamepad */
113 extern SDL_bool SDL_SYS_IsXInputGamepad_DeviceIndex(int device_index);
114 #endif
115 
116 #endif /* _SDL_sysjoystick_h */
117 
118 /* vi: set ts=4 sw=4 expandtab: */
SDL_JoystickID instance_id
SDL_bool SDL_SYS_JoystickAttached(SDL_Joystick *joystick)
SDL_bool
Definition: SDL_stdinc.h:126
SDL_bool force_recentering
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
struct joystick_hwdata * hwdata
struct _SDL_Joystick * next
SDL_JoystickGUID SDL_SYS_JoystickGetDeviceGUID(int device_index)
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:72
uint8_t Uint8
An unsigned 8-bit integer type.
Definition: SDL_stdinc.h:139
SDL_JoystickID SDL_SYS_GetInstanceIdOfDeviceIndex(int device_index)
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick, int device_index)
SDL_JoystickGUID SDL_SYS_JoystickGetGUID(SDL_Joystick *joystick)
const char * SDL_SYS_JoystickNameForDeviceIndex(int device_index)
SDL_JoystickPowerLevel epowerlevel
SDL_JoystickPowerLevel
Definition: SDL_joystick.h:74
void SDL_SYS_JoystickQuit(void)
int SDL_SYS_NumJoysticks()
struct _SDL_Joystick::balldelta * balls
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
void SDL_SYS_JoystickDetect()
int16_t Sint16
A signed 16-bit integer type.
Definition: SDL_stdinc.h:143
int SDL_SYS_JoystickInit(void)