Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

SDL: Update to 3.4.20

Rémi Verschelde6a90487e2673
diff --git a/thirdparty/README.md b/thirdparty/README.md
index 3ce5f61d967..0309050e5c5 100644
--- a/thirdparty/README.md
+++ b/thirdparty/README.md
@@ -1067,7 +1067,7 @@ proposed by these libraries and better integrate them with Godot.
## sdl
- Upstream: https://github.com/libsdl-org/SDL
-- Version: 3.4.16 (fa2c02bb6e21974a89ea9824bc53c9932abe5f9c, 2026)
+- Version: 3.4.20 (f00dc919ca35b9756316e86c4777392de442f9b2, 2026)
- License: Zlib
- Vendored: hidapi 0.14.0, license BSD-3-Clause
diff --git a/thirdparty/sdl/SDL.c b/thirdparty/sdl/SDL.c
index 9f62253c691..1cf7c8e7585 100644
--- a/thirdparty/sdl/SDL.c
+++ b/thirdparty/sdl/SDL.c
@@ -353,7 +353,7 @@ bool SDL_InitSubSystem(SDL_InitFlags flags)
if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return ptr >>> 2; }; }
#elif defined(__wasm64__)
if (typeof(SDL3.JSVarToCPtr) === 'undefined') { SDL3.JSVarToCPtr = function(v) { return BigInt(v); }; }
- if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Number(ptr / 4n); }; }
+ if (typeof(SDL3.CPtrToHeap32Index) === 'undefined') { SDL3.CPtrToHeap32Index = function(ptr) { return Math.floor(Number(ptr) / 4); }; } // This should NOT be SDL_floor()
#else
#error Please define your platform.
#endif
diff --git a/thirdparty/sdl/SDL_utils.c b/thirdparty/sdl/SDL_utils.c
index 146d8163414..50bfc8f5d58 100644
--- a/thirdparty/sdl/SDL_utils.c
+++ b/thirdparty/sdl/SDL_utils.c
@@ -548,6 +548,9 @@ char *SDL_CreateDeviceName(Uint16 vendor, Uint16 product, const char *vendor_nam
case SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_PRO:
name = SDL_strdup("Nintendo Switch Pro Controller");
break;
+ case SDL_GAMEPAD_TYPE_STEAM:
+ name = SDL_strdup("Steam Controller");
+ break;
default:
len = (6 + 1 + 6 + 1);
name = (char *)SDL_malloc(len);
diff --git a/thirdparty/sdl/core/linux/SDL_dbus.c b/thirdparty/sdl/core/linux/SDL_dbus.c
index 663e70427ac..de69b98c5fa 100644
--- a/thirdparty/sdl/core/linux/SDL_dbus.c
+++ b/thirdparty/sdl/core/linux/SDL_dbus.c
@@ -23,6 +23,7 @@
#include "../../stdlib/SDL_vacopy.h"
#include <fcntl.h>
+#include <sys/stat.h>
#include <unistd.h>
#ifdef SDL_USE_LIBDBUS
@@ -516,7 +517,19 @@ bool SDL_DBus_OpenURI(const char *uri, const char *window_id, const char *activa
}
uri = decoded_path;
}
- fd = open(uri, O_RDWR | O_CLOEXEC);
+
+ struct stat st;
+ if (stat(uri, &st) == 0) {
+ /* Open files and directories as read-only, as the fd is only used as proof
+ * of access by the portal, and a mismatch between fd write permissions and
+ * the portal write parameter will cause the fd to be rejected.
+ */
+ int oflags = O_RDONLY | O_CLOEXEC;
+ if (S_ISDIR(st.st_mode)) {
+ oflags |= O_DIRECTORY;
+ }
+ fd = open(uri, oflags);
+ }
SDL_free(decoded_path);
if (fd >= 0) {
msg = dbus.message_new_method_call(bus_name, path, interface, "OpenFile");
diff --git a/thirdparty/sdl/core/linux/SDL_udev.c b/thirdparty/sdl/core/linux/SDL_udev.c
index f05adeed6db..a715ac3b900 100644
--- a/thirdparty/sdl/core/linux/SDL_udev.c
+++ b/thirdparty/sdl/core/linux/SDL_udev.c
@@ -160,9 +160,6 @@ bool SDL_UDEV_Init(void)
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "sound", NULL);
_this->syms.udev_monitor_filter_add_match_subsystem_devtype(_this->udev_mon, "video4linux", NULL);
_this->syms.udev_monitor_enable_receiving(_this->udev_mon);
-
- // Do an initial scan of existing devices
- SDL_UDEV_Scan();
}
_this->ref_count += 1;
diff --git a/thirdparty/sdl/core/windows/SDL_gameinput.cpp b/thirdparty/sdl/core/windows/SDL_gameinput.cpp
index baf7ed21654..fb3b942d320 100644
--- a/thirdparty/sdl/core/windows/SDL_gameinput.cpp
+++ b/thirdparty/sdl/core/windows/SDL_gameinput.cpp
@@ -38,6 +38,10 @@ bool SDL_InitGameInput(IGameInput **ppGameInput)
return false;
}
+ if (WIN_HasBrokenEZFRD64DLL()) {
+ return SDL_SetError("GameInput disabled to prevent application crashing");
+ }
+
typedef HRESULT (WINAPI *pfnGameInputCreate)(IGameInput **gameInput);
pfnGameInputCreate pGameInputCreate = (pfnGameInputCreate)SDL_LoadFunction(g_hGameInputDLL, "GameInputCreate");
if (!pGameInputCreate) {
diff --git a/thirdparty/sdl/core/windows/SDL_windows.c b/thirdparty/sdl/core/windows/SDL_windows.c
index c7924bf934b..ed5da3daf3a 100644
--- a/thirdparty/sdl/core/windows/SDL_windows.c
+++ b/thirdparty/sdl/core/windows/SDL_windows.c
@@ -768,4 +768,35 @@ char *WIN_GetModulePath(HMODULE handle)
return retval;
}
+bool WIN_HasBrokenEZFRD64DLL(void)
+{
+ static bool checked = false;
+ static bool has_broken_EZFRD64_DLL = false;
+
+ if (!checked) {
+#ifdef _WIN64
+ if (SDL_GetHintBoolean("SDL_CHECK_BROKEN_EZFRD64", true)) {
+ // The 64-bit version of EZFRD64.DLL crashes after being loaded,
+ // which happens implicitly when querying the device capabilities,
+ // so make sure we don't do that if there's a possibility of crashing
+ static const char *directories[] = {
+ "C:/Windows/USB_Vibration",
+ "C:/Windows/USB Vibration"
+ };
+ for (int i = 0; i < SDL_arraysize(directories) && !has_broken_EZFRD64_DLL; ++i) {
+ int count = 0;
+ char **files = SDL_GlobDirectory(directories[i], "*/EZFRD64.DLL", SDL_GLOB_CASEINSENSITIVE, &count);
+ if (count > 0) {
+ SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Broken EZFRD64.DLL detected, disabling GameInput and DirectInput force feedback");
+ has_broken_EZFRD64_DLL = true;
+ }
+ SDL_free(files);
+ }
+ }
+#endif
+ checked = true;
+ }
+ return has_broken_EZFRD64_DLL;
+}
+
#endif // defined(SDL_PLATFORM_WINDOWS)
diff --git a/thirdparty/sdl/core/windows/SDL_windows.h b/thirdparty/sdl/core/windows/SDL_windows.h
index 54f3f2c96c7..882ce33dfb9 100644
--- a/thirdparty/sdl/core/windows/SDL_windows.h
+++ b/thirdparty/sdl/core/windows/SDL_windows.h
@@ -218,6 +218,9 @@ extern const char *WIN_CheckDefaultArgcArgv(int *pargc, char ***pargv, void **pa
// Does all the win32 tapdancing to make GetModuleFileName work. Returns a SDL_malloc'd UTF-8 string, or NULL on failure.
extern char *WIN_GetModulePath(HMODULE handle);
+// Return true if this system has a broken EZFRD64.DLL installed
+extern bool WIN_HasBrokenEZFRD64DLL(void);
+
// Ends C function definitions when using C++
#ifdef __cplusplus
}
diff --git a/thirdparty/sdl/hidapi/SDL_hidapi.c b/thirdparty/sdl/hidapi/SDL_hidapi.c
index abb85676004..5df9ae5b2d3 100644
--- a/thirdparty/sdl/hidapi/SDL_hidapi.c
+++ b/thirdparty/sdl/hidapi/SDL_hidapi.c
@@ -332,6 +332,8 @@ static void HIDAPI_InitializeDiscovery(void)
if (SDL_HIDAPI_discovery.m_pUdev != NULL) {
SDL_HIDAPI_discovery.m_pUdevMonitor = usyms->udev_monitor_new_from_netlink(SDL_HIDAPI_discovery.m_pUdev, "udev");
if (SDL_HIDAPI_discovery.m_pUdevMonitor != NULL) {
+ usyms->udev_monitor_filter_add_match_subsystem_devtype(SDL_HIDAPI_discovery.m_pUdevMonitor, "hidraw", NULL);
+ usyms->udev_monitor_filter_add_match_subsystem_devtype(SDL_HIDAPI_discovery.m_pUdevMonitor, "usb", NULL);
usyms->udev_monitor_enable_receiving(SDL_HIDAPI_discovery.m_pUdevMonitor);
SDL_HIDAPI_discovery.m_nUdevFd = usyms->udev_monitor_get_fd(SDL_HIDAPI_discovery.m_pUdevMonitor);
SDL_HIDAPI_discovery.m_bCanGetNotifications = true;
@@ -1176,7 +1178,7 @@ bool SDL_HIDAPI_ShouldIgnoreDevice(int bus, Uint16 vendor_id, Uint16 product_id,
}
return true;
} else if (vendor_id == USB_VENDOR_FLYDIGI_V2 &&
- (product_id == USB_PRODUCT_FLYDIGI_V2_APEX || product_id == USB_PRODUCT_FLYDIGI_V2_VADER)) {
+ (product_id == USB_PRODUCT_FLYDIGI_V2_APEX || product_id == USB_PRODUCT_FLYDIGI_V2_VADER || product_id == USB_PRODUCT_FLYDIGI_V2_APEX6)) {
if (usage_page == USB_USAGEPAGE_VENDOR_FLYDIGI) {
return false;
}
diff --git a/thirdparty/sdl/include/SDL3/SDL.h b/thirdparty/sdl/include/SDL3/SDL.h
index d9055809c4e..220ca022cee 100644
--- a/thirdparty/sdl/include/SDL3/SDL.h
+++ b/thirdparty/sdl/include/SDL3/SDL.h
@@ -20,7 +20,7 @@
*/
/**
- * Main include header for the SDL library, version 3.4.16
+ * Main include header for the SDL library, version 3.4.20
*
* It is almost always best to include just this one header instead of
* picking out individual headers included here. There are exceptions to
diff --git a/thirdparty/sdl/include/SDL3/SDL_assert.h b/thirdparty/sdl/include/SDL3/SDL_assert.h
index e65836a0dd6..5104642750b 100644
--- a/thirdparty/sdl/include/SDL3/SDL_assert.h
+++ b/thirdparty/sdl/include/SDL3/SDL_assert.h
@@ -131,7 +131,12 @@ extern "C" {
extern void __cdecl __debugbreak(void);
#define SDL_TriggerBreakpoint() __debugbreak()
#elif defined(__MINGW32__)
+ #include <_mingw.h>
+ #ifdef __MINGW64_VERSION_MAJOR
#include <intrin.h>
+ #else
+ extern void __cdecl __debugbreak(void);
+ #endif
#define SDL_TriggerBreakpoint() __debugbreak()
#elif defined(_MSC_VER) && defined(_M_IX86)
#define SDL_TriggerBreakpoint() { _asm { int 0x03 } }
diff --git a/thirdparty/sdl/include/SDL3/SDL_audio.h b/thirdparty/sdl/include/SDL3/SDL_audio.h
index 1e1af26d75f..f4246cd520d 100644
--- a/thirdparty/sdl/include/SDL3/SDL_audio.h
+++ b/thirdparty/sdl/include/SDL3/SDL_audio.h
@@ -415,6 +415,8 @@ typedef struct SDL_AudioSpec
* This reports on the size of an audio sample frame: stereo Sint16 data (2
* channels of 2 bytes each) would be 4 bytes per frame, for example.
*
+ * This casts the value to unsigned int to avoid implicit sign conversion.
+ *
* \param x an SDL_AudioSpec to query.
* \returns the number of bytes used per sample frame.
*
@@ -422,7 +424,7 @@ typedef struct SDL_AudioSpec
*
* \since This macro is available since SDL 3.2.0.
*/
-#define SDL_AUDIO_FRAMESIZE(x) (SDL_AUDIO_BYTESIZE((x).format) * (x).channels)
+#define SDL_AUDIO_FRAMESIZE(x) (((unsigned int)SDL_AUDIO_BYTESIZE((x).format)) * ((unsigned int)((x).channels)))
/**
* The opaque handle that represents an audio stream.
@@ -1802,6 +1804,16 @@ extern SDL_DECLSPEC bool SDLCALL SDL_AudioStreamDevicePaused(SDL_AudioStream *st
* As this is just a wrapper over SDL_LockMutex for an internal lock; it has
* all the same attributes (recursive locks are allowed, etc).
*
+ * Note that when the stream's callback runs, SDL is holding both an internal
+ * mutex for the audio device and the stream's lock, in that order. Which is
+ * to say: while this function can protect arbitrary data, calling into some
+ * SDL audio functions while holding this lock may cause a deadlock--the app
+ * holds this lock, and then calls into something that wants to obtain the
+ * device lock, in the opposite order that SDL's audio thread obtained them.
+ * Therefore, best practice is to use this function to protect simple app data
+ * against the audio callback, and be careful about what SDL functions one
+ * calls while locked outside of the callback.
+ *
* \param stream the audio stream to lock.
* \returns true on success or false on failure; call SDL_GetError() for more
* information.
diff --git a/thirdparty/sdl/include/SDL3/SDL_events.h b/thirdparty/sdl/include/SDL3/SDL_events.h
index 4fb6268135f..7f755c6c924 100644
--- a/thirdparty/sdl/include/SDL3/SDL_events.h
+++ b/thirdparty/sdl/include/SDL3/SDL_events.h
@@ -831,6 +831,7 @@ typedef struct SDL_PenProximityEvent
SDL_WindowID windowID; /**< The window with pen focus, if any */
SDL_PenID which; /**< The pen instance id */
SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event (added in 3.4.16). */
+ SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenProximityEvent;
/**
@@ -854,6 +855,7 @@ typedef struct SDL_PenMotionEvent
SDL_PenInputFlags pen_state; /**< Complete pen input state at time of event */
float x; /**< X coordinate, relative to window */
float y; /**< Y coordinate, relative to window */
+ SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenMotionEvent;
/**
@@ -876,6 +878,7 @@ typedef struct SDL_PenTouchEvent
float y; /**< Y coordinate, relative to window */
bool eraser; /**< true if eraser end is used (not all pens support this). */
bool down; /**< true if the pen is touching or false if the pen is lifted off */
+ SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenTouchEvent;
/**
@@ -898,6 +901,7 @@ typedef struct SDL_PenButtonEvent
float y; /**< Y coordinate, relative to window */
Uint8 button; /**< The pen button index (first button is 1). */
bool down; /**< true if the button is pressed */
+ SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenButtonEvent;
/**
@@ -920,6 +924,7 @@ typedef struct SDL_PenAxisEvent
float y; /**< Y coordinate, relative to window */
SDL_PenAxis axis; /**< Axis that has changed */
float value; /**< New value of axis */
+ SDL_PenDeviceType device_type; /**< the device type of the pen, if known (added in 3.4.18). */
} SDL_PenAxisEvent;
/**
diff --git a/thirdparty/sdl/include/SDL3/SDL_gamepad.h b/thirdparty/sdl/include/SDL3/SDL_gamepad.h
index 9c88a770ae0..d9f2ff5fbff 100644
--- a/thirdparty/sdl/include/SDL3/SDL_gamepad.h
+++ b/thirdparty/sdl/include/SDL3/SDL_gamepad.h
@@ -122,6 +122,7 @@ typedef enum SDL_GamepadType
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_RIGHT,
SDL_GAMEPAD_TYPE_NINTENDO_SWITCH_JOYCON_PAIR,
SDL_GAMEPAD_TYPE_GAMECUBE,
+ SDL_GAMEPAD_TYPE_STEAM,
SDL_GAMEPAD_TYPE_COUNT
} SDL_GamepadType;
diff --git a/thirdparty/sdl/include/SDL3/SDL_hints.h b/thirdparty/sdl/include/SDL3/SDL_hints.h
index a38abf02d15..002317063b2 100644
--- a/thirdparty/sdl/include/SDL3/SDL_hints.h
+++ b/thirdparty/sdl/include/SDL3/SDL_hints.h
@@ -3484,6 +3484,19 @@ extern "C" {
*/
#define SDL_HINT_PS2_GS_MODE "SDL_PS2_GS_MODE"
+/**
+ * A variable controlling the pixel storage mode of the PS2's framebuffer.
+ *
+ * The variable can be set to the following values:
+ *
+ * - "32"
+ * - "24" (default)
+ * - "16"
+ *
+ * \since This hint is available since SDL 3.4.20.
+ */
+#define SDL_HINT_PS2_GS_COLOR_DEPTH "SDL_PS2_GS_COLOR_DEPTH"
+
/**
* A variable controlling which Dispmanx layer to use on a Raspberry PI.
*
diff --git a/thirdparty/sdl/include/SDL3/SDL_init.h b/thirdparty/sdl/include/SDL3/SDL_init.h
index d75ccc31d70..cc8fd6e724e 100644
--- a/thirdparty/sdl/include/SDL3/SDL_init.h
+++ b/thirdparty/sdl/include/SDL3/SDL_init.h
@@ -426,8 +426,9 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetAppMetadata(const char *appname, const c
* - `SDL_PROP_APP_METADATA_NAME_STRING`: The human-readable name of the
* application, like "My Game 2: Bad Guy's Revenge!". This will show up
* anywhere the OS shows the name of the application separately from window
- * titles, such as volume control applets, etc. This defaults to "SDL
- * Application".
+ * titles, such as volume control applets, etc. If not provided by the app,
+ * SDL will attempt to pick a reasonable default (the app's binary's name
+ * if the platform can provide it, or "SDL Application" if all else fails).
* - `SDL_PROP_APP_METADATA_VERSION_STRING`: The version of the app that is
* running; there are no rules on format, so "1.0.3beta2" and "April 22nd,
* 2024" and a git hash are all valid options. This has no default.
diff --git a/thirdparty/sdl/include/SDL3/SDL_keyboard.h b/thirdparty/sdl/include/SDL3/SDL_keyboard.h
index d14ab6fb27c..276d43302c1 100644
--- a/thirdparty/sdl/include/SDL3/SDL_keyboard.h
+++ b/thirdparty/sdl/include/SDL3/SDL_keyboard.h
@@ -146,6 +146,13 @@ extern SDL_DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void);
* Note: This function doesn't take into account whether shift has been
* pressed or not.
*
+ * Note that this function is "thread safe," in that calling it from two
+ * threads at once will return the same array and that it won't be reallocated
+ * or free'd without warning, as more events arrive, the contents of this
+ * array may change without warning or any sort of thread synchronization. For
+ * apps that need precision, it is better to use the key events in the SDL
+ * event queue.
+ *
* \param numkeys if non-NULL, receives the length of the returned array.
* \returns a pointer to an array of key states.
*
diff --git a/thirdparty/sdl/include/SDL3/SDL_keycode.h b/thirdparty/sdl/include/SDL3/SDL_keycode.h
index 1818ee3e4c1..ae5184744e5 100644
--- a/thirdparty/sdl/include/SDL3/SDL_keycode.h
+++ b/thirdparty/sdl/include/SDL3/SDL_keycode.h
@@ -222,6 +222,7 @@ typedef Uint32 SDL_Keycode;
#define SDLK_CLEARAGAIN 0x400000a2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CLEARAGAIN) */
#define SDLK_CRSEL 0x400000a3u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_CRSEL) */
#define SDLK_EXSEL 0x400000a4u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_EXSEL) */
+#define SDLK_FRONT 0x400000a5u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_FRONT) */
#define SDLK_KP_00 0x400000b0u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_00) */
#define SDLK_KP_000 0x400000b1u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_KP_000) */
#define SDLK_THOUSANDSSEPARATOR 0x400000b2u /**< SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_THOUSANDSSEPARATOR) */
diff --git a/thirdparty/sdl/include/SDL3/SDL_main_impl.h b/thirdparty/sdl/include/SDL3/SDL_main_impl.h
index bf5f583639c..7344f827388 100644
--- a/thirdparty/sdl/include/SDL3/SDL_main_impl.h
+++ b/thirdparty/sdl/include/SDL3/SDL_main_impl.h
@@ -19,8 +19,6 @@
3. This notice may not be removed or altered from any source distribution.
*/
-/* WIKI CATEGORY: Main */
-
#ifndef SDL_main_impl_h_
#define SDL_main_impl_h_
diff --git a/thirdparty/sdl/include/SDL3/SDL_scancode.h b/thirdparty/sdl/include/SDL3/SDL_scancode.h
index cd5a1376a81..c1fb1b69877 100644
--- a/thirdparty/sdl/include/SDL3/SDL_scancode.h
+++ b/thirdparty/sdl/include/SDL3/SDL_scancode.h
@@ -286,6 +286,7 @@ typedef enum SDL_Scancode
SDL_SCANCODE_CLEARAGAIN = 162,
SDL_SCANCODE_CRSEL = 163,
SDL_SCANCODE_EXSEL = 164,
+ SDL_SCANCODE_FRONT = 165, /**< Front (Sun keyboards) */
SDL_SCANCODE_KP_00 = 176,
SDL_SCANCODE_KP_000 = 177,
diff --git a/thirdparty/sdl/include/SDL3/SDL_version.h b/thirdparty/sdl/include/SDL3/SDL_version.h
index 6b7816e0d4d..55bd973063e 100644
--- a/thirdparty/sdl/include/SDL3/SDL_version.h
+++ b/thirdparty/sdl/include/SDL3/SDL_version.h
@@ -62,7 +62,7 @@ extern "C" {
*
* \since This macro is available since SDL 3.2.0.
*/
-#define SDL_MICRO_VERSION 16
+#define SDL_MICRO_VERSION 20
/**
* This macro turns the version numbers into a numeric value.
diff --git a/thirdparty/sdl/joystick/SDL_gamepad.c b/thirdparty/sdl/joystick/SDL_gamepad.c
index dd5b4166a9a..2dfa729e13f 100644
--- a/thirdparty/sdl/joystick/SDL_gamepad.c
+++ b/thirdparty/sdl/joystick/SDL_gamepad.c
@@ -1290,12 +1290,14 @@ static GamepadMapping_t *SDL_CreateMappingForHIDAPIGamepad(SDL_GUID guid)
// Vader 5 has additional shoulder macro buttons and a circle button
SDL_strlcat(mapping_string, "misc4:b17,misc5:b18,misc6:b19", sizeof(mapping_string));
}
- } else if (guid.data[15] == SDL_FLYDIGI_APEX5) {
- // Apex 5 has additional shoulder macro buttons
+ } else if (guid.data[15] == SDL_FLYDIGI_APEX5 || guid.data[15] == SDL_FLYDIGI_APEX6) {
+ // Apex 5 and Apex 6 have additional shoulder macro buttons
SDL_strlcat(mapping_string, "misc2:b15,misc3:b16,", sizeof(mapping_string));
}
} else if (vendor == USB_VENDOR_8BITDO && product == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) {
SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,paddle3:b14,paddle4:b13,", sizeof(mapping_string));
+ } else if (vendor == USB_VENDOR_8BITDO && product == USB_PRODUCT_8BITDO_ULTIMATE2C_WIRELESS) {
+ SDL_strlcat(mapping_string, "paddle1:b12,paddle2:b11,", sizeof(mapping_string));
} else {
switch (SDL_GetGamepadTypeFromGUID(guid, NULL)) {
case SDL_GAMEPAD_TYPE_PS4:
@@ -1489,7 +1491,8 @@ static const char *map_StringForGamepadType[] = {
"joyconleft",
"joyconright",
"joyconpair",
- "gamecube"
+ "gamecube",
+ "steam"
};
SDL_COMPILE_TIME_ASSERT(map_StringForGamepadType, SDL_arraysize(map_StringForGamepadType) == SDL_GAMEPAD_TYPE_COUNT);
@@ -3455,7 +3458,12 @@ Sint16 SDL_GetGamepadAxis(SDL_Gamepad *gamepad, SDL_GamepadAxis axis)
bool valid_output_range;
if (binding->input_type == SDL_GAMEPAD_BINDTYPE_AXIS) {
- value = SDL_GetJoystickAxis(gamepad->joystick, binding->input.axis.axis);
+ const int input_axis = binding->input.axis.axis;
+ /* Missing axes return zero, which would normalize to a half-pressed trigger. */
+ if (input_axis < 0 || input_axis >= gamepad->joystick->naxes) {
+ continue;
+ }
+ value = SDL_GetJoystickAxis(gamepad->joystick, input_axis);
if (binding->input.axis.axis_min < binding->input.axis.axis_max) {
valid_input_range = (value >= binding->input.axis.axis_min && value <= binding->input.axis.axis_max);
} else {
diff --git a/thirdparty/sdl/joystick/SDL_gamepad_db.h b/thirdparty/sdl/joystick/SDL_gamepad_db.h
index ab7abf08a86..086361cd814 100644
--- a/thirdparty/sdl/joystick/SDL_gamepad_db.h
+++ b/thirdparty/sdl/joystick/SDL_gamepad_db.h
@@ -211,6 +211,7 @@ static const char *s_GamepadMappings[] = {
"030000004b120000014d000000000000,NYKO AIRFLO EX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,",
"03000000790000004318000000000000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
"03000000790000004418000000000000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
+ "03000000790000004618000000000000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
"03000000bd12000015d0000000000000,Nintendo Retrolink USB Super SNES Classic Controller,a:b2,b:b1,back:b8,leftshoulder:b4,leftx:a0,lefty:a1,rightshoulder:b5,start:b9,x:b3,y:b0,",
"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"030000000d0500000308000000000000,Nostromo N45,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b12,lefttrigger:b5,leftx:a0,lefty:a1,rightshoulder:b6,rightstick:b11,righttrigger:b7,rightx:a3,righty:a2,start:b10,x:b2,y:b3,",
@@ -427,7 +428,9 @@ static const char *s_GamepadMappings[] = {
"030000001008000001e5000006010000,NEXT SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b4,rightshoulder:b6,start:b9,x:b3,y:b0,",
"03000000550900001472000025050000,NVIDIA Controller v01.04,a:b0,b:b1,back:b17,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b15,leftshoulder:b4,leftstick:b7,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b8,righttrigger:a4,rightx:a2,righty:a5,start:b6,x:b2,y:b3,",
"030000004b120000014d000000010000,NYKO AIRFLO EX,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b10,leftshoulder:b4,leftstick:b11,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b12,righttrigger:b7,rightx:a3,righty:a2,start:b9,x:b2,y:b3,",
+ "03000000790000004318000000010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
"03000000790000004418000000010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
+ "03000000790000004618000000010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
"030000007e0500000920000000000000,Nintendo Switch Pro Controller,a:b0,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b2,y:b3,",
"050000007e05000009200000ff070000,Nintendo Switch Pro Controller,a:b1,b:b0,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b9,leftshoulder:b4,leftstick:b6,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b7,righttrigger:a5,rightx:a3,righty:a4,start:b10,x:b3,y:b2,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"0300000009120000072f000000010000,OrangeFox86 DreamPicoPort,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,lefttrigger:a2,leftx:a0,lefty:a1,righttrigger:a5,rightx:a3,righty:a4,start:b11,x:b3,y:b4,",
@@ -626,6 +629,7 @@ static const char *s_GamepadMappings[] = {
"0300000085320000030c000011010000,Nacon GC100,a:b2,b:b1,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b3,y:b0,",
"03000000790000004318000010010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
"03000000790000004418000010010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
+ "03000000790000004618000010010000,Nintendo GameCube Controller,a:b1,b:b2,dpdown:b14,dpleft:b15,dpright:b13,dpup:b12,lefttrigger:a3,leftx:a0,lefty:a1,rightshoulder:b7,righttrigger:a4,rightx:a5,righty:a2,start:b9,x:b0,y:b3,",
"030000007e0500001920000011810000,Nintendo N64 Controller,crc:d670,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b5,rightshoulder:b7,righttrigger:b3,start:b11,x:b4,y:b10,",
"050000007e0500001920000001800000,Nintendo N64 Controller,crc:5e1c,a:b0,b:b1,back:b2,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b9,lefttrigger:b8,leftx:a0,lefty:a1,misc1:b5,rightshoulder:b7,righttrigger:b3,start:b11,x:b4,y:b10,",
"030000007e0500001e20000011810000,Nintendo SEGA Genesis Controller,crc:bb22,a:b0,b:b1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b6,misc1:b3,rightshoulder:b2,righttrigger:b4,start:b5,",
diff --git a/thirdparty/sdl/joystick/SDL_joystick.c b/thirdparty/sdl/joystick/SDL_joystick.c
index cf08c30b861..ebfcef5b4f2 100644
--- a/thirdparty/sdl/joystick/SDL_joystick.c
+++ b/thirdparty/sdl/joystick/SDL_joystick.c
@@ -450,6 +450,7 @@ static Uint32 initial_blacklist_devices[] = {
MAKE_VIDPID(0x26ce, 0x01a2), // ASRock LED Controller
MAKE_VIDPID(0x3297, 0x1969), // Moonlander MK1 Keyboard
MAKE_VIDPID(0x3434, 0x0121), // Keychron Q3 System Control
+ MAKE_VIDPID(0x3434, 0x0163), // Keychron Q6 System Control
MAKE_VIDPID(0x3434, 0x0211), // Keychron K1 Pro System Control
MAKE_VIDPID(0x3434, 0x02a0), // Keychron K10 Pro System Control
MAKE_VIDPID(0x3434, 0x0353), // Keychron V5 System Control
@@ -3062,6 +3063,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
type = SDL_GAMEPAD_TYPE_XBOX360;
break;
case k_eControllerType_XBoxOneController:
+ case k_eControllerType_XBoxEliteController:
type = SDL_GAMEPAD_TYPE_XBOXONE;
break;
case k_eControllerType_PS3Controller:
@@ -3071,6 +3073,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
type = SDL_GAMEPAD_TYPE_PS4;
break;
case k_eControllerType_PS5Controller:
+ case k_eControllerType_PS5EdgeController:
type = SDL_GAMEPAD_TYPE_PS5;
break;
case k_eControllerType_XInputPS4Controller:
@@ -3091,6 +3094,14 @@ SDL_GamepadType SDL_GetGamepadTypeFromVIDPID(Uint16 vendor, Uint16 product, cons
type = SDL_GAMEPAD_TYPE_XBOX360;
}
break;
+ case k_eControllerType_SteamController:
+ case k_eControllerType_SteamControllerV2:
+ case k_eControllerType_SteamControllerNeptune:
+ case k_eControllerType_SteamControllerTriton:
+ case k_eControllerType_HoriSteamController:
+ case k_eControllerType_UnknownSteamController:
+ type = SDL_GAMEPAD_TYPE_STEAM;
+ break;
default:
break;
}
@@ -3138,20 +3149,14 @@ bool SDL_JoystickGUIDUsesVersion(SDL_GUID guid)
bool SDL_IsJoystickXboxOne(Uint16 vendor_id, Uint16 product_id)
{
EControllerType eType = GuessControllerType(vendor_id, product_id);
- return eType == k_eControllerType_XBoxOneController;
+ return eType == k_eControllerType_XBoxOneController ||
+ eType == k_eControllerType_XBoxEliteController;
}
bool SDL_IsJoystickXboxOneElite(Uint16 vendor_id, Uint16 product_id)
{
- if (vendor_id == USB_VENDOR_MICROSOFT) {
- if (product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_1 ||
- product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 ||
- product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLUETOOTH ||
- product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2_BLE) {
- return true;
- }
- }
- return false;
+ EControllerType eType = GuessControllerType(vendor_id, product_id);
+ return eType == k_eControllerType_XBoxEliteController;
}
bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id)
@@ -3190,17 +3195,14 @@ bool SDL_IsJoystickPS4(Uint16 vendor_id, Uint16 product_id)
bool SDL_IsJoystickPS5(Uint16 vendor_id, Uint16 product_id)
{
EControllerType eType = GuessControllerType(vendor_id, product_id);
- return eType == k_eControllerType_PS5Controller;
+ return eType == k_eControllerType_PS5Controller ||
+ eType == k_eControllerType_PS5EdgeController;
}
bool SDL_IsJoystickDualSenseEdge(Uint16 vendor_id, Uint16 product_id)
{
- if (vendor_id == USB_VENDOR_SONY) {
- if (product_id == USB_PRODUCT_SONY_DS5_EDGE) {
- return true;
- }
- }
- return false;
+ EControllerType eType = GuessControllerType(vendor_id, product_id);
+ return eType == k_eControllerType_PS5EdgeController;
}
bool SDL_IsJoystickNintendoSwitchPro(Uint16 vendor_id, Uint16 product_id)
@@ -3285,7 +3287,8 @@ bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id)
bool SDL_IsJoystickHoriSteamController(Uint16 vendor_id, Uint16 product_id)
{
- return vendor_id == USB_VENDOR_HORI && (product_id == USB_PRODUCT_HORI_STEAM_CONTROLLER || product_id == USB_PRODUCT_HORI_STEAM_CONTROLLER_BT);
+ EControllerType eType = GuessControllerType(vendor_id, product_id);
+ return eType == k_eControllerType_HoriSteamController;
}
bool SDL_IsJoystickSInputController(Uint16 vendor_id, Uint16 product_id)
@@ -3315,7 +3318,7 @@ bool SDL_IsJoystickFlydigiController(Uint16 vendor_id, Uint16 product_id)
}
}
if (vendor_id == USB_VENDOR_FLYDIGI_V2) {
- if (product_id == USB_PRODUCT_FLYDIGI_V2_APEX || product_id == USB_PRODUCT_FLYDIGI_V2_VADER) {
+ if (product_id == USB_PRODUCT_FLYDIGI_V2_APEX || product_id == USB_PRODUCT_FLYDIGI_V2_VADER || product_id == USB_PRODUCT_FLYDIGI_V2_APEX6) {
return true;
}
}
diff --git a/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c b/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c
index 23deb54a75c..a81af29de43 100644
--- a/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c
+++ b/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c
@@ -260,5 +260,7 @@ void SDL_QuitSteamVirtualGamepadInfo(void)
SDL_FreeSteamVirtualGamepadInfo();
SDL_free(SDL_steam_virtual_gamepad_info_file);
SDL_steam_virtual_gamepad_info_file = NULL;
+ SDL_steam_virtual_gamepad_info_file_mtime = 0;
+ SDL_steam_virtual_gamepad_info_check_time = 0;
}
}
diff --git a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
index b4b31704d0b..76794ed8152 100644
--- a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
+++ b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
@@ -387,7 +387,8 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
(SDL_strcmp(name, "8Bitdo SN30 Pro") == 0 && (HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_SN30_PRO, 0, "") || HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_SN30_PRO_BT, 0, ""))) ||
(SDL_strcmp(name, "8BitDo Pro 2") == 0 && (HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_PRO_2, 0, "") || HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_PRO_2_BT, 0, ""))) ||
(SDL_strcmp(name, "8BitDo Pro 3") == 0 && (HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_PRO_3, 0, ""))) ||
- (SDL_startswith(name, "8BitDo Ultimate 2 Wireless") && HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS, 0, ""))) {
+ (SDL_startswith(name, "8BitDo Ultimate 2 Wireless") && HIDAPI_IsDevicePresent(USB_VENDOR_8BITDO, USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS, 0, "")) ||
+ (SDL_startswith(name, "Steam Controller") && HIDAPI_IsDeviceTypePresent(SDL_GAMEPAD_TYPE_STEAM))) {
// The HIDAPI driver is taking care of this device
return false;
}
diff --git a/thirdparty/sdl/joystick/controller_list.h b/thirdparty/sdl/joystick/controller_list.h
index df491fbcdab..6157bfc1a79 100644
--- a/thirdparty/sdl/joystick/controller_list.h
+++ b/thirdparty/sdl/joystick/controller_list.h
@@ -175,7 +175,6 @@ static const ControllerDescription_t arrControllers[] = {
// { MAKE_CONTROLLER_ID( 0x7545, 0x1122 ), k_eControllerType_PS4Controller, NULL }, // Giotek VX4 - trackpad/gyro don't work. Had to not filter on interface info. Light bar is flaky, but works.
{ MAKE_CONTROLLER_ID( 0x054c, 0x0ce6 ), k_eControllerType_PS5Controller, NULL }, // Sony DualSense Controller
- { MAKE_CONTROLLER_ID( 0x054c, 0x0df2 ), k_eControllerType_PS5Controller, NULL }, // Sony DualSense Edge Controller
{ MAKE_CONTROLLER_ID( 0x054c, 0x0e5f ), k_eControllerType_PS5Controller, NULL }, // Access Controller for PS5
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0209 ), k_eControllerType_PS5Controller, NULL }, // Victrix Pro FS PS4/PS5 (PS5 mode)
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0163 ), k_eControllerType_PS5Controller, NULL }, // HORI Fighting Commander OCTA
@@ -239,6 +238,7 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0301 ), k_eControllerType_XBox360Controller, "PDP Xbox 360 Controller" }, // PDP Gamepad for Xbox 360
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0313 ), k_eControllerType_XBox360Controller, "PDP Xbox 360 Afterglow" }, // PDP Afterglow Gamepad for Xbox 360
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0314 ), k_eControllerType_XBox360Controller, "PDP Xbox 360 Afterglow" }, // PDP Afterglow Gamepad for Xbox 360
+ { MAKE_CONTROLLER_ID( 0x0e6f, 0x0338 ), k_eControllerType_XBox360Controller, "PDP Xbox 360 Afterglow" }, // PDP Afterglow Gamepad for Xbox 360
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0401 ), k_eControllerType_XBox360Controller, "PDP Xbox 360 Controller" }, // PDP Gamepad for Xbox 360
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0413 ), k_eControllerType_XBox360Controller, NULL }, // PDP Afterglow AX.1 (unlisted)
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0501 ), k_eControllerType_XBox360Controller, NULL }, // PDP Xbox 360 Controller (unlisted)
@@ -337,19 +337,15 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x045e, 0x02d1 ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft Xbox One Controller
{ MAKE_CONTROLLER_ID( 0x045e, 0x02dd ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft Xbox One Controller (Firmware 2015)
{ MAKE_CONTROLLER_ID( 0x045e, 0x02e0 ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft Xbox One S Controller (Bluetooth)
- { MAKE_CONTROLLER_ID( 0x045e, 0x02e3 ), k_eControllerType_XBoxOneController, "Xbox One Elite Controller" }, // Microsoft Xbox One Elite Controller
{ MAKE_CONTROLLER_ID( 0x045e, 0x02ea ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft Xbox One S Controller
{ MAKE_CONTROLLER_ID( 0x045e, 0x02fd ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft Xbox One S Controller (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft Xbox One Controller with XBOXGIP driver on Windows
- { MAKE_CONTROLLER_ID( 0x045e, 0x0b00 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft Xbox One Elite Series 2 Controller
- { MAKE_CONTROLLER_ID( 0x045e, 0x0b05 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft Xbox One Elite Series 2 Controller (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b0a ), k_eControllerType_XBoxOneController, "Xbox Adaptive Controller" }, // Microsoft Xbox Adaptive Controller
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b0c ), k_eControllerType_XBoxOneController, "Xbox Adaptive Controller" }, // Microsoft Xbox Adaptive Controller (Bluetooth)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b12 ), k_eControllerType_XBoxOneController, "Xbox Series X Controller" }, // Microsoft Xbox Series X Controller
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b13 ), k_eControllerType_XBoxOneController, "Xbox Series X Controller" }, // Microsoft Xbox Series X Controller (BLE)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b20 ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft Xbox One S Controller (BLE)
{ MAKE_CONTROLLER_ID( 0x045e, 0x0b21 ), k_eControllerType_XBoxOneController, "Xbox Adaptive Controller" }, // Microsoft Xbox Adaptive Controller (BLE)
- { MAKE_CONTROLLER_ID( 0x045e, 0x0b22 ), k_eControllerType_XBoxOneController, "Xbox One Elite 2 Controller" }, // Microsoft Xbox One Elite Series 2 Controller (BLE)
{ MAKE_CONTROLLER_ID( 0x0738, 0x4a01 ), k_eControllerType_XBoxOneController, NULL }, // Mad Catz FightStick TE 2
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0139 ), k_eControllerType_XBoxOneController, "PDP Xbox One Afterglow" }, // PDP Afterglow Wired Controller for Xbox One
{ MAKE_CONTROLLER_ID( 0x0e6f, 0x013B ), k_eControllerType_XBoxOneController, "PDP Xbox One Face-Off Controller" }, // PDP Face-Off Gamepad for Xbox One
@@ -469,6 +465,7 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x2e24, 0x1618 ), k_eControllerType_XBoxOneController, NULL }, // Hyperkin Duke
{ MAKE_CONTROLLER_ID( 0x2e24, 0x1688 ), k_eControllerType_XBoxOneController, NULL }, // Hyperkin X91
{ MAKE_CONTROLLER_ID( 0x146b, 0x0611 ), k_eControllerType_XBoxOneController, NULL }, // Xbox Controller Mode for NACON Revolution 3
+ { MAKE_CONTROLLER_ID( 0x3537, 0x109c ), k_eControllerType_XBoxOneController, "GameSir G7 Pro" }, // GameSir G7 Pro connected through its 2.4G dongle in Xbox mode
// These have been added via Minidump for unrecognized Xinput controller assert
{ MAKE_CONTROLLER_ID( 0x045e, 0x02a2 ), k_eControllerType_XBox360Controller, NULL }, // Unknown Controller - Microsoft VID
@@ -620,6 +617,22 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x33dd, 0x0003 ), k_eControllerType_SwitchInputOnlyController, NULL }, // ZUIKI MasCon for Nintendo Switch Red
{ MAKE_CONTROLLER_ID( 0x0f0d, 0x00f0 ), k_eControllerType_SwitchInputOnlyController, NULL }, // HORI Taiko Controller For Switch
+ { MAKE_CONTROLLER_ID( 0x054c, 0x0df2 ), k_eControllerType_PS5EdgeController, NULL }, // Sony DualSense Edge Controller
+
+ { MAKE_CONTROLLER_ID( 0x045e, 0x02e3 ), k_eControllerType_XBoxEliteController, "Xbox One Elite Controller" }, // Microsoft Xbox One Elite Controller
+ { MAKE_CONTROLLER_ID( 0x045e, 0x0b00 ), k_eControllerType_XBoxEliteController, "Xbox One Elite 2 Controller" }, // Microsoft Xbox One Elite Series 2 Controller
+ { MAKE_CONTROLLER_ID( 0x045e, 0x0b05 ), k_eControllerType_XBoxEliteController, "Xbox One Elite 2 Controller" }, // Microsoft Xbox One Elite Series 2 Controller (Bluetooth)
+ { MAKE_CONTROLLER_ID( 0x045e, 0x0b22 ), k_eControllerType_XBoxEliteController, "Xbox One Elite 2 Controller" }, // Microsoft Xbox One Elite Series 2 Controller (BLE)
+
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6000 ), k_eControllerType_8BitDoController, "8Bitdo SF30 Controller" }, // 8BitDo SF30 Pro Controller in Steam Mode
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6100 ), k_eControllerType_8BitDoController, "8Bitdo SF30 Controller" }, // 8BitDo SF30 Pro Controller in Steam Mode (Bluetooth)
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6001 ), k_eControllerType_8BitDoController, "8Bitdo SN30 Controller" }, // 8BitDo SN30 Pro Controller in Steam Mode
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6101 ), k_eControllerType_8BitDoController, "8Bitdo SN30 Controller" }, // 8BitDo SN30 Pro Controller in Steam Mode (Bluetooth)
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6003 ), k_eControllerType_8BitDoController, "8Bitdo Pro 2 Controller" }, // 8BitDo Pro 2 Controller in Steam Mode
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6006 ), k_eControllerType_8BitDoController, "8Bitdo Pro 2 Controller" }, // 8BitDo Pro 2 Controller in Steam Mode
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6009 ), k_eControllerType_8BitDoController, "8Bitdo Pro 3 Controller" }, // 8BitDo Pro 3 Controller in Steam Mode (Bluetooth)
+ { MAKE_CONTROLLER_ID( 0x2dc8, 0x6012 ), k_eControllerType_8BitDoController, "8Bitdo Ultimate 2 Wireless Controller" }, // 8BitDo Ultimate 2 Wireless Controller in Steam Mode (Bluetooth)
+
// Valve products
{ MAKE_CONTROLLER_ID( 0x0000, 0x11fb ), k_eControllerType_MobileTouch, NULL }, // Streaming mobile touch virtual controls
{ MAKE_CONTROLLER_ID( 0x28de, 0x1101 ), k_eControllerType_SteamController, NULL }, // Valve Legacy Steam Controller (CHELL)
@@ -635,4 +648,7 @@ static const ControllerDescription_t arrControllers[] = {
{ MAKE_CONTROLLER_ID( 0x28de, 0x1303 ), k_eControllerType_SteamControllerTriton, NULL }, // Valve Steam Triton Controller (BLE)
{ MAKE_CONTROLLER_ID( 0x28de, 0x1304 ), k_eControllerType_SteamControllerTriton, NULL }, // Valve Steam Proteus Dongle (Proprietary)
{ MAKE_CONTROLLER_ID( 0x28de, 0x1305 ), k_eControllerType_SteamControllerTriton, NULL }, // Valve Steam Nereid Dongle (Proprietary)
+
+ { MAKE_CONTROLLER_ID( 0x0f0d, 0x01AB ), k_eControllerType_HoriSteamController, NULL }, // HORI Wireless HORIPAD for Steam
+ { MAKE_CONTROLLER_ID( 0x0f0d, 0x0196 ), k_eControllerType_HoriSteamController, NULL }, // HORI Wireless HORIPAD for Steam ( BT )
};
diff --git a/thirdparty/sdl/joystick/controller_type.h b/thirdparty/sdl/joystick/controller_type.h
index bb94840affb..cc49ae6f3c1 100644
--- a/thirdparty/sdl/joystick/controller_type.h
+++ b/thirdparty/sdl/joystick/controller_type.h
@@ -25,7 +25,7 @@
#endif
//-----------------------------------------------------------------------------
-// Purpose: Steam Controller models
+// Purpose: Steam Controller models
// WARNING: DO NOT RENUMBER EXISTING VALUES - STORED IN A DATABASE
//-----------------------------------------------------------------------------
typedef enum
@@ -58,7 +58,11 @@ typedef enum
k_eControllerType_MobileTouch = 43,
k_eControllerType_XInputSwitchController = 44, // Client-side only, used to mark Nintendo Switch style controllers as using XInput instead of the Nintendo Switch protocol
k_eControllerType_PS5Controller = 45,
- k_eControllerType_XInputPS4Controller = 46, // Client-side only, used to mark DualShock 4 style controllers using XInput instead of the DualShock 4 controller protocol
+ k_eControllerType_XBoxEliteController = 46,
+ k_eControllerType_XInputPS4Controller = 47, // Client-side only, used to mark DualShock 4 style controllers using XInput instead of the DualShock 4 controller protocol
+ k_eControllerType_PS5EdgeController = 48,
+ k_eControllerType_HoriSteamController = 49,
+ k_eControllerType_8BitDoController = 50,
k_eControllerType_LastController, // Don't add game controllers below this enumeration - this enumeration can change value
// Keyboards and Mice
diff --git a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_8bitdo.c b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_8bitdo.c
index 8c607c2fb3a..a89d2f3503c 100644
--- a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_8bitdo.c
+++ b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_8bitdo.c
@@ -48,6 +48,8 @@ enum
SDL_GAMEPAD_NUM_8BITDO_ULTIMATE3_BUTTONS,
};
+#define SDL_GAMEPAD_NUM_8BITDO_ULTIMATE2C_BUTTONS (SDL_GAMEPAD_BUTTON_8BITDO_R4 + 1)
+
#define SDL_8BITDO_FEATURE_REPORTID 0x30
#define SDL_8BITDO_FEATURE_REPORTID_ENABLE_SDL_REPORTID 0x06
#define SDL_8BITDO_REPORTID_SDL_REPORTID 0x04
@@ -159,6 +161,7 @@ static bool HIDAPI_Driver8BitDo_IsSupportedDevice(SDL_HIDAPI_Device *device, con
case USB_PRODUCT_8BITDO_PRO_2_BT:
case USB_PRODUCT_8BITDO_PRO_3:
case USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS:
+ case USB_PRODUCT_8BITDO_ULTIMATE2C_WIRELESS:
case USB_PRODUCT_8BITDO_ULTIMATE3:
return true;
default:
@@ -195,6 +198,8 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
}
break;
}
+ } else if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2C_WIRELESS) {
+ // The Ultimate 2C Wireless controller has an 11 byte report with no sensor or rumble support
} else if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE3) {
// Supported by default
ctx->sensors_supported = true;
@@ -228,8 +233,7 @@ static bool HIDAPI_Driver8BitDo_InitDevice(SDL_HIDAPI_Device *device)
}
SDL_Delay(10);
}
- }
- else {
+ } else {
Uint8 data[USB_PACKET_LENGTH];
const int MAX_ATTEMPTS = 5;
for (int attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) {
@@ -350,6 +354,8 @@ static bool HIDAPI_Driver8BitDo_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys
device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS) {
// This controller has additional buttons
joystick->nbuttons = SDL_GAMEPAD_NUM_8BITDO_BUTTONS;
+ } else if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE2C_WIRELESS) {
+ joystick->nbuttons = SDL_GAMEPAD_NUM_8BITDO_ULTIMATE2C_BUTTONS;
} else if (device->product_id == USB_PRODUCT_8BITDO_ULTIMATE3) {
joystick->nbuttons = SDL_GAMEPAD_NUM_8BITDO_ULTIMATE3_BUTTONS;
} else {
@@ -590,8 +596,13 @@ static void HIDAPI_Driver8BitDo_HandleStatePacket(SDL_Joystick *joystick, SDL_Dr
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, ((data[8] & 0x40) != 0));
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, ((data[8] & 0x80) != 0));
- SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_8BITDO_PL, ((data[8] & 0x20) != 0));
- SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_8BITDO_PR, ((data[8] & 0x04) != 0));
+ if (joystick->nbuttons > SDL_GAMEPAD_BUTTON_8BITDO_PR) {
+ SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_8BITDO_PL, ((data[8] & 0x20) != 0));
+ SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_8BITDO_PR, ((data[8] & 0x04) != 0));
+ } else if (joystick->nbuttons > SDL_GAMEPAD_BUTTON_8BITDO_R4) {
+ SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_8BITDO_L4, ((data[8] & 0x04) != 0));
+ SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_8BITDO_R4, ((data[8] & 0x20) != 0));
+ }
}
if (ctx->last_state[9] != data[9]) {
diff --git a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.c b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.c
index 989609ca53c..a90a115b0d1 100644
--- a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.c
+++ b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.c
@@ -19,6 +19,7 @@
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
+#include <stdint.h>
#ifdef SDL_JOYSTICK_HIDAPI
@@ -74,6 +75,7 @@ enum
#define FLYDIGI_V2_MAGIC1 0x5A
#define FLYDIGI_V2_MAGIC2 0xA5
#define FLYDIGI_V2_GET_INFO_COMMAND 0x01
+#define FLYDIGI_V2_CHECK_ARCHITECTURE_COMMAND 0x07
#define FLYDIGI_V2_GET_STATUS_COMMAND 0x10
#define FLYDIGI_V2_SET_STATUS_COMMAND 0x11
#define FLYDIGI_V2_HAPTIC_COMMAND 0x12
@@ -88,16 +90,28 @@ typedef struct
bool has_cz;
bool has_lmrm;
bool has_circle;
+ bool has_trigger_rumble;
bool wireless;
bool sensors_supported;
bool sensors_enabled;
Uint16 firmware_version;
Uint64 sensor_timestamp_ns; // Simulate onboard clock. Advance by known time step. Nanoseconds.
Uint64 sensor_timestamp_step_ns; // Based on observed rate of receipt of IMU sensor packets.
+ // Convertion from raw values to meters per second squared.
float accelScale;
- float gyroScale;
+ // Convertion from raw values to radians per second.
+ // A negative value means that the gyro axis is inverted.
+ // X Y Z
+ // https://wiki.libsdl.org/SDL2/SDL_SensorType
+ float gyroScale[3];
Uint64 next_heartbeat;
+ Uint64 next_status_request;
Uint64 last_packet;
+ bool acquired;
+ Uint8 low_frequency_rumble;
+ Uint8 high_frequency_rumble;
+ Uint8 left_trigger_rumble;
+ Uint8 right_trigger_rumble;
Uint8 last_state[USB_PACKET_LENGTH];
} SDL_DriverFlydigi_Context;
@@ -182,6 +196,11 @@ static void HIDAPI_DriverFlydigi_UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
case 134:
controller_type = SDL_FLYDIGI_APEX5;
break;
+ case 149: //Apex6
+ case 150: //Apex6 Pro
+ case 152: //Apex 6 Pro Phantom Blade Zero
+ controller_type = SDL_FLYDIGI_APEX6;
+ break;
default:
// Try to guess from the name of the controller
if (SDL_strcasestr(device->name, "VADER") != NULL) {
@@ -203,6 +222,8 @@ static void HIDAPI_DriverFlydigi_UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
controller_type = SDL_FLYDIGI_APEX4;
} else if (SDL_strstr(device->name, "APEX5") != NULL) {
controller_type = SDL_FLYDIGI_APEX5;
+ } else if (SDL_strstr(device->name, "APEX6") != NULL) {
+ controller_type = SDL_FLYDIGI_APEX6;
}
}
break;
@@ -229,7 +250,15 @@ static void HIDAPI_DriverFlydigi_UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
ctx->has_lmrm = true;
ctx->sensors_supported = true;
ctx->accelScale = SDL_STANDARD_GRAVITY / 4096.0f;
- ctx->gyroScale = DEG2RAD(2000.0f);
+ ctx->gyroScale[0] = DEG2RAD(2000.0f); // Scale is the same for all axis.
+ ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_APEX5_DONGLE_NS : SENSOR_INTERVAL_APEX5_WIRED_NS;
+ break;
+ case SDL_FLYDIGI_APEX6:
+ HIDAPI_SetDeviceName(device, "Flydigi Apex 6");
+ ctx->has_lmrm = true;
+ ctx->sensors_supported = true;
+ ctx->accelScale = SDL_STANDARD_GRAVITY / 4096.0f;
+ ctx->gyroScale[0] = DEG2RAD(2000.0f); // Scale is the same for all axis.
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_APEX5_DONGLE_NS : SENSOR_INTERVAL_APEX5_WIRED_NS;
break;
case SDL_FLYDIGI_VADER2:
@@ -250,6 +279,9 @@ static void HIDAPI_DriverFlydigi_UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
ctx->has_cz = true;
ctx->sensors_supported = true;
ctx->accelScale = SDL_STANDARD_GRAVITY / 256.0f;
+ ctx->gyroScale[0] = -DEG2RAD(72000.0f);
+ ctx->gyroScale[1] = -DEG2RAD(72000.0f);
+ ctx->gyroScale[2] = -DEG2RAD(1200.0f);
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_VADER4_PRO_DONGLE_NS : SENSOR_INTERVAL_VADER4_PRO_WIRED_NS;
break;
case SDL_FLYDIGI_VADER4_PRO:
@@ -257,6 +289,9 @@ static void HIDAPI_DriverFlydigi_UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
ctx->has_cz = true;
ctx->sensors_supported = true;
ctx->accelScale = SDL_STANDARD_GRAVITY / 256.0f;
+ ctx->gyroScale[0] = -DEG2RAD(72000.0f);
+ ctx->gyroScale[1] = -DEG2RAD(72000.0f);
+ ctx->gyroScale[2] = -DEG2RAD(1200.0f);
ctx->sensor_timestamp_step_ns = ctx->wireless ? SENSOR_INTERVAL_VADER4_PRO_DONGLE_NS : SENSOR_INTERVAL_VADER4_PRO_WIRED_NS;
break;
case SDL_FLYDIGI_VADER5_PRO:
@@ -264,9 +299,10 @@ static void HIDAPI_DriverFlydigi_UpdateDeviceIdentity(SDL_HIDAPI_Device *device)
ctx->has_cz = true;
ctx->has_lmrm = true;
ctx->has_circle = true;
+ ctx->has_trigger_rumble = true;
ctx->sensors_supported = true;
ctx->accelScale = SDL_STANDARD_GRAVITY / 4096.0f;
- ctx->gyroScale = DEG2RAD(2000.0f);
+ ctx->gyroScale[0] = DEG2RAD(2000.0f); // Scale is the same for all axis.
ctx->sensor_timestamp_step_ns = SENSOR_INTERVAL_VADER5_PRO_NS;
break;
default:
@@ -295,13 +331,16 @@ static void HIDAPI_DriverFlydigi_SetAvailable(SDL_HIDAPI_Device *device, bool av
ctx->available = available;
}
-static int HIDAPI_DriverFlydigi_WritePacket(SDL_HIDAPI_Device *device, const Uint8 *data, size_t size)
+static bool HIDAPI_DriverFlydigi_UsesUnnumberedReports(SDL_HIDAPI_Device *device)
{
// We know that at the very least the Vader 5 now uses unnumbered reports for commands instead of FLYDIGI_V2_CMD_REPORT_ID.
// If other Flydigi things prove to do the same, we can tweak this check to be more general.
- bool bUsesUnnumberedReports = (device->vendor_id == USB_VENDOR_FLYDIGI_V2 && device->product_id == USB_PRODUCT_FLYDIGI_V2_VADER);
+ return (device->vendor_id == USB_VENDOR_FLYDIGI_V2 && (device->product_id == USB_PRODUCT_FLYDIGI_V2_VADER || device->product_id == USB_PRODUCT_FLYDIGI_V2_APEX6));
+}
- if (bUsesUnnumberedReports && data[0] == FLYDIGI_V2_CMD_REPORT_ID) {
+static int HIDAPI_DriverFlydigi_WritePacket(SDL_HIDAPI_Device *device, const Uint8 *data, size_t size)
+{
+ if (HIDAPI_DriverFlydigi_UsesUnnumberedReports(device) && data[0] == FLYDIGI_V2_CMD_REPORT_ID) {
// Zero out the report byte.
Uint8 output[USB_PACKET_LENGTH];
SDL_memcpy(output, data, SDL_min(size, USB_PACKET_LENGTH));
@@ -407,6 +446,23 @@ static bool GetReply(SDL_HIDAPI_Device* device, Uint8 command, Uint8* data, size
return false;
}
+static bool SDL_HIDAPI_Flydigi_CheckNewArchitectureRequest(SDL_HIDAPI_Device *device)
+{
+ const Uint8 cmd[] = {
+ FLYDIGI_V2_CMD_REPORT_ID,
+ FLYDIGI_V2_MAGIC1,
+ FLYDIGI_V2_MAGIC2,
+ FLYDIGI_V2_CHECK_ARCHITECTURE_COMMAND,
+ 0,
+ 0
+ };
+
+ if (HIDAPI_DriverFlydigi_WritePacket(device, cmd, sizeof(cmd)) < 0) {
+ return SDL_SetError("Couldn't query controller info");
+ }
+ return true;
+}
+
static bool SDL_HIDAPI_Flydigi_SendInfoRequest(SDL_HIDAPI_Device *device)
{
const Uint8 cmd[] = {
@@ -434,11 +490,19 @@ static void HIDAPI_DriverFlydigi_HandleInfoResponse(SDL_Joystick *joystick, SDL_
switch (status) {
case 0:
state = SDL_POWERSTATE_ON_BATTERY;
- percent = level * 20;
+ if (ctx->device->guid.data[15] == SDL_FLYDIGI_APEX6) {
+ percent = level * 10;
+ } else {
+ percent = level * 20;
+ }
break;
case 1:
state = SDL_POWERSTATE_CHARGING;
- percent = level * 20;
+ if (ctx->device->guid.data[15] == SDL_FLYDIGI_APEX6) {
+ percent = level * 10;
+ } else {
+ percent = level * 20;
+ }
break;
case 2:
state = SDL_POWERSTATE_CHARGED;
@@ -452,53 +516,60 @@ static void HIDAPI_DriverFlydigi_HandleInfoResponse(SDL_Joystick *joystick, SDL_
SDL_SendJoystickPowerInfo(joystick, state, percent);
}
-static bool SDL_HIDAPI_Flydigi_SendStatusRequest(SDL_HIDAPI_Device *device)
+static bool SDL_HIDAPI_Flydigi_SendAcquireRequest(SDL_HIDAPI_Device *device, bool acquire)
{
- const Uint8 cmd[] = {
+ const Uint8 cmd[32] = {
FLYDIGI_V2_CMD_REPORT_ID,
FLYDIGI_V2_MAGIC1,
FLYDIGI_V2_MAGIC2,
- FLYDIGI_V2_GET_STATUS_COMMAND
+ FLYDIGI_V2_ACQUIRE_CONTROLLER_COMMAND,
+ 23,
+ acquire ? 1 : 0,
+ 'S', 'D', 'L', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
if (HIDAPI_DriverFlydigi_WritePacket(device, cmd, sizeof(cmd)) < 0) {
- return SDL_SetError("Couldn't query controller status");
+ return SDL_SetError("Couldn't send acquire command");
}
return true;
}
-static void HIDAPI_DriverFlydigi_HandleStatusResponse(SDL_HIDAPI_Device *device, Uint8 *data, int size)
+static void HIDAPI_DriverFlydigi_HandleAcquireResponse(SDL_HIDAPI_Device *device, Uint8 *data, int size)
{
- if (data[9] == 1) {
- HIDAPI_DriverFlydigi_SetAvailable(device, true);
- } else {
- // Click "Allow third-party apps to take over mappings" in the FlyDigi Space Station app
- HIDAPI_DriverFlydigi_SetAvailable(device, false);
- }
+ // This response might be from another application (e.g. the Space Station Service)
+ // so let's rely on the status response to determine whether the controller is available
}
-static bool SDL_HIDAPI_Flydigi_SendAcquireRequest(SDL_HIDAPI_Device *device, bool acquire)
+static bool SDL_HIDAPI_Flydigi_SendStatusRequest(SDL_HIDAPI_Device *device)
{
- const Uint8 cmd[32] = {
+ const Uint8 cmd[] = {
FLYDIGI_V2_CMD_REPORT_ID,
FLYDIGI_V2_MAGIC1,
FLYDIGI_V2_MAGIC2,
- FLYDIGI_V2_ACQUIRE_CONTROLLER_COMMAND,
- 23,
- acquire ? 1 : 0,
- 'S', 'D', 'L', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ FLYDIGI_V2_GET_STATUS_COMMAND
};
if (HIDAPI_DriverFlydigi_WritePacket(device, cmd, sizeof(cmd)) < 0) {
- return SDL_SetError("Couldn't send acquire command");
+ return SDL_SetError("Couldn't query controller status");
}
return true;
}
-static void HIDAPI_DriverFlydigi_HandleAcquireResponse(SDL_HIDAPI_Device *device, Uint8 *data, int size)
+static void HIDAPI_DriverFlydigi_HandleStatusResponse(SDL_HIDAPI_Device *device, Uint8 *data, int size)
{
- if (data[5] != 1 && data[6] == 0) {
- // Controller acquiring failed or has been disabled
+ SDL_DriverFlydigi_Context *ctx = (SDL_DriverFlydigi_Context *)device->context;
+
+ if (data[9] == 1) {
+ HIDAPI_DriverFlydigi_SetAvailable(device, true);
+
+ // The Space Station service can stop input while third party apps are still allowed,
+ // so release and re-acquire the controller if it looks like we should be able to.
+ if (device->num_joysticks > 0 && ctx->acquired && data[6] == 0) {
+ SDL_HIDAPI_Flydigi_SendAcquireRequest(device, false);
+ SDL_HIDAPI_Flydigi_SendAcquireRequest(device, true);
+ }
+ } else {
+ // Click "Allow third-party apps to take over mappings" in the FlyDigi Space Station app
HIDAPI_DriverFlydigi_SetAvailable(device, false);
}
}
@@ -507,7 +578,22 @@ static bool HIDAPI_DriverFlydigi_InitControllerV2(SDL_HIDAPI_Device *device)
{
SDL_DriverFlydigi_Context *ctx = (SDL_DriverFlydigi_Context *)device->context;
+ // Check whether is the new architecture
+ Uint8 versionData[USB_PACKET_LENGTH];
+ bool isNewArchitecture = false;
+ if (!SDL_HIDAPI_Flydigi_CheckNewArchitectureRequest(device)) {
+ return false;
+ }
+ if (!GetReply(device, FLYDIGI_V2_CHECK_ARCHITECTURE_COMMAND, versionData, sizeof(versionData))) {
+ return SDL_SetError("Couldn't get controller info");
+ }
+
+ if (versionData[3] == 1 && versionData[4] == 0) {
+ isNewArchitecture = true;
+ }
+
Uint8 data[USB_PACKET_LENGTH];
+
if (!SDL_HIDAPI_Flydigi_SendInfoRequest(device)) {
return false;
}
@@ -536,24 +622,42 @@ static bool HIDAPI_DriverFlydigi_InitControllerV2(SDL_HIDAPI_Device *device)
return SDL_SetError("Unsupported firmware version");
}
- switch (data[6]) {
- case 1:
- // Wired connection
- ctx->wireless = false;
- break;
- case 2:
- // Wireless connection
- ctx->wireless = true;
- break;
- default:
- break;
+ if (isNewArchitecture) {
+ switch (data[6]) {
+ case 0:
+ // Wired connection
+ ctx->wireless = false;
+ break;
+ case 1:
+ // Wireless connection
+ ctx->wireless = true;
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (data[6]) {
+ case 1:
+ // Wired connection
+ ctx->wireless = false;
+ break;
+ case 2:
+ // Wireless connection
+ ctx->wireless = true;
+ break;
+ default:
+ break;
+ }
}
ctx->deviceID = data[5];
HIDAPI_DriverFlydigi_UpdateDeviceIdentity(device);
// See whether we can acquire the controller
- SDL_HIDAPI_Flydigi_SendStatusRequest(device);
+ if (SDL_HIDAPI_Flydigi_SendStatusRequest(device) &&
+ GetReply(device, FLYDIGI_V2_GET_STATUS_COMMAND, data, sizeof(data))) {
+ HIDAPI_DriverFlydigi_HandleStatusResponse(device, data, sizeof(data));
+ }
return true;
}
@@ -591,6 +695,10 @@ static bool HIDAPI_DriverFlydigi_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
SDL_AssertJoysticksLocked();
SDL_zeroa(ctx->last_state);
+ ctx->low_frequency_rumble = 0;
+ ctx->high_frequency_rumble = 0;
+ ctx->left_trigger_rumble = 0;
+ ctx->right_trigger_rumble = 0;
// Initialize the joystick capabilities
joystick->nbuttons = SDL_GAMEPAD_NUM_BASE_FLYDIGI_BUTTONS;
@@ -618,6 +726,24 @@ static bool HIDAPI_DriverFlydigi_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
return true;
}
+static bool HIDAPI_DriverFlydigi_SendRumbleV2(SDL_DriverFlydigi_Context *ctx)
+{
+ SDL_HIDAPI_Device *device = ctx->device;
+ Uint8 rumble_packet[] = { FLYDIGI_V2_CMD_REPORT_ID, FLYDIGI_V2_MAGIC1, FLYDIGI_V2_MAGIC2, FLYDIGI_V2_HAPTIC_COMMAND, 6, 0, 0, 0, 0, 0 };
+ rumble_packet[5] = ctx->low_frequency_rumble;
+ rumble_packet[6] = ctx->high_frequency_rumble;
+ rumble_packet[7] = ctx->left_trigger_rumble;
+ rumble_packet[8] = ctx->right_trigger_rumble;
+ if (HIDAPI_DriverFlydigi_UsesUnnumberedReports(device)) {
+ rumble_packet[0] = 0;
+ }
+
+ if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
+ return SDL_SetError("Couldn't send rumble packet");
+ }
+ return true;
+}
+
static bool HIDAPI_DriverFlydigi_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble)
{
if (device->vendor_id == USB_VENDOR_FLYDIGI_V1) {
@@ -632,6 +758,9 @@ static bool HIDAPI_DriverFlydigi_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J
Uint8 rumble_packet[] = { FLYDIGI_V2_CMD_REPORT_ID, FLYDIGI_V2_MAGIC1, FLYDIGI_V2_MAGIC2, FLYDIGI_V2_HAPTIC_COMMAND, 6, 0, 0, 0, 0, 0 };
rumble_packet[5] = low_frequency_rumble >> 8;
rumble_packet[6] = high_frequency_rumble >> 8;
+ if (HIDAPI_DriverFlydigi_UsesUnnumberedReports(device)) {
+ rumble_packet[0] = 0;
+ }
if (SDL_HIDAPI_SendRumble(device, rumble_packet, sizeof(rumble_packet)) != sizeof(rumble_packet)) {
return SDL_SetError("Couldn't send rumble packet");
@@ -642,12 +771,26 @@ static bool HIDAPI_DriverFlydigi_RumbleJoystick(SDL_HIDAPI_Device *device, SDL_J
static bool HIDAPI_DriverFlydigi_RumbleJoystickTriggers(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint16 left_rumble, Uint16 right_rumble)
{
- return SDL_Unsupported();
+ SDL_DriverFlydigi_Context *ctx = (SDL_DriverFlydigi_Context *)device->context;
+
+ if (!ctx->has_trigger_rumble) {
+ return SDL_Unsupported();
+ }
+
+ ctx->left_trigger_rumble = left_rumble >> 8;
+ ctx->right_trigger_rumble = right_rumble >> 8;
+ return HIDAPI_DriverFlydigi_SendRumbleV2(ctx);
}
static Uint32 HIDAPI_DriverFlydigi_GetJoystickCapabilities(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
{
- return SDL_JOYSTICK_CAP_RUMBLE;
+ SDL_DriverFlydigi_Context *ctx = (SDL_DriverFlydigi_Context *)device->context;
+ Uint32 caps = SDL_JOYSTICK_CAP_RUMBLE;
+
+ if (ctx->has_trigger_rumble) {
+ caps |= SDL_JOYSTICK_CAP_TRIGGER_RUMBLE;
+ }
+ return caps;
}
static bool HIDAPI_DriverFlydigi_SetJoystickLED(SDL_HIDAPI_Device *device, SDL_Joystick *joystick, Uint8 red, Uint8 green, Uint8 blue)
@@ -778,15 +921,10 @@ static void HIDAPI_DriverFlydigi_HandleStatePacketV1(SDL_Joystick *joystick, SDL
sensor_timestamp = ctx->sensor_timestamp_ns;
ctx->sensor_timestamp_ns += ctx->sensor_timestamp_step_ns;
- // Pitch and yaw scales may be receiving extra filtering for the sake of bespoke direct mouse output.
- // As result, roll has a different scaling factor than pitch and yaw.
- // These values were estimated using the testcontroller tool in lieux of hard data sheet references.
- const float flPitchAndYawScale = DEG2RAD(72000.0f);
- const float flRollScale = DEG2RAD(1200.0f);
-
- values[0] = HIDAPI_RemapVal(-1.0f * LOAD16(data[26], data[27]), INT16_MIN, INT16_MAX, -flPitchAndYawScale, flPitchAndYawScale);
- values[1] = HIDAPI_RemapVal(-1.0f * LOAD16(data[18], data[20]), INT16_MIN, INT16_MAX, -flPitchAndYawScale, flPitchAndYawScale);
- values[2] = HIDAPI_RemapVal(-1.0f * LOAD16(data[29], data[30]), INT16_MIN, INT16_MAX, -flRollScale, flRollScale);
+ const float *flGyroScale = ctx->gyroScale;
+ values[0] = LOAD16(data[26], data[27]) * flGyroScale[0] / INT16_MAX; // Acceleration along pitch axis
+ values[1] = LOAD16(data[18], data[20]) * flGyroScale[1] / INT16_MAX; // Acceleration along yaw axis
+ values[2] = LOAD16(data[29], data[30]) * flGyroScale[2] / INT16_MAX; // Acceleration along roll axis
SDL_SendJoystickSensor(timestamp, joystick, SDL_SENSOR_GYRO, sensor_timestamp, values, 3);
const float flAccelScale = ctx->accelScale;
@@ -930,7 +1068,7 @@ static void HIDAPI_DriverFlydigi_HandleStatePacketV2(SDL_Joystick *joystick, SDL
sensor_timestamp = ctx->sensor_timestamp_ns;
ctx->sensor_timestamp_ns += ctx->sensor_timestamp_step_ns;
- const float flGyroScale = ctx->gyroScale;
+ const float flGyroScale = ctx->gyroScale[0];
values[0] = HIDAPI_RemapVal((float)LOAD16(data[17], data[18]), INT16_MIN, INT16_MAX, -flGyroScale, flGyroScale);
values[1] = HIDAPI_RemapVal((float)LOAD16(data[21], data[22]), INT16_MIN, INT16_MAX, -flGyroScale, flGyroScale);
values[2] = HIDAPI_RemapVal(-(float)LOAD16(data[19], data[20]), INT16_MIN, INT16_MAX, -flGyroScale, flGyroScale);
@@ -1002,11 +1140,26 @@ static bool HIDAPI_DriverFlydigi_UpdateDevice(SDL_HIDAPI_Device *device)
joystick = SDL_GetJoystickFromID(device->joysticks[0]);
}
- if (device->vendor_id == USB_VENDOR_FLYDIGI_V2 && joystick) {
- if (!ctx->next_heartbeat || now >= ctx->next_heartbeat) {
- SDL_HIDAPI_Flydigi_SendAcquireRequest(device, true);
- SDL_HIDAPI_Flydigi_SendInfoRequest(device);
- ctx->next_heartbeat = now + FLYDIGI_ACQUIRE_CONTROLLER_HEARTBEAT_TIME;
+ if (device->vendor_id == USB_VENDOR_FLYDIGI_V2) {
+ if (joystick) {
+ if (!ctx->next_heartbeat || now >= ctx->next_heartbeat) {
+ if (SDL_HIDAPI_Flydigi_SendAcquireRequest(device, true)) {
+ ctx->acquired = true;
+ }
+ SDL_HIDAPI_Flydigi_SendInfoRequest(device);
+ SDL_HIDAPI_Flydigi_SendStatusRequest(device);
+ ctx->next_heartbeat = now + FLYDIGI_ACQUIRE_CONTROLLER_HEARTBEAT_TIME;
+
+ // Time the input timeout from the heartbeat so we don't send it again before the replies arrive
+ ctx->last_packet = now;
+ }
+ } else if (device->num_joysticks == 0) {
+ // We don't know yet whether we can use the controller, and the status reply might have been lost
+ const int STATUS_RETRY_MS = 1000;
+ if (now >= ctx->next_status_request) {
+ SDL_HIDAPI_Flydigi_SendStatusRequest(device);
+ ctx->next_status_request = now + STATUS_RETRY_MS;
+ }
}
}
diff --git a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.h b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.h
index cf60bed0f2d..12ea9adc637 100644
--- a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.h
+++ b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_flydigi.h
@@ -28,6 +28,7 @@ typedef enum
SDL_FLYDIGI_APEX3,
SDL_FLYDIGI_APEX4,
SDL_FLYDIGI_APEX5,
+ SDL_FLYDIGI_APEX6,
SDL_FLYDIGI_VADER2 = (1 << 4),
SDL_FLYDIGI_VADER2_PRO,
SDL_FLYDIGI_VADER3,
@@ -35,4 +36,3 @@ typedef enum
SDL_FLYDIGI_VADER4_PRO,
SDL_FLYDIGI_VADER5_PRO,
} SDL_FlyDigiControllerType;
-
diff --git a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_switch.c b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_switch.c
index 7580385af0e..188d93109b1 100644
--- a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_switch.c
+++ b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_switch.c
@@ -351,6 +351,10 @@ typedef struct
float fGyroScaleX;
float fGyroScaleY;
float fGyroScaleZ;
+
+ Sint16 sGyroOffsetX;
+ Sint16 sGyroOffsetY;
+ Sint16 sGyroOffsetZ;
} m_IMUScaleData;
} SDL_DriverSwitch_Context;
@@ -407,8 +411,10 @@ static SwitchSubcommandInputPacket_t *ReadSubcommandReply(SDL_DriverSwitch_Conte
continue;
}
if (reply->ucSubcommandID == k_eSwitchSubcommandIDs_SPIFlashRead) {
- SDL_assert(ucLen == sizeof(reply->spiReadData.opData));
- if (SDL_memcmp(&reply->spiReadData.opData, pBuf, ucLen) != 0) {
+ SDL_assert(ucLen == sizeof(SwitchSPIOpData_t));
+ const SwitchSPIOpData_t *request = (const SwitchSPIOpData_t *)pBuf;
+ if (reply->spiReadData.opData.unAddress != request->unAddress ||
+ reply->spiReadData.opData.ucLength < request->ucLength) {
// This was a reply for another SPI read command
continue;
}
@@ -958,10 +964,10 @@ static bool SetIMUEnabled(SDL_DriverSwitch_Context *ctx, bool enabled)
return WriteSubcommand(ctx, k_eSwitchSubcommandIDs_EnableIMU, &imu_data, sizeof(imu_data), NULL);
}
-static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
+static void LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
{
- Uint8 pLeftStickCal[9];
- Uint8 pRightStickCal[9];
+ Uint8 pLeftStickCal[9] = {0,0,0,0,0,0,0,0,0};
+ Uint8 pRightStickCal[9] = {0,0,0,0,0,0,0,0,0};
bool have_left_stick_cal = false, have_right_stick_cal = false;
size_t stick, axis;
SwitchSubcommandInputPacket_t *user_reply = NULL;
@@ -997,38 +1003,26 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
readFactoryParams.unAddress = k_unSPIStickFactoryCalibrationStartOffset;
readFactoryParams.ucLength = k_unSPIStickFactoryCalibrationLength;
- const int MAX_ATTEMPTS = 3;
- for (int attempt = 0;; ++attempt) {
- if (!WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) {
- return false;
- }
-
- if (factory_reply->stickFactoryCalibration.opData.unAddress == k_unSPIStickFactoryCalibrationStartOffset) {
- // We successfully read the calibration data
- // Avoid overriding user calibration if it's present for only one stick (known to happen on JoyCons)
- if (!have_left_stick_cal) {
- have_left_stick_cal = true;
- SDL_memcpy(pLeftStickCal, factory_reply->stickFactoryCalibration.rgucLeftCalibration, sizeof(pLeftStickCal));
- }
-
- if (!have_right_stick_cal) {
- have_right_stick_cal = true;
- SDL_memcpy(pRightStickCal, factory_reply->stickFactoryCalibration.rgucRightCalibration, sizeof(pRightStickCal));
- }
-
- break;
+ if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readFactoryParams, sizeof(readFactoryParams), &factory_reply)) {
+ // We successfully read the calibration data
+ // Avoid overriding user calibration if it's present for only one stick (known to happen on JoyCons)
+ if (!have_left_stick_cal) {
+ have_left_stick_cal = true;
+ SDL_memcpy(pLeftStickCal, factory_reply->stickFactoryCalibration.rgucLeftCalibration, sizeof(pLeftStickCal));
}
-
- if (attempt == MAX_ATTEMPTS) {
- return false;
+ if (!have_right_stick_cal) {
+ have_right_stick_cal = true;
+ SDL_memcpy(pRightStickCal, factory_reply->stickFactoryCalibration.rgucRightCalibration, sizeof(pRightStickCal));
}
}
}
- // If we still don't have calibration data, return false
- if (!have_left_stick_cal || !have_right_stick_cal)
- {
- return false;
+ // If we still don't have calibration data, use default values
+ if (!have_left_stick_cal) {
+ SDL_memset(pLeftStickCal, 0xFF, sizeof(pLeftStickCal));
+ }
+ if (!have_right_stick_cal) {
+ SDL_memset(pRightStickCal, 0xFF, sizeof(pRightStickCal));
}
/* Stick calibration values are 12-bits each and are packed by bit
@@ -1081,12 +1075,11 @@ static bool LoadStickCalibration(SDL_DriverSwitch_Context *ctx)
ctx->m_SimpleStickExtents[stick].axis[axis].sMax = (Sint16)(SDL_MAX_SINT16 * 0.5f);
}
}
-
- return true;
}
static bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
{
+ bool have_imu_cal = false;
SwitchSubcommandInputPacket_t *reply = NULL;
// Read Calibration Info
@@ -1122,29 +1115,48 @@ static bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
// Check for user calibration data. If it's present and set, it'll override the factory settings
readParams.unAddress = k_unSPIIMUUserScaleStartOffset;
readParams.ucLength = k_unSPIIMUUserScaleLength;
- if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply) && (pIMUScale[0] | pIMUScale[1] << 8) == 0xA1B2) {
- pIMUScale = reply->spiReadData.rgucReadData;
+ if (WriteSubcommand(ctx, k_eSwitchSubcommandIDs_SPIFlashRead, (uint8_t *)&readParams, sizeof(readParams), &reply)) {
+ Uint8 *pUserIMUScale = reply->spiReadData.rgucReadData;
- sAccelRawX = (pIMUScale[3] << 8) | pIMUScale[2];
- sAccelRawY = (pIMUScale[5] << 8) | pIMUScale[4];
- sAccelRawZ = (pIMUScale[7] << 8) | pIMUScale[6];
+ if ((pUserIMUScale[0] | (pUserIMUScale[1] << 8)) == 0xA1B2) {
+ pIMUScale = pUserIMUScale;
- sGyroRawX = (pIMUScale[15] << 8) | pIMUScale[14];
- sGyroRawY = (pIMUScale[17] << 8) | pIMUScale[16];
- sGyroRawZ = (pIMUScale[19] << 8) | pIMUScale[18];
+ sAccelRawX = (pIMUScale[3] << 8) | pIMUScale[2];
+ sAccelRawY = (pIMUScale[5] << 8) | pIMUScale[4];
+ sAccelRawZ = (pIMUScale[7] << 8) | pIMUScale[6];
+
+ sGyroRawX = (pIMUScale[15] << 8) | pIMUScale[14];
+ sGyroRawY = (pIMUScale[17] << 8) | pIMUScale[16];
+ sGyroRawZ = (pIMUScale[19] << 8) | pIMUScale[18];
+ }
}
- // Accelerometer scale
- ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffX - (float)sAccelRawX) * SDL_STANDARD_GRAVITY;
- ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffY - (float)sAccelRawY) * SDL_STANDARD_GRAVITY;
- ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffZ - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
+ if (sAccelSensCoeffX != sAccelRawX &&
+ sAccelSensCoeffY != sAccelRawY &&
+ sAccelSensCoeffZ != sAccelRawZ &&
+ sGyroSensCoeffX != sGyroRawX &&
+ sGyroSensCoeffY != sGyroRawY &&
+ sGyroSensCoeffZ != sGyroRawZ) {
+ // Gyro zero-rate offset
+ ctx->m_IMUScaleData.sGyroOffsetX = sGyroRawX;
+ ctx->m_IMUScaleData.sGyroOffsetY = sGyroRawY;
+ ctx->m_IMUScaleData.sGyroOffsetZ = sGyroRawZ;
- // Gyro scale
- ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffX - (float)sGyroRawX) * SDL_PI_F / 180.0f;
- ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffY - (float)sGyroRawY) * SDL_PI_F / 180.0f;
- ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffZ - (float)sGyroRawZ) * SDL_PI_F / 180.0f;
+ // Accelerometer scale
+ ctx->m_IMUScaleData.fAccelScaleX = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffX - (float)sAccelRawX) * SDL_STANDARD_GRAVITY;
+ ctx->m_IMUScaleData.fAccelScaleY = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffY - (float)sAccelRawY) * SDL_STANDARD_GRAVITY;
+ ctx->m_IMUScaleData.fAccelScaleZ = SWITCH_ACCEL_SCALE_MULT / ((float)sAccelSensCoeffZ - (float)sAccelRawZ) * SDL_STANDARD_GRAVITY;
- } else {
+ // Gyro scale
+ ctx->m_IMUScaleData.fGyroScaleX = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffX - (float)sGyroRawX) * SDL_PI_F / 180.0f;
+ ctx->m_IMUScaleData.fGyroScaleY = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffY - (float)sGyroRawY) * SDL_PI_F / 180.0f;
+ ctx->m_IMUScaleData.fGyroScaleZ = SWITCH_GYRO_SCALE_MULT / ((float)sGyroSensCoeffZ - (float)sGyroRawZ) * SDL_PI_F / 180.0f;
+
+ have_imu_cal = true;
+ }
+ }
+
+ if (!have_imu_cal) {
// Use default values
const float accelScale = SDL_STANDARD_GRAVITY / SWITCH_ACCEL_SCALE;
const float gyroScale = SDL_PI_F / 180.0f / SWITCH_GYRO_SCALE;
@@ -1156,7 +1168,13 @@ static bool LoadIMUCalibration(SDL_DriverSwitch_Context *ctx)
ctx->m_IMUScaleData.fGyroScaleX = gyroScale;
ctx->m_IMUScaleData.fGyroScaleY = gyroScale;
ctx->m_IMUScaleData.fGyroScaleZ = gyroScale;
+
+ ctx->m_IMUScaleData.sGyroOffsetX = 0;
+ ctx->m_IMUScaleData.sGyroOffsetY = 0;
+ ctx->m_IMUScaleData.sGyroOffsetZ = 0;
}
+
+ // FIXME: Should we read two reports and verify that gyro values are coming through?
return true;
}
@@ -1336,8 +1354,9 @@ static bool HIDAPI_DriverNintendoClassic_IsSupportedDevice(SDL_HIDAPI_Device *de
{
if (vendor_id == USB_VENDOR_NINTENDO) {
if (product_id == USB_PRODUCT_NINTENDO_SWITCH_JOYCON_RIGHT) {
- if (SDL_strncmp(name, "NES Controller", 14) == 0 ||
- SDL_strncmp(name, "HVC Controller", 14) == 0) {
+ if (name &&
+ (SDL_strncmp(name, "NES Controller", 14) == 0 ||
+ SDL_strncmp(name, "HVC Controller", 14) == 0)) {
return true;
}
}
@@ -1417,7 +1436,7 @@ static bool HIDAPI_DriverSwitch_IsSupportedDevice(SDL_HIDAPI_Device *device, con
controller to continually attempt to reconnect is to filter it out by manufacturer/product string.
Note that the controller does have a different product string when connected over Bluetooth.
*/
- if (SDL_strcmp(name, "HORI Wireless Switch Pad") == 0) {
+ if (name && SDL_strcmp(name, "HORI Wireless Switch Pad") == 0) {
return false;
}
@@ -1621,10 +1640,7 @@ static bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joys
}
}
- if (!LoadStickCalibration(ctx)) {
- SDL_SetError("Couldn't load stick calibration");
- return false;
- }
+ LoadStickCalibration(ctx);
if (ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCLeft &&
ctx->m_eControllerType != k_eSwitchDeviceInfoControllerType_HVCRight &&
@@ -2371,9 +2387,13 @@ static void SendSensorUpdate(Uint64 timestamp, SDL_Joystick *joystick, SDL_Drive
* users will want consistent axis mappings across devices.
*/
if (type == SDL_SENSOR_GYRO || type == SDL_SENSOR_GYRO_L || type == SDL_SENSOR_GYRO_R) {
- data[0] = -(ctx->m_IMUScaleData.fGyroScaleY * (float)values[1]);
- data[1] = ctx->m_IMUScaleData.fGyroScaleZ * (float)values[2];
- data[2] = -(ctx->m_IMUScaleData.fGyroScaleX * (float)values[0]);
+ const float gyroX = (float)(values[0] - ctx->m_IMUScaleData.sGyroOffsetX);
+ const float gyroY = (float)(values[1] - ctx->m_IMUScaleData.sGyroOffsetY);
+ const float gyroZ = (float)(values[2] - ctx->m_IMUScaleData.sGyroOffsetZ);
+
+ data[0] = -(ctx->m_IMUScaleData.fGyroScaleY * gyroY);
+ data[1] = ctx->m_IMUScaleData.fGyroScaleZ * gyroZ;
+ data[2] = -(ctx->m_IMUScaleData.fGyroScaleX * gyroX);
} else {
data[0] = -(ctx->m_IMUScaleData.fAccelScaleY * (float)values[1]);
data[1] = ctx->m_IMUScaleData.fAccelScaleZ * (float)values[2];
diff --git a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_xboxone.c b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_xboxone.c
index 5d97876f746..5c92bb03fe4 100644
--- a/thirdparty/sdl/joystick/hidapi/SDL_hidapi_xboxone.c
+++ b/thirdparty/sdl/joystick/hidapi/SDL_hidapi_xboxone.c
@@ -886,15 +886,18 @@ static bool HIDAPI_DriverXboxOne_HandleDescriptorReport(SDL_Joystick *joystick,
ctx->last_buttons = value;
const SDL_GamepadButton *button_map;
- if (field->bit_size == 12) {
+ int button_count;
+ if (field->bit_size == 12 || size == 15) {
button_map = button_map_12;
+ button_count = SDL_arraysize(button_map_12);
} else if (field->bit_size == 15) {
button_map = button_map_15;
+ button_count = SDL_arraysize(button_map_15);
} else {
// Should never happen
break;
}
- for (int button_index = 0; button_index < field->bit_size; ++button_index, value >>= 1) {
+ for (int button_index = 0; button_index < button_count; ++button_index, value >>= 1) {
SDL_GamepadButton button = button_map[button_index];
if (button == SDL_GAMEPAD_BUTTON_INVALID) {
continue;
diff --git a/thirdparty/sdl/joystick/usb_ids.h b/thirdparty/sdl/joystick/usb_ids.h
index ee0d8683fef..1b64d2908a1 100644
--- a/thirdparty/sdl/joystick/usb_ids.h
+++ b/thirdparty/sdl/joystick/usb_ids.h
@@ -78,6 +78,7 @@
#define USB_PRODUCT_8BITDO_PRO_2_BT 0x6006 // mode switch to D
#define USB_PRODUCT_8BITDO_PRO_3 0x6009 // mode switch to D
#define USB_PRODUCT_8BITDO_ULTIMATE2_WIRELESS 0x6012 // mode switch to BT
+#define USB_PRODUCT_8BITDO_ULTIMATE2C_WIRELESS 0x301b // mode switch to BT
#define USB_PRODUCT_8BITDO_ULTIMATE3 0x202f // mode switch to BT
#define USB_PRODUCT_AMAZON_LUNA_CONTROLLER 0x0419
#define USB_PRODUCT_ASTRO_C40_XBOX360 0x0024
@@ -93,6 +94,7 @@
#define USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER3 0x1846
#define USB_PRODUCT_FLYDIGI_V1_GAMEPAD 0x2412
#define USB_PRODUCT_FLYDIGI_V2_APEX 0x2501
+#define USB_PRODUCT_FLYDIGI_V2_APEX6 0x2502
#define USB_PRODUCT_FLYDIGI_V2_VADER 0x2401
#define USB_PRODUCT_HARMONIX_WII_RB1_GUITAR 0x0004
#define USB_PRODUCT_HARMONIX_WII_RB1_DRUMS 0x0005
diff --git a/thirdparty/sdl/joystick/windows/SDL_dinputjoystick.c b/thirdparty/sdl/joystick/windows/SDL_dinputjoystick.c
index c6712600f8d..37753113a39 100644
--- a/thirdparty/sdl/joystick/windows/SDL_dinputjoystick.c
+++ b/thirdparty/sdl/joystick/windows/SDL_dinputjoystick.c
@@ -45,7 +45,6 @@ extern HWND SDL_HelperWindow;
// local variables
static bool coinitialized = false;
static LPDIRECTINPUT8 dinput = NULL;
-static bool has_broken_EZFRD64DLL = false;
// Taken from Wine - Thanks!
static DIOBJECTDATAFORMAT dfDIJoystick2[] = {
@@ -346,50 +345,31 @@ static bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, Uint
void FreeRumbleEffectData(DIEFFECT *effect)
{
- if (!effect) {
- return;
- }
- SDL_free(effect->rgdwAxes);
- SDL_free(effect->rglDirection);
- SDL_free(effect->lpvTypeSpecificParams);
- SDL_free(effect);
+ SDL_free(effect); // it's all allocated in a single SDL_calloc() (or using static data) now.
}
DIEFFECT *CreateRumbleEffectData(Sint16 magnitude)
{
- DIEFFECT *effect;
- DIPERIODIC *periodic;
-
- // Create the effect
- effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect));
+ DIEFFECT *effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect) + sizeof (DIPERIODIC));
if (!effect) {
return NULL;
}
+
effect->dwSize = sizeof(*effect);
effect->dwGain = 10000;
effect->dwFlags = DIEFF_OBJECTOFFSETS;
effect->dwDuration = SDL_MAX_RUMBLE_DURATION_MS * 1000; // In microseconds.
effect->dwTriggerButton = DIEB_NOTRIGGER;
- effect->cAxes = 2;
- effect->rgdwAxes = (DWORD *)SDL_calloc(effect->cAxes, sizeof(DWORD));
- if (!effect->rgdwAxes) {
- FreeRumbleEffectData(effect);
- return NULL;
- }
+ static DWORD rgdwAxes[] = { DIJOFS_X, DIJOFS_Y };
+ effect->cAxes = SDL_arraysize(rgdwAxes);
+ effect->rgdwAxes = rgdwAxes;
- effect->rglDirection = (LONG *)SDL_calloc(effect->cAxes, sizeof(LONG));
- if (!effect->rglDirection) {
- FreeRumbleEffectData(effect);
- return NULL;
- }
+ static LONG rglDirection[] = { 0, 0 };
+ effect->rglDirection = rglDirection;
effect->dwFlags |= DIEFF_CARTESIAN;
- periodic = (DIPERIODIC *)SDL_calloc(1, sizeof(*periodic));
- if (!periodic) {
- FreeRumbleEffectData(effect);
- return NULL;
- }
+ DIPERIODIC *periodic = (DIPERIODIC *)(effect + 1); // we allocated this right after the effect struct.
periodic->dwMagnitude = CONVERT_MAGNITUDE(magnitude);
periodic->dwPeriod = 1000000;
@@ -438,29 +418,6 @@ bool SDL_DINPUT_JoystickInit(void)
dinput = NULL;
return SetDIerror("IDirectInput::Initialize", result);
}
-
-#ifdef _WIN64
- if (SDL_GetHintBoolean("SDL_JOYSTICK_CHECK_EZFRD64", true)) {
- // The 64-bit version of EZFRD64.DLL crashes after being loaded,
- // which happens implicitly when querying the device capabilities,
- // so make sure we don't do that if there's a possibility of crashing
- static const char *directories[] = {
- "C:/Windows/USB_Vibration",
- "C:/Windows/USB Vibration"
- };
- for (int i = 0; i < SDL_arraysize(directories) && !has_broken_EZFRD64DLL; ++i) {
- int count = 0;
- char **files = SDL_GlobDirectory(directories[i], "*/EZFRD64.DLL", SDL_GLOB_CASEINSENSITIVE, &count);
- if (count > 0) {
- has_broken_EZFRD64DLL = true;
- }
- SDL_free(files);
- }
- if (has_broken_EZFRD64DLL) {
- SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Broken EZFRD64.DLL detected, disabling DirectInput force feedback");
- }
- }
-#endif
return true;
}
@@ -806,7 +763,7 @@ bool SDL_DINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joysti
return SetDIerror("IDirectInputDevice8::SetDataFormat", result);
}
- if (!has_broken_EZFRD64DLL) {
+ if (!WIN_HasBrokenEZFRD64DLL()) {
// Get device capabilities to see if we are force feedback capable
result =
IDirectInputDevice8_GetCapabilities(joystick->hwdata->InputDevice,
diff --git a/thirdparty/sdl/joystick/windows/SDL_windowsjoystick.c b/thirdparty/sdl/joystick/windows/SDL_windowsjoystick.c
index a7ed293a956..0ba3746e552 100644
--- a/thirdparty/sdl/joystick/windows/SDL_windowsjoystick.c
+++ b/thirdparty/sdl/joystick/windows/SDL_windowsjoystick.c
@@ -200,7 +200,9 @@ static bool SDL_WaitForDeviceNotification(SDL_DeviceNotificationData *data, SDL_
}
SDL_UnlockMutex(mutex);
- while (lastret > 0 && !WindowsDeviceChanged()) {
+ // Pump messages until we're told to quit. Device changes are picked up by WINDOWS_JoystickDetect(),
+ // so returning while one is pending would just spin until the next detect.
+ while (lastret > 0) {
lastret = GetMessage(&msg, NULL, 0, 0); // WM_QUIT causes return value of 0
if (lastret > 0) {
TranslateMessage(&msg);
@@ -331,26 +333,21 @@ void WINDOWS_JoystickQuit(void);
static bool WINDOWS_JoystickInit(void)
{
- if (!SDL_XINPUT_JoystickInit()) {
- WINDOWS_JoystickQuit();
- return false;
- }
-
- if (!SDL_DINPUT_JoystickInit()) {
- WINDOWS_JoystickQuit();
- return false;
- }
-
WIN_InitDeviceNotification();
+ SDL_XINPUT_JoystickInit();
+ SDL_DINPUT_JoystickInit();
+
#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)
s_bJoystickThread = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_THREAD, true);
if (s_bJoystickThread) {
if (!SDL_StartJoystickThread()) {
+ WINDOWS_JoystickQuit();
return false;
}
} else {
if (!SDL_CreateDeviceNotification(&s_notification_data)) {
+ WINDOWS_JoystickQuit();
return false;
}
}
@@ -360,6 +357,7 @@ static bool WINDOWS_JoystickInit(void)
// On Xbox, force create the joystick thread for device detection (since other methods don't work
s_bJoystickThread = true;
if (!SDL_StartJoystickThread()) {
+ WINDOWS_JoystickQuit();
return false;
}
#endif
diff --git a/thirdparty/sdl/patches/0001-remove-unnecessary-subsystems.patch b/thirdparty/sdl/patches/0001-remove-unnecessary-subsystems.patch
index c7af24591f0..babb1938573 100644
--- a/thirdparty/sdl/patches/0001-remove-unnecessary-subsystems.patch
+++ b/thirdparty/sdl/patches/0001-remove-unnecessary-subsystems.patch
@@ -1,5 +1,5 @@
diff --git a/thirdparty/sdl/SDL.c b/thirdparty/sdl/SDL.c
-index 3e61b8ad4a..40982f2cfc 100644
+index 8354bd5de7..d62adb9b1e 100644
--- a/thirdparty/sdl/SDL.c
+++ b/thirdparty/sdl/SDL.c
@@ -30,9 +30,9 @@
@@ -418,7 +418,7 @@ index 95c5dc1a6b..fd0037eb7e 100644
if (!id_str) {
diff --git a/thirdparty/sdl/core/windows/SDL_windows.c b/thirdparty/sdl/core/windows/SDL_windows.c
-index b8b27e5ced..c7924bf934 100644
+index 1e9e6bba97..ed5da3daf3 100644
--- a/thirdparty/sdl/core/windows/SDL_windows.c
+++ b/thirdparty/sdl/core/windows/SDL_windows.c
@@ -24,7 +24,7 @@
@@ -1042,7 +1042,7 @@ index 377b04ec17..8bd09458c1 100644
// Start and stop the event processing loop
extern bool SDL_StartEventLoop(void);
diff --git a/thirdparty/sdl/include/SDL3/SDL.h b/thirdparty/sdl/include/SDL3/SDL.h
-index 51848b51be..d9055809c4 100644
+index 0ba8cb73f4..220ca022ce 100644
--- a/thirdparty/sdl/include/SDL3/SDL.h
+++ b/thirdparty/sdl/include/SDL3/SDL.h
@@ -48,7 +48,7 @@
@@ -1115,7 +1115,7 @@ index a4ea58025e..14d3790808 100644
SDL_PropertiesID props; /**< A properties ID for extensions. Should be 0 if no extensions are needed. */
} SDL_GPURenderStateCreateInfo;
diff --git a/thirdparty/sdl/joystick/SDL_joystick.c b/thirdparty/sdl/joystick/SDL_joystick.c
-index ccf6572f50..cf08c30b86 100644
+index 3ee5c218d6..ebfcef5b4f 100644
--- a/thirdparty/sdl/joystick/SDL_joystick.c
+++ b/thirdparty/sdl/joystick/SDL_joystick.c
@@ -29,7 +29,7 @@
@@ -1127,7 +1127,7 @@ index ccf6572f50..cf08c30b86 100644
#include "../sensor/SDL_sensor_c.h"
#include "hidapi/SDL_hidapijoystick_c.h"
-@@ -1239,7 +1239,8 @@ static void AttemptSensorFusion(SDL_Joystick *joystick, bool invert_sensors)
+@@ -1240,7 +1240,8 @@ static void AttemptSensorFusion(SDL_Joystick *joystick, bool invert_sensors)
When a phone is being used as a gamepad, its orientation changes,
so adjust sensor axes to match.
*/
@@ -1137,7 +1137,7 @@ index ccf6572f50..cf08c30b86 100644
/* When a device in landscape orientation is laid flat, the axes change
orientation as follows:
-X to +X becomes -X to +X
-@@ -2309,10 +2310,10 @@ static bool SDL_PrivateJoystickShouldIgnoreEvent(void)
+@@ -2310,10 +2311,10 @@ static bool SDL_PrivateJoystickShouldIgnoreEvent(void)
return false;
}
@@ -1153,7 +1153,7 @@ index ccf6572f50..cf08c30b86 100644
}
diff --git a/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c b/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c
-index 7d1ef1a890..23deb54a75 100644
+index 1613ff4abd..a81af29de4 100644
--- a/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c
+++ b/thirdparty/sdl/joystick/SDL_steam_virtual_gamepad.c
@@ -138,11 +138,11 @@ void SDL_InitSteamVirtualGamepadInfo(void)
diff --git a/thirdparty/sdl/patches/0002-fix-libudev-dbus.patch b/thirdparty/sdl/patches/0002-fix-libudev-dbus.patch
index 33d2826daae..3376d5a1edf 100644
--- a/thirdparty/sdl/patches/0002-fix-libudev-dbus.patch
+++ b/thirdparty/sdl/patches/0002-fix-libudev-dbus.patch
@@ -1,8 +1,8 @@
diff --git a/thirdparty/sdl/core/linux/SDL_dbus.c b/thirdparty/sdl/core/linux/SDL_dbus.c
-index cd7f77a100..663e70427a 100644
+index 2d3ae34b0b..de69b98c5f 100644
--- a/thirdparty/sdl/core/linux/SDL_dbus.c
+++ b/thirdparty/sdl/core/linux/SDL_dbus.c
-@@ -115,15 +115,18 @@ static bool LoadDBUSSyms(void)
+@@ -116,15 +116,18 @@ static bool LoadDBUSSyms(void)
static void UnloadDBUSLibrary(void)
{
@@ -21,7 +21,7 @@ index cd7f77a100..663e70427a 100644
if (!dbus_handle) {
dbus_handle = SDL_LoadObject(dbus_library);
if (!dbus_handle) {
-@@ -136,6 +139,9 @@ static bool LoadDBUSLibrary(void)
+@@ -137,6 +140,9 @@ static bool LoadDBUSLibrary(void)
}
}
}
@@ -32,7 +32,7 @@ index cd7f77a100..663e70427a 100644
}
diff --git a/thirdparty/sdl/core/linux/SDL_udev.c b/thirdparty/sdl/core/linux/SDL_udev.c
-index 3aaa0fb4e9..58b0b1ed42 100644
+index 107e1d6c76..a715ac3b90 100644
--- a/thirdparty/sdl/core/linux/SDL_udev.c
+++ b/thirdparty/sdl/core/linux/SDL_udev.c
@@ -53,7 +53,9 @@ SDL_ELF_NOTE_DLOPEN(
@@ -61,7 +61,7 @@ index f2b1ce56e2..5958ba4f37 100644
#include <sys/time.h>
#include <sys/types.h>
diff --git a/thirdparty/sdl/hidapi/linux/hid.c b/thirdparty/sdl/hidapi/linux/hid.c
-index c0cb6a7b0e..367b243830 100644
+index a66f62e4e6..411fa17099 100644
--- a/thirdparty/sdl/hidapi/linux/hid.c
+++ b/thirdparty/sdl/hidapi/linux/hid.c
@@ -40,7 +40,37 @@
diff --git a/thirdparty/sdl/patches/0004-ios-accelerometer.patch b/thirdparty/sdl/patches/0004-ios-accelerometer.patch
index 8601d3443af..b21a508b34b 100644
--- a/thirdparty/sdl/patches/0004-ios-accelerometer.patch
+++ b/thirdparty/sdl/patches/0004-ios-accelerometer.patch
@@ -1,8 +1,8 @@
diff --git a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
-index 36e18f0ec7..b4b31704d0 100644
+index 33fb754d0b..76794ed815 100644
--- a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
+++ b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
-@@ -946,8 +946,6 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
+@@ -947,8 +947,6 @@ static bool IOS_JoystickOpen(SDL_Joystick *joystick, int device_index)
GCMotion *motion = controller.motion;
if (motion && motion.hasRotationRate) {
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_GYRO, 0.0f);
@@ -11,7 +11,7 @@ index 36e18f0ec7..b4b31704d0 100644
SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 0.0f);
}
}
-@@ -1198,20 +1196,17 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
+@@ -1199,20 +1197,17 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
if (motion && motion.sensorsActive) {
float data[3];
diff --git a/thirdparty/sdl/stdlib/SDL_iconv.c b/thirdparty/sdl/stdlib/SDL_iconv.c
index c07f6cf9450..dc2071ec25c 100644
--- a/thirdparty/sdl/stdlib/SDL_iconv.c
+++ b/thirdparty/sdl/stdlib/SDL_iconv.c
@@ -265,10 +265,10 @@ size_t SDL_iconv(SDL_iconv_t cd,
size_t n = srclen / 2;
while (n) {
if (p[0] == 0xFF && p[1] == 0xFE) {
- cd->src_fmt = ENCODING_UTF16BE;
+ cd->src_fmt = ENCODING_UTF16LE;
break;
} else if (p[0] == 0xFE && p[1] == 0xFF) {
- cd->src_fmt = ENCODING_UTF16LE;
+ cd->src_fmt = ENCODING_UTF16BE;
break;
}
p += 2;
@@ -288,11 +288,11 @@ size_t SDL_iconv(SDL_iconv_t cd,
while (n) {
if (p[0] == 0xFF && p[1] == 0xFE &&
p[2] == 0x00 && p[3] == 0x00) {
- cd->src_fmt = ENCODING_UTF32BE;
+ cd->src_fmt = ENCODING_UTF32LE;
break;
} else if (p[0] == 0x00 && p[1] == 0x00 &&
p[2] == 0xFE && p[3] == 0xFF) {
- cd->src_fmt = ENCODING_UTF32LE;
+ cd->src_fmt = ENCODING_UTF32BE;
break;
}
p += 4;
diff --git a/thirdparty/sdl/stdlib/SDL_string.c b/thirdparty/sdl/stdlib/SDL_string.c
index e0e7d573370..415a7316822 100644
--- a/thirdparty/sdl/stdlib/SDL_string.c
+++ b/thirdparty/sdl/stdlib/SDL_string.c
@@ -240,7 +240,7 @@ static Uint32 StepUTF8(const char **_str, const size_t slen)
const Uint8 str2 = str[2];
const Uint8 str3 = str[3];
if (((str1 & 0xC0) == 0x80) && ((str2 & 0xC0) == 0x80) && ((str3 & 0xC0) == 0x80)) { // If trailing bytes aren't 10xxxxxx, sequence is bogus.
- const Uint32 octet2 = ((Uint32) (str1 & 0x1F)) << 12;
+ const Uint32 octet2 = ((Uint32) (str1 & 0x3F)) << 12;
const Uint32 octet3 = ((Uint32) (str2 & 0x3F)) << 6;
const Uint32 octet4 = ((Uint32) (str3 & 0x3F));
const Uint32 result = ((octet & 0x07) << 18) | octet2 | octet3 | octet4;
diff --git a/thirdparty/sdl/thread/pthread/SDL_syscond.c b/thirdparty/sdl/thread/pthread/SDL_syscond.c
index 9849f5e4f9a..12ddf574915 100644
--- a/thirdparty/sdl/thread/pthread/SDL_syscond.c
+++ b/thirdparty/sdl/thread/pthread/SDL_syscond.c
@@ -28,6 +28,12 @@
#include "SDL_sysmutex_c.h"
+#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_PTHREAD_CONDATTR_SETCLOCK)
+#define COND_CLOCK CLOCK_MONOTONIC
+#else
+#define COND_CLOCK CLOCK_REALTIME
+#endif
+
struct SDL_Condition
{
pthread_cond_t cond;
@@ -40,11 +46,21 @@ SDL_Condition *SDL_CreateCondition(void)
cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition));
if (cond) {
- if (pthread_cond_init(&cond->cond, NULL) != 0) {
+ pthread_condattr_t attr;
+ if (pthread_condattr_init(&attr) != 0) {
+ SDL_SetError("pthread_condattr_init() failed");
+ SDL_free(cond);
+ return NULL;
+ }
+#ifdef HAVE_PTHREAD_CONDATTR_SETCLOCK
+ pthread_condattr_setclock(&attr, COND_CLOCK);
+#endif
+ if (pthread_cond_init(&cond->cond, &attr) != 0) {
SDL_SetError("pthread_cond_init() failed");
SDL_free(cond);
cond = NULL;
}
+ pthread_condattr_destroy(&attr);
}
return cond;
}
@@ -80,9 +96,6 @@ void SDL_BroadcastCondition(SDL_Condition *cond)
bool SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 timeoutNS)
{
-#ifndef HAVE_CLOCK_GETTIME
- struct timeval delta;
-#endif
struct timespec abstime;
if (!cond || !mutex) {
@@ -94,11 +107,12 @@ bool SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 ti
}
#ifdef HAVE_CLOCK_GETTIME
- clock_gettime(CLOCK_REALTIME, &abstime);
+ clock_gettime(COND_CLOCK, &abstime);
abstime.tv_sec += (timeoutNS / SDL_NS_PER_SECOND);
abstime.tv_nsec += (timeoutNS % SDL_NS_PER_SECOND);
#else
+ struct timeval delta;
gettimeofday(&delta, NULL);
abstime.tv_sec = delta.tv_sec + (timeoutNS / SDL_NS_PER_SECOND);
diff --git a/thirdparty/sdl/thread/pthread/SDL_syssem.c b/thirdparty/sdl/thread/pthread/SDL_syssem.c
index a3a53185dd5..eb697c2d702 100644
--- a/thirdparty/sdl/thread/pthread/SDL_syssem.c
+++ b/thirdparty/sdl/thread/pthread/SDL_syssem.c
@@ -33,6 +33,12 @@
#include "../generic/SDL_syssem.c"
#else
+#if defined(HAVE_CLOCK_GETTIME) && (defined(HAVE_SEM_CLOCKWAIT) || defined(HAVE_SEM_CLOCKWAIT_NP))
+#define SEM_CLOCK CLOCK_MONOTONIC
+#else
+#define SEM_CLOCK CLOCK_REALTIME
+#endif
+
struct SDL_Semaphore
{
sem_t sem;
@@ -62,15 +68,6 @@ void SDL_DestroySemaphore(SDL_Semaphore *sem)
bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
{
-#ifdef HAVE_SEM_TIMEDWAIT
-#ifndef HAVE_CLOCK_GETTIME
- struct timeval now;
-#endif
- struct timespec ts_timeout;
-#else
- Uint64 stop_time;
-#endif
-
if (!sem) {
return true;
}
@@ -89,18 +86,20 @@ bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
return (rc == 0);
}
-#ifdef HAVE_SEM_TIMEDWAIT
- /* Setup the timeout. sem_timedwait doesn't wait for
- * a lapse of time, but until we reach a certain time.
+#if defined(HAVE_SEM_CLOCKWAIT) || defined(HAVE_SEM_CLOCKWAIT_NP) || defined(HAVE_SEM_TIMEDWAIT)
+ /* Setup the timeout. sem_clockwait and sem_timedwait don't wait
+ * for a lapse of time, but until we reach a certain time.
* This time is now plus the timeout.
*/
+ struct timespec ts_timeout;
#ifdef HAVE_CLOCK_GETTIME
- clock_gettime(CLOCK_REALTIME, &ts_timeout);
+ clock_gettime(SEM_CLOCK, &ts_timeout);
// Add our timeout to current time
ts_timeout.tv_sec += (timeoutNS / SDL_NS_PER_SECOND);
ts_timeout.tv_nsec += (timeoutNS % SDL_NS_PER_SECOND);
#else
+ struct timeval now;
gettimeofday(&now, NULL);
// Add our timeout to current time
@@ -117,12 +116,18 @@ bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
// Wait.
int rc;
do {
+#if defined(HAVE_SEM_CLOCKWAIT)
+ rc = sem_clockwait(&sem->sem, SEM_CLOCK, &ts_timeout);
+#elif defined(HAVE_SEM_CLOCKWAIT_NP)
+ rc = sem_clockwait_np(&sem->sem, SEM_CLOCK, TIMER_ABSTIME, &ts_timeout, NULL);
+#else
rc = sem_timedwait(&sem->sem, &ts_timeout);
+#endif
} while (rc < 0 && errno == EINTR);
return (rc == 0);
#else
- stop_time = SDL_GetTicksNS() + timeoutNS;
+ Uint64 stop_time = SDL_GetTicksNS() + timeoutNS;
while (sem_trywait(&sem->sem) != 0) {
if (SDL_GetTicksNS() >= stop_time) {
return false;
@@ -130,7 +135,7 @@ bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS)
SDL_DelayNS(100);
}
return true;
-#endif // HAVE_SEM_TIMEDWAIT
+#endif // defined(HAVE_SEM_CLOCKWAIT) || defined(HAVE_SEM_CLOCKWAIT_NP) || defined(HAVE_SEM_TIMEDWAIT)
}
Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem)
diff --git a/thirdparty/sdl/update-sdl.sh b/thirdparty/sdl/update-sdl.sh
index 0d4382a4259..dee364930ab 100755
--- a/thirdparty/sdl/update-sdl.sh
+++ b/thirdparty/sdl/update-sdl.sh
@@ -1,6 +1,6 @@
#!/bin/bash -e
-VERSION=3.4.16
+VERSION=3.4.20
target=$(dirname "$(realpath $0)")
pushd $target