Skip to content

Commit e07acf0

Browse files
committed
Merge pull request #110500 from sorascode/fix-macos-joy-name
[macOS] Use `productCategory` instead of `vendorName` for joypad name in SDL
2 parents dc32e2c + 92172ca commit e07acf0

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

thirdparty/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -973,6 +973,7 @@ Patches:
973973
- `0004-errno-include.patch` (GH-108354)
974974
- `0005-fix-libudev-dbus.patch` (GH-108373)
975975
- `0006-fix-cs-environ.patch` (GH-109283)
976+
- `0007-macos-joypad-name.patch` (GH-110500)
976977

977978
The SDL source code folder includes `hidapi` library inside of folder `thirdparty/sdl/hidapi/`.
978979
Its version and license is described in this file under `hidapi`.

thirdparty/sdl/joystick/apple/SDL_mfijoystick.m

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,15 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
300300
* struct, and ARC doesn't work with structs. */
301301
device->controller = (__bridge GCController *)CFBridgingRetain(controller);
302302

303-
if (controller.vendorName) {
304-
name = controller.vendorName.UTF8String;
305-
}
303+
if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
304+
if (controller.productCategory) {
305+
name = controller.productCategory.UTF8String;
306+
}
307+
} else {
308+
if (controller.vendorName) {
309+
name = controller.vendorName.UTF8String;
310+
}
311+
}
306312

307313
if (!name) {
308314
name = "MFi Gamepad";
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
2+
index 811a9f1ae7..2ba2cbeae6 100644
3+
--- a/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
4+
+++ b/thirdparty/sdl/joystick/apple/SDL_mfijoystick.m
5+
@@ -300,9 +300,15 @@ static bool IOS_AddMFIJoystickDevice(SDL_JoystickDeviceItem *device, GCControlle
6+
* struct, and ARC doesn't work with structs. */
7+
device->controller = (__bridge GCController *)CFBridgingRetain(controller);
8+
9+
- if (controller.vendorName) {
10+
- name = controller.vendorName.UTF8String;
11+
- }
12+
+ if (@available(macOS 10.15, iOS 13.0, tvOS 13.0, *)) {
13+
+ if (controller.productCategory) {
14+
+ name = controller.productCategory.UTF8String;
15+
+ }
16+
+ } else {
17+
+ if (controller.vendorName) {
18+
+ name = controller.vendorName.UTF8String;
19+
+ }
20+
+ }
21+
22+
if (!name) {
23+
name = "MFi Gamepad";
24+
--
25+
2.51.0

0 commit comments

Comments
 (0)