Updated gamepad, joystick, sensor APIs, removing device indices

Instead of indexing into an internal list of devices which requires locking, we return a list of device IDs which can then be queried individually.

Reference: https://github.com/libsdl-org/SDL/issues/6889
This commit is contained in:
Sam Lantinga 2022-12-27 18:10:06 -08:00
parent e40a96155f
commit 16092f58bb
27 changed files with 917 additions and 797 deletions

View file

@ -130,7 +130,6 @@
#define SDL_GetGamepadMappingForGUID SDL_GetGamepadMappingForGUID_REAL
#define SDL_GetGamepadMapping SDL_GetGamepadMapping_REAL
#define SDL_IsGamepad SDL_IsGamepad_REAL
#define SDL_GetGamepadNameForIndex SDL_GetGamepadNameForIndex_REAL
#define SDL_OpenGamepad SDL_OpenGamepad_REAL
#define SDL_GetGamepadName SDL_GetGamepadName_REAL
#define SDL_IsGamepadConnected SDL_IsGamepadConnected_REAL
@ -182,11 +181,8 @@
#define SDL_AddHintCallback SDL_AddHintCallback_REAL
#define SDL_DelHintCallback SDL_DelHintCallback_REAL
#define SDL_ClearHints SDL_ClearHints_REAL
#define SDL_GetNumJoysticks SDL_GetNumJoysticks_REAL
#define SDL_GetJoystickNameForIndex SDL_GetJoystickNameForIndex_REAL
#define SDL_OpenJoystick SDL_OpenJoystick_REAL
#define SDL_GetJoystickName SDL_GetJoystickName_REAL
#define SDL_GetJoystickDeviceGUID SDL_GetJoystickDeviceGUID_REAL
#define SDL_GetJoystickGUID SDL_GetJoystickGUID_REAL
#define SDL_GetJoystickGUIDString SDL_GetJoystickGUIDString_REAL
#define SDL_GetJoystickGUIDFromString SDL_GetJoystickGUIDFromString_REAL
@ -578,9 +574,6 @@
#define SDL_CreateSurface SDL_CreateSurface_REAL
#define SDL_CreateSurfaceFrom SDL_CreateSurfaceFrom_REAL
#define SDL_GetHintBoolean SDL_GetHintBoolean_REAL
#define SDL_GetJoystickDeviceVendor SDL_GetJoystickDeviceVendor_REAL
#define SDL_GetJoystickDeviceProduct SDL_GetJoystickDeviceProduct_REAL
#define SDL_GetJoystickDeviceProductVersion SDL_GetJoystickDeviceProductVersion_REAL
#define SDL_GetJoystickVendor SDL_GetJoystickVendor_REAL
#define SDL_GetJoystickProduct SDL_GetJoystickProduct_REAL
#define SDL_GetJoystickProductVersion SDL_GetJoystickProductVersion_REAL
@ -591,11 +584,9 @@
#define SDL_GetNumGamepadMappings SDL_GetNumGamepadMappings_REAL
#define SDL_GetGamepadMappingForIndex SDL_GetGamepadMappingForIndex_REAL
#define SDL_GetJoystickAxisInitialState SDL_GetJoystickAxisInitialState_REAL
#define SDL_GetJoystickDeviceType SDL_GetJoystickDeviceType_REAL
#define SDL_GetJoystickType SDL_GetJoystickType_REAL
#define SDL_MemoryBarrierReleaseFunction SDL_MemoryBarrierReleaseFunction_REAL
#define SDL_MemoryBarrierAcquireFunction SDL_MemoryBarrierAcquireFunction_REAL
#define SDL_GetJoystickDeviceInstanceID SDL_GetJoystickDeviceInstanceID_REAL
#define SDL_utf8strlen SDL_utf8strlen_REAL
#define SDL_LoadFile_RW SDL_LoadFile_RW_REAL
#define SDL_wcscmp SDL_wcscmp_REAL
@ -641,7 +632,6 @@
#define SDL_WinRTGetDeviceFamily SDL_WinRTGetDeviceFamily_REAL
#define SDL_log10 SDL_log10_REAL
#define SDL_log10f SDL_log10f_REAL
#define SDL_GetGamepadMappingForDeviceIndex SDL_GetGamepadMappingForDeviceIndex_REAL
#define SDL_LinuxSetThreadPriority SDL_LinuxSetThreadPriority_REAL
#define SDL_HasAVX512F SDL_HasAVX512F_REAL
#define SDL_IsChromebook SDL_IsChromebook_REAL
@ -652,11 +642,6 @@
#define SDL_wcsdup SDL_wcsdup_REAL
#define SDL_RumbleGamepad SDL_RumbleGamepad_REAL
#define SDL_RumbleJoystick SDL_RumbleJoystick_REAL
#define SDL_GetNumSensors SDL_GetNumSensors_REAL
#define SDL_GetSensorDeviceName SDL_GetSensorDeviceName_REAL
#define SDL_GetSensorDeviceType SDL_GetSensorDeviceType_REAL
#define SDL_GetSensorDeviceNonPortableType SDL_GetSensorDeviceNonPortableType_REAL
#define SDL_GetSensorDeviceInstanceID SDL_GetSensorDeviceInstanceID_REAL
#define SDL_OpenSensor SDL_OpenSensor_REAL
#define SDL_GetSensorFromInstanceID SDL_GetSensorFromInstanceID_REAL
#define SDL_GetSensorName SDL_GetSensorName_REAL
@ -670,7 +655,6 @@
#define SDL_GetDisplayOrientation SDL_GetDisplayOrientation_REAL
#define SDL_SurfaceHasColorKey SDL_SurfaceHasColorKey_REAL
#define SDL_CreateThreadWithStackSize SDL_CreateThreadWithStackSize_REAL
#define SDL_GetJoystickDevicePlayerIndex SDL_GetJoystickDevicePlayerIndex_REAL
#define SDL_GetJoystickPlayerIndex SDL_GetJoystickPlayerIndex_REAL
#define SDL_GetGamepadPlayerIndex SDL_GetGamepadPlayerIndex_REAL
#define SDL_RenderFlush SDL_RenderFlush_REAL
@ -702,7 +686,6 @@
#define SDL_strtokr SDL_strtokr_REAL
#define SDL_wcsstr SDL_wcsstr_REAL
#define SDL_wcsncmp SDL_wcsncmp_REAL
#define SDL_GetGamepadTypeForIndex SDL_GetGamepadTypeForIndex_REAL
#define SDL_GetGamepadType SDL_GetGamepadType_REAL
#define SDL_GetGamepadFromPlayerIndex SDL_GetGamepadFromPlayerIndex_REAL
#define SDL_SetGamepadPlayerIndex SDL_SetGamepadPlayerIndex_REAL
@ -727,8 +710,6 @@
#define SDL_SetJoystickVirtualButton SDL_SetJoystickVirtualButton_REAL
#define SDL_SetJoystickVirtualHat SDL_SetJoystickVirtualHat_REAL
#define SDL_GetErrorMsg SDL_GetErrorMsg_REAL
#define SDL_LockSensors SDL_LockSensors_REAL
#define SDL_UnlockSensors SDL_UnlockSensors_REAL
#define SDL_Metal_GetLayer SDL_Metal_GetLayer_REAL
#define SDL_Metal_GetDrawableSize SDL_Metal_GetDrawableSize_REAL
#define SDL_trunc SDL_trunc_REAL
@ -835,9 +816,7 @@
#define SDL_GetRectAndLineIntersectionF SDL_GetRectAndLineIntersectionF_REAL
#define SDL_GetRenderWindow SDL_GetRenderWindow_REAL
#define SDL_bsearch SDL_bsearch_REAL
#define SDL_GetGamepadPathForIndex SDL_GetGamepadPathForIndex_REAL
#define SDL_GetGamepadPath SDL_GetGamepadPath_REAL
#define SDL_GetJoystickPathForIndex SDL_GetJoystickPathForIndex_REAL
#define SDL_GetJoystickPath SDL_GetJoystickPath_REAL
#define SDL_AttachVirtualJoystickEx SDL_AttachVirtualJoystickEx_REAL
#define SDL_GetGamepadFirmwareVersion SDL_GetGamepadFirmwareVersion_REAL
@ -876,3 +855,29 @@
#define SDL_GetEventState SDL_GetEventState_REAL
#define SDL_GetRenderDriver SDL_GetRenderDriver_REAL
#define SDL_RunApp SDL_RunApp_REAL
#define SDL_GetSensors SDL_GetSensors_REAL
#define SDL_GetSensorInstanceName SDL_GetSensorInstanceName_REAL
#define SDL_GetSensorInstanceType SDL_GetSensorInstanceType_REAL
#define SDL_GetSensorInstanceNonPortableType SDL_GetSensorInstanceNonPortableType_REAL
#define SDL_GetJoysticks SDL_GetJoysticks_REAL
#define SDL_GetJoystickInstanceName SDL_GetJoystickInstanceName_REAL
#define SDL_GetJoystickInstancePath SDL_GetJoystickInstancePath_REAL
#define SDL_GetJoystickInstancePlayerIndex SDL_GetJoystickInstancePlayerIndex_REAL
#define SDL_GetJoystickInstanceGUID SDL_GetJoystickInstanceGUID_REAL
#define SDL_GetJoystickInstanceVendor SDL_GetJoystickInstanceVendor_REAL
#define SDL_GetJoystickInstanceProduct SDL_GetJoystickInstanceProduct_REAL
#define SDL_GetJoystickInstanceProductVersion SDL_GetJoystickInstanceProductVersion_REAL
#define SDL_GetJoystickInstanceType SDL_GetJoystickInstanceType_REAL
#define SDL_GetGamepadInstanceName SDL_GetGamepadInstanceName_REAL
#define SDL_GetGamepadInstancePath SDL_GetGamepadInstancePath_REAL
#define SDL_GetGamepadInstanceType SDL_GetGamepadInstanceType_REAL
#define SDL_GetGamepadInstanceMapping SDL_GetGamepadInstanceMapping_REAL
#define SDL_HasJoysticks SDL_HasJoysticks_REAL
#define SDL_HasSensors SDL_HasSensors_REAL
#define SDL_HasGamepads SDL_HasGamepads_REAL
#define SDL_GetGamepads SDL_GetGamepads_REAL
#define SDL_GetGamepadInstancePlayerIndex SDL_GetGamepadInstancePlayerIndex_REAL
#define SDL_GetGamepadInstanceGUID SDL_GetGamepadInstanceGUID_REAL
#define SDL_GetGamepadInstanceVendor SDL_GetGamepadInstanceVendor_REAL
#define SDL_GetGamepadInstanceProduct SDL_GetGamepadInstanceProduct_REAL
#define SDL_GetGamepadInstanceProductVersion SDL_GetGamepadInstanceProductVersion_REAL