Atlas - SDL_joystick_c.h

Home / ext / SDL / src / joystick Lines: 1 | Size: 12345 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2026 Sam Lantinga <[email protected]> 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 31extern "C" { 32#endif 33 34struct SDL_JoystickDriver; 35struct SDL_SteamVirtualGamepadInfo; 36 37// Initialization and shutdown functions 38extern bool SDL_InitJoysticks(void); 39extern void SDL_QuitJoysticks(void); 40 41// Return whether the joystick system is currently initialized 42extern bool SDL_JoysticksInitialized(void); 43 44// Return whether the joystick system is shutting down 45extern bool SDL_JoysticksQuitting(void); 46 47// Return whether the joysticks are currently locked 48extern bool SDL_JoysticksLocked(void); 49 50// Make sure we currently have the joysticks locked 51extern void SDL_AssertJoysticksLocked(void) SDL_ASSERT_CAPABILITY(SDL_joystick_lock); 52 53// Function to return whether there are any joysticks opened by the application 54extern bool SDL_JoysticksOpened(void); 55 56// Function to determine whether a device is currently detected by this driver 57extern 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 */ 62extern 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 65extern 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 68extern SDL_GUID SDL_CreateJoystickGUIDForName(const char *name); 69 70// Function to set the vendor field of a joystick GUID 71extern void SDL_SetJoystickGUIDVendor(SDL_GUID *guid, Uint16 vendor); 72 73// Function to set the product field of a joystick GUID 74extern void SDL_SetJoystickGUIDProduct(SDL_GUID *guid, Uint16 product); 75 76// Function to set the version field of a joystick GUID 77extern void SDL_SetJoystickGUIDVersion(SDL_GUID *guid, Uint16 version); 78 79// Function to set the CRC field of a joystick GUID 80extern void SDL_SetJoystickGUIDCRC(SDL_GUID *guid, Uint16 crc); 81 82// Function to return the type of a controller 83extern SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, const char *name, bool forUI); 84extern SDL_GamepadType SDL_GetGamepadTypeFromGUID(SDL_GUID guid, const char *name); 85 86// Function to return whether a joystick GUID uses the version field 87extern bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid); 88 89// Function to return whether a joystick is an Xbox One controller 90extern bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id); 91 92// Function to return whether a joystick is an Xbox One Elite controller 93extern bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id); 94 95// Function to return whether a joystick is an Xbox Series X controller 96extern 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 99extern bool SDL_IsJoystickBluetoothXboxOne(Uint16 vendor_id, Uint16 product_id); 100 101// Function to return whether a joystick is a PS4 controller 102extern bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id); 103 104// Function to return whether a joystick is a PS5 controller 105extern bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id); 106extern bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id); 107 108// Function to return whether a joystick is a Nintendo Switch Pro controller 109extern bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id); 110extern bool SDL_IsJoystickNintendoSwitchProInputOnly(Uint16 vendor_id, Uint16 product_id); 111extern bool SDL_IsJoystickNintendoSwitchJoyCon(Uint16 vendor_id, Uint16 product_id); 112extern bool SDL_IsJoystickNintendoSwitchJoyConLeft(Uint16 vendor_id, Uint16 product_id); 113extern bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16 product_id); 114extern bool SDL_IsJoystickNintendoSwitchJoyConGrip(Uint16 vendor_id, Uint16 product_id); 115extern bool SDL_IsJoystickNintendoSwitchJoyConPair(Uint16 vendor_id, Uint16 product_id); 116 117// Function to return whether a joystick is a Nintendo GameCube style controller 118extern bool SDL_IsJoystickGameCube(Uint16 vendor_id, Uint16 product_id); 119 120// Function to return whether a joystick is an Amazon Luna controller 121extern bool SDL_IsJoystickAmazonLunaController(Uint16 vendor_id, Uint16 product_id); 122 123// Function to return whether a joystick is a Google Stadia controller 124extern bool SDL_IsJoystickGoogleStadiaController(Uint16 vendor_id, Uint16 product_id); 125 126// Function to return whether a joystick is an NVIDIA SHIELD controller 127extern bool SDL_IsJoystickNVIDIASHIELDController(Uint16 vendor_id, Uint16 product_id); 128 129// Function to return whether a joystick is a Steam Virtual Gamepad 130extern bool SDL_IsJoystickSteamVirtualGamepad(Uint16 vendor_id, Uint16 product_id, Uint16 version); 131 132// Function to return whether a joystick is a Steam Controller 133extern bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id); 134 135// Function to return whether a joystick is a HORI Steam controller 136extern bool SDL_IsJoystickHoriSteamController(Uint16 vendor_id, Uint16 product_id); 137 138// Function to return whether a joystick is an SInput (Open Format) controller 139extern bool SDL_IsJoystickSInputController(Uint16 vendor_id, Uint16 product_id); 140 141// Function to return whether a joystick is a Flydigi controller 142extern bool SDL_IsJoystickFlydigiController(Uint16 vendor_id, Uint16 product_id); 143 144// Function to return whether a joystick is a GameSir controller 145extern bool SDL_IsJoystickGameSirController(Uint16 vendor_id, Uint16 product_id); 146 147// Function to return whether a joystick is a Steam Deck 148extern bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); 149 150// Function to return whether a joystick is a Steam Triton 151extern bool SDL_IsJoystickSteamTriton(Uint16 vendor_id, Uint16 product_id); 152 153// Function to return whether a joystick guid comes from the XInput driver 154extern bool SDL_IsJoystickXInput(SDL_GUID guid); 155 156// Function to return whether a joystick guid comes from the WGI driver 157extern bool SDL_IsJoystickWGI(SDL_GUID guid); 158 159// Function to return whether a joystick guid comes from the GameInput driver 160extern bool SDL_IsJoystickGameInput(SDL_GUID guid); 161 162// Function to return whether a joystick guid comes from the HIDAPI driver 163extern bool SDL_IsJoystickHIDAPI(SDL_GUID guid); 164 165// Function to return whether a joystick guid comes from the MFI driver 166extern bool SDL_IsJoystickMFI(SDL_GUID guid); 167 168// Function to return whether a joystick guid comes from the RAWINPUT driver 169extern bool SDL_IsJoystickRAWINPUT(SDL_GUID guid); 170 171// Function to return whether a joystick guid comes from the Virtual driver 172extern bool SDL_IsJoystickVIRTUAL(SDL_GUID guid); 173 174// Function to return whether a joystick is a wheel 175extern bool SDL_IsJoystickWheel(Uint16 vendor_id, Uint16 product_id); 176 177// Function to return whether a joystick should be ignored 178extern bool SDL_ShouldIgnoreJoystick(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); 179 180// Internal event queueing functions 181extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers); 182extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type, float rate); 183extern void SDL_PrivateJoystickSensorRate(SDL_Joystick *joystick, SDL_SensorType type, float rate); 184extern void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id); 185extern bool SDL_IsJoystickBeingAdded(void); 186extern void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id); 187extern void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick); 188extern void SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, Sint16 value); 189extern void SDL_SendJoystickBall(Uint64 timestamp, SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel); 190extern void SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uint8 value); 191extern void SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 button, bool down); 192extern void SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); 193extern void SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); 194extern void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent); 195 196// Function to get the Steam virtual gamepad info for a joystick 197extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickVirtualGamepadInfoForID(SDL_JoystickID instance_id); 198 199// Internal sanity checking functions 200extern bool SDL_IsJoystickValid(SDL_Joystick *joystick); 201 202typedef enum 203{ 204 EMappingKind_None, 205 EMappingKind_Button, 206 EMappingKind_Axis, 207 EMappingKind_Hat, 208} EMappingKind; 209 210typedef struct SDL_InputMapping 211{ 212 EMappingKind kind; 213 Uint8 target; 214 bool axis_reversed; 215 bool half_axis_positive; 216 bool half_axis_negative; 217} SDL_InputMapping; 218 219typedef struct SDL_GamepadMapping 220{ 221 SDL_InputMapping a; 222 SDL_InputMapping b; 223 SDL_InputMapping x; 224 SDL_InputMapping y; 225 SDL_InputMapping back; 226 SDL_InputMapping guide; 227 SDL_InputMapping start; 228 SDL_InputMapping leftstick; 229 SDL_InputMapping rightstick; 230 SDL_InputMapping leftshoulder; 231 SDL_InputMapping rightshoulder; 232 SDL_InputMapping dpup; 233 SDL_InputMapping dpdown; 234 SDL_InputMapping dpleft; 235 SDL_InputMapping dpright; 236 SDL_InputMapping misc1; 237 SDL_InputMapping misc2; 238 SDL_InputMapping misc3; 239 SDL_InputMapping misc4; 240 SDL_InputMapping misc5; 241 SDL_InputMapping misc6; 242 SDL_InputMapping right_paddle1; 243 SDL_InputMapping left_paddle1; 244 SDL_InputMapping right_paddle2; 245 SDL_InputMapping left_paddle2; 246 SDL_InputMapping leftx; 247 SDL_InputMapping lefty; 248 SDL_InputMapping rightx; 249 SDL_InputMapping righty; 250 SDL_InputMapping lefttrigger; 251 SDL_InputMapping righttrigger; 252 SDL_InputMapping touchpad; 253} SDL_GamepadMapping; 254 255// Function to get autodetected gamepad controller mapping from the driver 256extern bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, 257 SDL_GamepadMapping *out); 258 259 260typedef struct 261{ 262 const char *included_hint_name; 263 int num_included_entries; 264 int max_included_entries; 265 Uint32 *included_entries; 266 267 const char *excluded_hint_name; 268 int num_excluded_entries; 269 int max_excluded_entries; 270 Uint32 *excluded_entries; 271 272 int num_initial_entries; 273 Uint32 *initial_entries; 274 275 bool initialized; 276} SDL_vidpid_list; 277 278extern void SDL_LoadVIDPIDList(SDL_vidpid_list *list); 279extern void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list); 280extern bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); 281extern void SDL_FreeVIDPIDList(SDL_vidpid_list *list); 282 283// Ends C function definitions when using C++ 284#ifdef __cplusplus 285} 286#endif 287 288#endif // SDL_joystick_c_h_ 289
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.