Allow reading background events for MFi controllers

This commit is contained in:
Sam Lantinga 2022-03-08 18:42:13 -08:00
parent b064ad6ac5
commit 6a787619e6
1 changed files with 7 additions and 0 deletions

View File

@ -69,6 +69,9 @@ static NSString *GCInputXboxShareButton = @"Button Share";
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000)) #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 130000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 130000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1500000))
@property(nonatomic, readonly) NSString *productCategory; @property(nonatomic, readonly) NSString *productCategory;
#endif #endif
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 140500) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 140500) || (__MAC_OS_X_VERSION_MAX_ALLOWED >= 110300))
@property(class, nonatomic, readwrite) BOOL shouldMonitorBackgroundEvents;
#endif
@end @end
@interface GCExtendedGamepad (SDL) @interface GCExtendedGamepad (SDL)
#if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 121000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 121000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1401000)) #if !((__IPHONE_OS_VERSION_MAX_ALLOWED >= 121000) || (__APPLETV_OS_VERSION_MAX_ALLOWED >= 121000) || (__MAC_OS_VERSION_MAX_ALLOWED >= 1401000))
@ -572,6 +575,10 @@ IOS_JoystickInit(void)
return 0; return 0;
} }
if (@available(macOS 11.3, iOS 14.5, tvOS 14.5, *)) {
GCController.shouldMonitorBackgroundEvents = YES;
}
/* For whatever reason, this always returns an empty array on /* For whatever reason, this always returns an empty array on
macOS 11.0.1 */ macOS 11.0.1 */
for (GCController *controller in [GCController controllers]) { for (GCController *controller in [GCController controllers]) {