SDL  2.0
SDL_joystick_c.h
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2020 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 
22 #ifndef SDL_joystick_c_h_
23 #define SDL_joystick_c_h_
24 
25 #include "../SDL_internal.h"
26 
27 /* Useful functions and variables from SDL_joystick.c */
28 #include "SDL_gamecontroller.h"
29 #include "SDL_joystick.h"
30 
31 struct _SDL_JoystickDriver;
32 
33 /* Initialization and shutdown functions */
34 extern int SDL_JoystickInit(void);
35 extern void SDL_JoystickQuit(void);
36 
37 /* Function to get the next available joystick instance ID */
39 
40 /* Initialization and shutdown functions */
41 extern int SDL_GameControllerInitMappings(void);
42 extern void SDL_GameControllerQuitMappings(void);
43 extern int SDL_GameControllerInit(void);
44 extern void SDL_GameControllerQuit(void);
45 
46 /* Function to get the joystick driver and device index for an API device index */
47 extern SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, struct _SDL_JoystickDriver **driver, int *driver_index);
48 
49 /* Function to return the device index for a joystick ID, or -1 if not found */
51 
52 /* Function to extract information from an SDL joystick GUID */
53 extern void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version);
54 
55 /* Function to standardize the name for a controller
56  This should be freed with SDL_free() when no longer needed
57  */
58 extern char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name);
59 
60 /* Function to return the type of a controller */
63 extern SDL_GameControllerType SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol);
64 
65 /* Function to return whether a joystick is an Xbox One Elite controller */
66 extern SDL_bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id);
67 
68 /* Function to return whether a joystick is an Xbox One Series X controller */
69 extern SDL_bool SDL_IsJoystickXboxOneSeriesX(Uint16 vendor_id, Uint16 product_id);
70 
71 /* Function to return whether a joystick is a PS4 controller */
72 extern SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id);
73 
74 /* Function to return whether a joystick is a PS5 controller */
75 extern SDL_bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id);
76 
77 /* Function to return whether a joystick is a Nintendo Switch Pro controller */
78 extern SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id);
80 
81 /* Function to return whether a joystick is a Steam Controller */
82 extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);
83 
84 /* Function to return whether a joystick guid comes from the XInput driver */
86 
87 /* Function to return whether a joystick guid comes from the WGI driver */
89 
90 /* Function to return whether a joystick guid comes from the HIDAPI driver */
92 
93 /* Function to return whether a joystick guid comes from the RAWINPUT driver */
95 
96 /* Function to return whether a joystick guid comes from the Virtual driver */
98 
99 /* Function to return whether a joystick should be ignored */
100 extern SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid);
101 
102 /* Function to return whether a joystick name and GUID is a game controller */
104 
105 /* Function to return whether a game controller should be ignored */
107 
108 /* Handle delayed guide button on a game controller */
109 extern void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick);
110 
111 /* Internal event queueing functions */
112 extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers);
113 extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type);
114 extern void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance);
115 extern void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance);
116 extern int SDL_PrivateJoystickAxis(SDL_Joystick *joystick,
118 extern int SDL_PrivateJoystickBall(SDL_Joystick *joystick,
119  Uint8 ball, Sint16 xrel, Sint16 yrel);
120 extern int SDL_PrivateJoystickHat(SDL_Joystick *joystick,
121  Uint8 hat, Uint8 value);
122 extern int SDL_PrivateJoystickButton(SDL_Joystick *joystick,
124 extern int SDL_PrivateJoystickTouchpad(SDL_Joystick *joystick,
125  int touchpad, int finger, Uint8 state, float x, float y, float pressure);
126 extern int SDL_PrivateJoystickSensor(SDL_Joystick *joystick,
127  SDL_SensorType type, const float *data, int num_values);
128 extern void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick,
129  SDL_JoystickPowerLevel ePowerLevel);
130 
131 /* Internal sanity checking functions */
132 extern SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick);
133 
134 typedef enum
135 {
139  EMappingKind_Hat = 3
141 
142 typedef struct _SDL_InputMapping
143 {
147 
148 typedef struct _SDL_GamepadMapping
149 {
172 
173 /* Function to get autodetected gamepad controller mapping from the driver */
174 extern SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(int device_index,
175  SDL_GamepadMapping *out);
176 
177 #endif /* SDL_joystick_c_h_ */
178 
179 /* vi: set ts=4 sw=4 expandtab: */
SDL_GameControllerType
SDL_JoystickPowerLevel
Definition: SDL_joystick.h:98
Sint32 SDL_JoystickID
Definition: SDL_joystick.h:81
int SDL_PrivateJoystickTouchpad(SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure)
void SDL_GameControllerQuit(void)
int SDL_GameControllerInit(void)
void SDL_GameControllerHandleDelayedGuideButton(SDL_Joystick *joystick)
void SDL_GameControllerQuitMappings(void)
SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromVIDPID(Uint16 vendor, Uint16 product)
int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel)
SDL_bool SDL_IsJoystickVirtual(SDL_JoystickGUID guid)
void SDL_PrivateJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
SDL_bool SDL_IsGameControllerNameAndGUID(const char *name, SDL_JoystickGUID guid)
int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
void SDL_PrivateJoystickRemoved(SDL_JoystickID device_instance)
int SDL_JoystickInit(void)
Definition: SDL_joystick.c:213
EMappingKind
@ EMappingKind_Hat
@ EMappingKind_Button
@ EMappingKind_Axis
@ EMappingKind_None
SDL_bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id)
SDL_bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id)
SDL_bool SDL_IsJoystickHIDAPI(SDL_JoystickGUID guid)
int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
SDL_bool SDL_ShouldIgnoreJoystick(const char *name, SDL_JoystickGUID guid)
void SDL_JoystickQuit(void)
SDL_bool SDL_IsJoystickWGI(SDL_JoystickGUID guid)
SDL_bool SDL_GetDriverAndJoystickIndex(int device_index, struct _SDL_JoystickDriver **driver, int *driver_index)
SDL_bool SDL_IsJoystickRAWINPUT(SDL_JoystickGUID guid)
SDL_bool SDL_PrivateJoystickGetAutoGamepadMapping(int device_index, SDL_GamepadMapping *out)
Definition: SDL_joystick.c:574
void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers)
SDL_GameControllerType SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGUID guid, const char *name)
SDL_JoystickID SDL_GetNextJoystickInstanceID(void)
Definition: SDL_joystick.c:262
void SDL_PrivateJoystickAdded(SDL_JoystickID device_instance)
SDL_GameControllerType SDL_GetJoystickGameControllerType(const char *name, Uint16 vendor, Uint16 product, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
void SDL_GetJoystickGUIDInfo(SDL_JoystickGUID guid, Uint16 *vendor, Uint16 *product, Uint16 *version)
int SDL_PrivateJoystickSensor(SDL_Joystick *joystick, SDL_SensorType type, const float *data, int num_values)
SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid)
void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type)
SDL_bool SDL_IsJoystickXboxOneSeriesX(Uint16 vendor_id, Uint16 product_id)
SDL_bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id)
int SDL_JoystickGetDeviceIndexFromInstanceID(SDL_JoystickID instance_id)
SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid)
SDL_bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id)
SDL_bool SDL_PrivateJoystickValid(SDL_Joystick *joystick)
Definition: SDL_joystick.c:559
SDL_bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id)
int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
int SDL_GameControllerInitMappings(void)
SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id)
char * SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name)
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLuint GLuint GLsizei GLenum type
Definition: SDL_opengl.h:1571
GLuint const GLchar * name
GLsizei const GLfloat * value
SDL_SensorType
Definition: SDL_sensor.h:70
uint16_t Uint16
Definition: SDL_stdinc.h:197
int16_t Sint16
Definition: SDL_stdinc.h:191
SDL_bool
Definition: SDL_stdinc.h:168
uint8_t Uint8
Definition: SDL_stdinc.h:185
struct xkb_state * state
SDL_InputMapping rightshoulder
SDL_InputMapping leftx
SDL_InputMapping guide
SDL_InputMapping righttrigger
SDL_InputMapping dpup
SDL_InputMapping a
SDL_InputMapping rightx
SDL_InputMapping rightstick
SDL_InputMapping righty
SDL_InputMapping b
SDL_InputMapping leftshoulder
SDL_InputMapping lefttrigger
SDL_InputMapping start
SDL_InputMapping lefty
SDL_InputMapping leftstick
SDL_InputMapping dpdown
SDL_InputMapping x
SDL_InputMapping dpright
SDL_InputMapping back
SDL_InputMapping dpleft
SDL_InputMapping y
EMappingKind kind
SDL_Texture * button
SDL_Texture * axis
static SDL_Joystick * joystick
Definition: testjoystick.c:37