From 92172cab9d0dd597534658949183dcb934ad5abf Mon Sep 17 00:00:00 2001 From: sora Date: Sat, 13 Sep 2025 22:16:17 +0200 Subject: [PATCH] macOS: Use `productCategory` instead of `vendorName` for joypad name --- thirdparty/README.md | 1 + .../sdl/joystick/apple/SDL_mfijoystick.m | 12 ++++++--- .../sdl/patches/0007-macos-joypad-name.patch | 25 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 thirdparty/sdl/patches/0007-macos-joypad-name.patch diff --git a/thirdparty/README.md b/thirdparty/README.md index efd9dc92475..b8f753ff8d0 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -973,6 +973,7 @@ Patches: - `0004-errno-include.patch` (GH-108354) - `0005-fix-libudev-dbus.patch` (GH-108373) - `0006-fix-cs-environ.patch` (GH-109283) +- `0007-macos-joypad-name.patch` (GH-110500) The SDL source code folder includes `hidapi` library inside of folder `thirdparty/sdl/hidapi/`. Its version and license is described in this file under `hidapi`. diff --git a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m index 811a9f1ae76..2ba2cbeae64 100644 --- a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m +++ b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m @@ -300,9 +300,15 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle * struct, and ARC doesn't work with structs. */ device->controller = (__bridge GCController *)CFBridgingRetain(controller); - if (controller.vendorName) { - name = controller.vendorName.UTF8String; - } + if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { + if (controller.productCategory) { + name = controller.productCategory.UTF8String; + } + } else { + if (controller.vendorName) { + name = controller.vendorName.UTF8String; + } + } if (!name) { name = "MFi Gamepad"; diff --git a/thirdparty/sdl/patches/0007-macos-joypad-name.patch b/thirdparty/sdl/patches/0007-macos-joypad-name.patch new file mode 100644 index 00000000000..c8ca1505f1f --- /dev/null +++ b/thirdparty/sdl/patches/0007-macos-joypad-name.patch @@ -0,0 +1,25 @@ +diff --git a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m +index 811a9f1ae7..2ba2cbeae6 100644 +--- a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m ++++ b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m +@@ -300,9 +300,15 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle + * struct, and ARC doesn't work with structs. */ + device->controller = (__bridge GCController *)CFBridgingRetain(controller); + +- if (controller.vendorName) { +- name = controller.vendorName.UTF8String; +- } ++ if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) { ++ if (controller.productCategory) { ++ name = controller.productCategory.UTF8String; ++ } ++ } else { ++ if (controller.vendorName) { ++ name = controller.vendorName.UTF8String; ++ } ++ } + + if (!name) { + name = "MFi Gamepad"; +-- +2.51.0