Atlas - SDL_joystick_c.h

Home / ext / SDL / src / joystick Lines: 1 | Size: 12059 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 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 Steam Deck 145extern bool SDL_IsJoystickSteamDeck(Uint16 vendor_id, Uint16 product_id); 146 147// Function to return whether a joystick is a Steam Triton 148extern bool SDL_IsJoystickSteamTriton(Uint16 vendor_id, Uint16 product_id); 149 150// Function to return whether a joystick guid comes from the XInput driver 151extern bool SDL_IsJoystickXInput(SDL_GUID guid); 152 153// Function to return whether a joystick guid comes from the WGI driver 154extern bool SDL_IsJoystickWGI(SDL_GUID guid); 155 156// Function to return whether a joystick guid comes from the HIDAPI driver 157extern bool SDL_IsJoystickHIDAPI(SDL_GUID guid); 158 159// Function to return whether a joystick guid comes from the MFI driver 160extern bool SDL_IsJoystickMFI(SDL_GUID guid); 161 162// Function to return whether a joystick guid comes from the RAWINPUT driver 163extern bool SDL_IsJoystickRAWINPUT(SDL_GUID guid); 164 165// Function to return whether a joystick guid comes from the Virtual driver 166extern bool SDL_IsJoystickVIRTUAL(SDL_GUID guid); 167 168// Function to return whether a joystick is a wheel 169bool SDL_IsJoystickWheel(Uint16 vendor_id, Uint16 product_id); 170 171// Function to return whether a joystick should be ignored 172extern bool SDL_ShouldIgnoreJoystick(Uint16 vendor_id, Uint16 product_id, Uint16 version, const char *name); 173 174// Internal event queueing functions 175extern void SDL_PrivateJoystickAddTouchpad(SDL_Joystick *joystick, int nfingers); 176extern void SDL_PrivateJoystickAddSensor(SDL_Joystick *joystick, SDL_SensorType type, float rate); 177extern void SDL_PrivateJoystickSensorRate(SDL_Joystick *joystick, SDL_SensorType type, float rate); 178extern void SDL_PrivateJoystickAdded(SDL_JoystickID instance_id); 179extern bool SDL_IsJoystickBeingAdded(void); 180extern void SDL_PrivateJoystickRemoved(SDL_JoystickID instance_id); 181extern void SDL_PrivateJoystickForceRecentering(SDL_Joystick *joystick); 182extern void SDL_SendJoystickAxis(Uint64 timestamp, SDL_Joystick *joystick, Uint8 axis, Sint16 value); 183extern void SDL_SendJoystickBall(Uint64 timestamp, SDL_Joystick *joystick, Uint8 ball, Sint16 xrel, Sint16 yrel); 184extern void SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 hat, Uint8 value); 185extern void SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 button, bool down); 186extern void SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touchpad, int finger, bool down, float x, float y, float pressure); 187extern void SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values); 188extern void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent); 189 190// Function to get the Steam virtual gamepad info for a joystick 191extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickVirtualGamepadInfoForID(SDL_JoystickID instance_id); 192 193// Internal sanity checking functions 194extern bool SDL_IsJoystickValid(SDL_Joystick *joystick); 195 196typedef enum 197{ 198 EMappingKind_None, 199 EMappingKind_Button, 200 EMappingKind_Axis, 201 EMappingKind_Hat, 202} EMappingKind; 203 204typedef struct SDL_InputMapping 205{ 206 EMappingKind kind; 207 Uint8 target; 208 bool axis_reversed; 209 bool half_axis_positive; 210 bool half_axis_negative; 211} SDL_InputMapping; 212 213typedef struct SDL_GamepadMapping 214{ 215 SDL_InputMapping a; 216 SDL_InputMapping b; 217 SDL_InputMapping x; 218 SDL_InputMapping y; 219 SDL_InputMapping back; 220 SDL_InputMapping guide; 221 SDL_InputMapping start; 222 SDL_InputMapping leftstick; 223 SDL_InputMapping rightstick; 224 SDL_InputMapping leftshoulder; 225 SDL_InputMapping rightshoulder; 226 SDL_InputMapping dpup; 227 SDL_InputMapping dpdown; 228 SDL_InputMapping dpleft; 229 SDL_InputMapping dpright; 230 SDL_InputMapping misc1; 231 SDL_InputMapping misc2; 232 SDL_InputMapping misc3; 233 SDL_InputMapping misc4; 234 SDL_InputMapping misc5; 235 SDL_InputMapping misc6; 236 SDL_InputMapping right_paddle1; 237 SDL_InputMapping left_paddle1; 238 SDL_InputMapping right_paddle2; 239 SDL_InputMapping left_paddle2; 240 SDL_InputMapping leftx; 241 SDL_InputMapping lefty; 242 SDL_InputMapping rightx; 243 SDL_InputMapping righty; 244 SDL_InputMapping lefttrigger; 245 SDL_InputMapping righttrigger; 246 SDL_InputMapping touchpad; 247} SDL_GamepadMapping; 248 249// Function to get autodetected gamepad controller mapping from the driver 250extern bool SDL_PrivateJoystickGetAutoGamepadMapping(SDL_JoystickID instance_id, 251 SDL_GamepadMapping *out); 252 253 254typedef struct 255{ 256 const char *included_hint_name; 257 int num_included_entries; 258 int max_included_entries; 259 Uint32 *included_entries; 260 261 const char *excluded_hint_name; 262 int num_excluded_entries; 263 int max_excluded_entries; 264 Uint32 *excluded_entries; 265 266 int num_initial_entries; 267 Uint32 *initial_entries; 268 269 bool initialized; 270} SDL_vidpid_list; 271 272extern void SDL_LoadVIDPIDList(SDL_vidpid_list *list); 273extern void SDL_LoadVIDPIDListFromHints(SDL_vidpid_list *list, const char *included_list, const char *excluded_list); 274extern bool SDL_VIDPIDInList(Uint16 vendor_id, Uint16 product_id, const SDL_vidpid_list *list); 275extern void SDL_FreeVIDPIDList(SDL_vidpid_list *list); 276 277// Ends C function definitions when using C++ 278#ifdef __cplusplus 279} 280#endif 281 282#endif // SDL_joystick_c_h_ 283
[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.