Mac: Detect the d-pad and pause buttons on Steelseries MFi gamepads (bug #3124.)
authorAlex Szpakowski <slime73@gmail.com>
Thu, 12 Nov 2015 22:44:32 -0400
changeset 9912 628225876708
parent 9911 7423403b70da
child 9913 3a1a20edbecc
Mac: Detect the d-pad and pause buttons on Steelseries MFi gamepads (bug #3124.)
src/joystick/darwin/SDL_sysjoystick.c
src/video/uikit/SDL_uikitwindow.m
--- a/src/joystick/darwin/SDL_sysjoystick.c	Thu Nov 12 20:58:11 2015 -0400
+++ b/src/joystick/darwin/SDL_sysjoystick.c	Thu Nov 12 22:44:32 2015 -0400
@@ -243,6 +243,18 @@
                                     }
                                 }
                                 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 @@
                         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) {
--- a/src/video/uikit/SDL_uikitwindow.m	Thu Nov 12 20:58:11 2015 -0400
+++ b/src/video/uikit/SDL_uikitwindow.m	Thu Nov 12 22:44:32 2015 -0400
@@ -317,6 +317,10 @@
                 [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;
         }