diff options
Diffstat (limited to 'contrib/SDL-3.2.8/src/joystick/SDL_joystick_c.h')
| -rw-r--r-- | contrib/SDL-3.2.8/src/joystick/SDL_joystick_c.h | 270 |
1 files changed, 270 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/joystick/SDL_joystick_c.h b/contrib/SDL-3.2.8/src/joystick/SDL_joystick_c.h new file mode 100644 index 0000000..d931cf7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/joystick/SDL_joystick_c.h | |||
| @@ -0,0 +1,270 @@ | |||
| 1 | /* | ||
| 2 | Simple DirectMedia Layer | ||
| 3 | Copyright (C) 1997-2025 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 | |||
| 29 | // Set up for C function definitions, even when using C++ | ||
| 30 | #ifdef __cplusplus | ||
| 31 | extern "C" { | ||
| 32 | #endif | ||
| 33 | |||
| 34 | struct SDL_JoystickDriver; | ||
| 35 | struct SDL_SteamVirtualGamepadInfo; | ||
| 36 | |||
| 37 | // Initialization and shutdown functions | ||
| 38 | extern bool SDL_InitJoysticks(void); | ||
| 39 | extern void SDL_QuitJoysticks(void); | ||
| 40 | |||
| 41 | // Return whether the joystick system is currently initialized | ||
| 42 | extern bool SDL_JoysticksInitialized(void); | ||
| 43 | |||
| 44 | // Return whether the joystick system is shutting down | ||
| 45 | extern bool SDL_JoysticksQuitting(void); | ||
| 46 | |||
| 47 | // Return whether the joysticks are currently locked | ||
| 48 | extern bool SDL_JoysticksLocked(void); | ||
| 49 | |||
| 50 | // Make sure we currently have the joysticks locked | ||
| 51 | extern void SDL_AssertJoysticksLocked(void) SDL_ASSERT_CAPABILITY(SDL_joystick_lock); | ||
| 52 | |||
| 53 | // Function to return whether there are any joysticks opened by the application | ||
| 54 | extern bool SDL_JoysticksOpened(void); | ||
| 55 | |||
| 56 | // Function to determine whether a device is currently detected by this driver | ||
| 57 | extern bool SDL_JoystickHandledByAnotherDriver(struct SDL_JoystickDriver *driver, Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); | ||
| 58 | |||
| 59 | /* Function to standardize the name for a controller | ||
| 60 | This should be freed with SDL_free() when no longer needed | ||
| 61 | */ | ||
| 62 | extern char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_name, const char *product_name); | ||
| 63 | |||
| 64 | // Function to create a GUID for a joystick based on the VID/PID and name | ||
| 65 | extern SDL_GUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 product, Uint16 version, const char *vendor_name, const char *product_name, Uint8 driver_signature, Uint8 driver_data); | ||
| 66 | |||
| 67 | // Function to create a GUID for a joystick based on the name, with no VID/PID information | ||
| 68 | extern SDL_GUID SDL_CreateJoystickGUIDForName(const char *name); | ||
| 69 | |||
| 70 | // Function to set the vendor field of a joystick GUID | ||
| 71 | extern void SDL_SetJoystickGUIDVendor(SDL_GUID *guid, Uint16 vendor); | ||
| 72 | |||
| 73 | // Function to set the product field of a joystick GUID | ||
| 74 | extern void SDL_SetJoystickGUIDProduct(SDL_GUID *guid, Uint16 product); | ||
| 75 | |||
| 76 | // Function to set the version field of a joystick GUID | ||
| 77 | extern void SDL_SetJoystickGUIDVersion(SDL_GUID *guid, Uint16 version); | ||
| 78 | |||
| 79 | // Function to set the CRC field of a joystick GUID | ||
| 80 | extern void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc); | ||
| 81 | |||
| 82 | // Function to return the type of a controller | ||
| 83 | extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, bool forUI); | ||
| 84 | extern SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name); | ||
| 85 | |||
| 86 | // Function to return whether a joystick GUID uses the version field | ||
| 87 | extern bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid); | ||
| 88 | |||
| 89 | // Function to return whether a joystick is an Xbox One controller | ||
| 90 | extern bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); | ||
| 91 | |||
| 92 | // Function to return whether a joystick is an Xbox One Elite controller | ||
| 93 | extern bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id); | ||
| 94 | |||
| 95 | // Function to return whether a joystick is an Xbox Series X controller | ||
| 96 | extern bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id); | ||
| 97 | |||
| 98 | // Function to return whether a joystick is an Xbox One controller connected via Bluetooth | ||
| 99 | extern bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id); | ||
| 100 | |||
| 101 | // Function to return whether a joystick is a PS4 controller | ||
| 102 | extern bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); | ||
| 103 | |||
| 104 | // Function to return whether a joystick is a PS5 controller | ||
| 105 | extern bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id); | ||
| 106 | extern bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id); | ||
| 107 | |||
| 108 | // Function to return whether a joystick is a Nintendo Switch Pro controller | ||
| 109 | extern bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); | ||
| 110 | extern bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id); | ||
| 111 | extern bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id); | ||
| 112 | extern bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id); | ||
| 113 | extern bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id); | ||
| 114 | extern bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id); | ||
| 115 | extern bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id); | ||
| 116 | |||
| 117 | // Function to return whether a joystick is a Nintendo GameCube style controller | ||
| 118 | extern bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id); | ||
| 119 | |||
| 120 | // Function to return whether a joystick is an Amazon Luna controller | ||
| 121 | extern bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id); | ||
| 122 | |||
| 123 | // Function to return whether a joystick is a Google Stadia controller | ||
| 124 | extern bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id); | ||
| 125 | |||
| 126 | // Function to return whether a joystick is an NVIDIA SHIELD controller | ||
| 127 | extern bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id); | ||
| 128 | |||
| 129 | // Function to return whether a joystick is a Steam Virtual Gamepad | ||
| 130 | extern bool SDL_IsJoystickSteamVirtualGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version); | ||
| 131 | |||
| 132 | // Function to return whether a joystick is a Steam Controller | ||
| 133 | extern bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); | ||
| 134 | |||
| 135 | // Function to return whether a joystick is a HORI Steam controller | ||
| 136 | extern bool SDL_IsJoystickHoriSteamController(Uint16 vendor_id, Uint16 product_id); | ||
| 137 | |||
| 138 | // Function to return whether a joystick is a Steam Deck | ||
| 139 | extern bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); | ||
| 140 | |||
| 141 | // Function to return whether a joystick guid comes from the XInput driver | ||
| 142 | extern bool SDL_IsJoystickXInput(SDL_GUID guid); | ||
| 143 | |||
| 144 | // Function to return whether a joystick guid comes from the WGI driver | ||
| 145 | extern bool SDL_IsJoystickWGI(SDL_GUID guid); | ||
| 146 | |||
| 147 | // Function to return whether a joystick guid comes from the HIDAPI driver | ||
| 148 | extern bool SDL_IsJoystickHIDAPI(SDL_GUID guid); | ||
| 149 | |||
| 150 | // Function to return whether a joystick guid comes from the MFI driver | ||
| 151 | extern bool SDL_IsJoystickMFI(SDL_GUID guid); | ||
| 152 | |||
| 153 | // Function to return whether a joystick guid comes from the RAWINPUT driver | ||
| 154 | extern bool SDL_IsJoystickRAWINPUT(SDL_GUID guid); | ||
| 155 | |||
| 156 | // Function to return whether a joystick guid comes from the Virtual driver | ||
| 157 | extern bool SDL_IsJoystickVIRTUAL(SDL_GUID guid); | ||
| 158 | |||
| 159 | // Function to return whether a joystick should be ignored | ||
| 160 | extern bool SDL_ShouldIgnoreJoystick(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); | ||
| 161 | |||
| 162 | // Internal event queueing functions | ||
| 163 | extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers); | ||
| 164 | extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type, float rate); | ||
| 165 | extern void SDL_PrivateJoystickSensorRate(SDL_Joystick *joystick, SDL_SensorType type, float rate); | ||
| 166 | extern void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id); | ||
| 167 | extern bool SDL_IsJoystickBeingAdded(void); | ||
| 168 | extern void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id); | ||
| 169 | extern void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick); | ||
| 170 | extern void SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, Sint16 value); | ||
| 171 | extern void SDL_SendJoystickBall(Uint64 timestamp, SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel); | ||
| 172 | extern void SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uint8 value); | ||
| 173 | extern void SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 button, bool down); | ||
| 174 | extern void SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); | ||
| 175 | extern void SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); | ||
| 176 | extern void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent); | ||
| 177 | |||
| 178 | // Function to get the Steam virtual gamepad info for a joystick | ||
| 179 | extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickVirtualGamepadInfoForID(SDL_JoystickID instance_id); | ||
| 180 | |||
| 181 | // Internal sanity checking functions | ||
| 182 | extern bool SDL_IsJoystickValid(SDL_Joystick *joystick); | ||
| 183 | |||
| 184 | typedef enum | ||
| 185 | { | ||
| 186 | EMappingKind_None, | ||
| 187 | EMappingKind_Button, | ||
| 188 | EMappingKind_Axis, | ||
| 189 | EMappingKind_Hat, | ||
| 190 | } EMappingKind; | ||
| 191 | |||
| 192 | typedef struct SDL_InputMapping | ||
| 193 | { | ||
| 194 | EMappingKind kind; | ||
| 195 | Uint8 target; | ||
| 196 | bool axis_reversed; | ||
| 197 | bool half_axis_positive; | ||
| 198 | bool half_axis_negative; | ||
| 199 | } SDL_InputMapping; | ||
| 200 | |||
| 201 | typedef struct SDL_GamepadMapping | ||
| 202 | { | ||
| 203 | SDL_InputMapping a; | ||
| 204 | SDL_InputMapping b; | ||
| 205 | SDL_InputMapping x; | ||
| 206 | SDL_InputMapping y; | ||
| 207 | SDL_InputMapping back; | ||
| 208 | SDL_InputMapping guide; | ||
| 209 | SDL_InputMapping start; | ||
| 210 | SDL_InputMapping leftstick; | ||
| 211 | SDL_InputMapping rightstick; | ||
| 212 | SDL_InputMapping leftshoulder; | ||
| 213 | SDL_InputMapping rightshoulder; | ||
| 214 | SDL_InputMapping dpup; | ||
| 215 | SDL_InputMapping dpdown; | ||
| 216 | SDL_InputMapping dpleft; | ||
| 217 | SDL_InputMapping dpright; | ||
| 218 | SDL_InputMapping misc1; | ||
| 219 | SDL_InputMapping misc2; | ||
| 220 | SDL_InputMapping misc3; | ||
| 221 | SDL_InputMapping misc4; | ||
| 222 | SDL_InputMapping misc5; | ||
| 223 | SDL_InputMapping misc6; | ||
| 224 | SDL_InputMapping right_paddle1; | ||
| 225 | SDL_InputMapping left_paddle1; | ||
| 226 | SDL_InputMapping right_paddle2; | ||
| 227 | SDL_InputMapping left_paddle2; | ||
| 228 | SDL_InputMapping leftx; | ||
| 229 | SDL_InputMapping lefty; | ||
| 230 | SDL_InputMapping rightx; | ||
| 231 | SDL_InputMapping righty; | ||
| 232 | SDL_InputMapping lefttrigger; | ||
| 233 | SDL_InputMapping righttrigger; | ||
| 234 | SDL_InputMapping touchpad; | ||
| 235 | } SDL_GamepadMapping; | ||
| 236 | |||
| 237 | // Function to get autodetected gamepad controller mapping from the driver | ||
| 238 | extern bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, | ||
| 239 | SDL_GamepadMapping *out); | ||
| 240 | |||
| 241 | |||
| 242 | typedef struct | ||
| 243 | { | ||
| 244 | const char *included_hint_name; | ||
| 245 | int num_included_entries; | ||
| 246 | int max_included_entries; | ||
| 247 | Uint32 *included_entries; | ||
| 248 | |||
| 249 | const char *excluded_hint_name; | ||
| 250 | int num_excluded_entries; | ||
| 251 | int max_excluded_entries; | ||
| 252 | Uint32 *excluded_entries; | ||
| 253 | |||
| 254 | int num_initial_entries; | ||
| 255 | Uint32 *initial_entries; | ||
| 256 | |||
| 257 | bool initialized; | ||
| 258 | } SDL_vidpid_list; | ||
| 259 | |||
| 260 | extern void SDL_LoadVIDPIDList(SDL_vidpid_list *list); | ||
| 261 | extern void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list); | ||
| 262 | extern bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); | ||
| 263 | extern void SDL_FreeVIDPIDList(SDL_vidpid_list *list); | ||
| 264 | |||
| 265 | // Ends C function definitions when using C++ | ||
| 266 | #ifdef __cplusplus | ||
| 267 | } | ||
| 268 | #endif | ||
| 269 | |||
| 270 | #endif // SDL_joystick_c_h_ | ||
