Mac: Detect the d-pad and pause buttons on Steelseries MFi gamepads (bug #3124.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c
index e9a028b..5abb09c 100644
--- a/src/joystick/darwin/SDL_sysjoystick.c
+++ b/src/joystick/darwin/SDL_sysjoystick.c
@@ -243,6 +243,18 @@ AddHIDElement(const void *value, void *parameter)
}
}
break;
+ case kHIDUsage_GD_DPadUp:
+ case kHIDUsage_GD_DPadDown:
+ case kHIDUsage_GD_DPadRight:
+ case kHIDUsage_GD_DPadLeft:
+ if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) {
+ element = (recElement *) SDL_calloc(1, sizeof (recElement));
+ if (element) {
+ pDevice->buttons++;
+ headElement = &(pDevice->firstButton);
+ }
+ }
+ break;
}
break;
@@ -265,6 +277,7 @@ AddHIDElement(const void *value, void *parameter)
break;
case kHIDPage_Button:
+ case kHIDPage_Consumer: /* e.g. 'pause' button on Steelseries MFi gamepads. */
if (!ElementAlreadyAdded(cookie, pDevice->firstButton)) {
element = (recElement *) SDL_calloc(1, sizeof (recElement));
if (element) {
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index 3dc3910..6826f82 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -317,6 +317,10 @@ UIKit_DestroyWindow(_THIS, SDL_Window * window)
[view setSDLWindow:NULL];
}
+ /* iOS may still hold a reference to the window after we release it.
+ * We want to make sure the SDL view controller isn't accessed in
+ * that case, because it would contain an invalid pointer to the old
+ * SDL window. */
data.uiwindow.rootViewController = nil;
data.uiwindow.hidden = YES;
}