diff --git a/iOS-res/hash.zip b/iOS-res/hash.zip index 23d143bf..013e1ece 100644 Binary files a/iOS-res/hash.zip and b/iOS-res/hash.zip differ diff --git a/iOS-res/plugins.zip b/iOS-res/plugins.zip index 0e0a1617..de4e69cf 100644 Binary files a/iOS-res/plugins.zip and b/iOS-res/plugins.zip differ diff --git a/iOS/EmulatorController.m b/iOS/EmulatorController.m index cd65e52e..a4bdb090 100644 --- a/iOS/EmulatorController.m +++ b/iOS/EmulatorController.m @@ -76,11 +76,8 @@ #import "WebServer.h" #import "Alert.h" #import "ZipFile.h" -#import "SteamController.h" #import "SkinManager.h" -#if 0 #import "CloudSync.h" -#endif #import "SoftwareList.h" #import "Timer.h" @@ -304,8 +301,6 @@ -(void)toggleFullScreen:(id)sender; static NSInteger g_settings_file_count; static Options* g_settings_options; -static BOOL g_bluetooth_enabled; - static EmulatorController *sharedInstance = nil; static const int buttonPressReleaseCycles = 2; @@ -748,10 +743,11 @@ void m4i_game_list(myosd_game_info* game_info, int game_count) year = @""; NSString *driver = [@(game_info[i].source_file ?: "").lastPathComponent stringByDeletingPathExtension]; +#if TARGET_APPSTORE // App Store release: don't include pong/breakout to avoid copyright issues - if ( [driver isEqualToString:@"pong"] || [driver isEqualToString:@"breakout"]) { - continue; - } + if ( [driver isEqualToString:@"pong"] || [driver isEqualToString:@"breakout"]) + continue; +#endif GameInfo* game = [[GameInfo alloc] initWithDictionary:@{ kGameInfoType: type, @@ -784,8 +780,8 @@ void m4i_game_list(myosd_game_info* game_info, int game_count) [games addObject:game]; [games addObjectsFromArray:software]; } - -#if 0 + +#if !TARGET_APPSTORE NSString* mame_version = [@((const char *)myosd_get(MYOSD_VERSION_STRING) ?: "") componentsSeparatedByString:@" ("].firstObject; // add a *special* system game that will run the DOS MAME menu. @@ -1477,16 +1473,12 @@ - (void)runAddROMS:(id)from { [self runImport]; }]]; #endif - -#if 0 if (CloudSync.status == CloudSyncStatusAvailable) { [alert addAction:[UIAlertAction actionWithTitle:@"Import from iCloud" symbol:@"icloud.and.arrow.down" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action) { [CloudSync import]; }]]; } -#endif - #if TARGET_OS_IOS [alert addAction:[UIAlertAction actionWithTitle:@"Show Files" symbol:@"folder" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action) { [self runShowFiles]; @@ -1891,17 +1883,6 @@ -(void)viewDidLoad{ // always enable Keyboard for hardware keyboard support keyboardView.active = YES; - // see if bluetooth is enabled... - - if (@available(iOS 13.1, tvOS 13.0, *)) - g_bluetooth_enabled = CBCentralManager.authorization == CBManagerAuthorizationAllowedAlways; - else if (@available(iOS 13.0, *)) - g_bluetooth_enabled = FALSE; // authorization is not in iOS 13.0, so no bluetooth for you. - else - g_bluetooth_enabled = TRUE; // pre-iOS 13.0, bluetooth allways. - - NSLog(@"BLUETOOTH ENABLED: %@", g_bluetooth_enabled ? @"YES" : @"NO"); - [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(gameControllerConnected:) name:GCControllerDidConnectNotification object:nil]; [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(gameControllerDisconnected:) name:GCControllerDidDisconnectNotification object:nil]; @@ -5192,13 +5173,6 @@ -(void)setupGameControllers { [controllers addObject:controler]; } - // now add any Steam Controllers, these should always have a extendedGamepad profile - if (g_bluetooth_enabled) { - for (GCController* controler in SteamControllerManager.sharedManager.controllers) { - if (controler.extendedGamepad != nil) - [controllers addObject:controler]; - } - } // only handle upto NUM_JOY (non Siri Remote) controllers if (controllers.count > MYOSD_NUM_JOY) { [controllers removeObjectsInRange:NSMakeRange(MYOSD_NUM_JOY,controllers.count - MYOSD_NUM_JOY)]; @@ -5695,8 +5669,6 @@ -(void)dumpDevice:(NSObject*)_device { -(void)scanForDevices{ [GCController startWirelessControllerDiscoveryWithCompletionHandler:nil]; - if (g_bluetooth_enabled) - [[SteamControllerManager sharedManager] scanForControllers]; } -(void)gameControllerConnected:(NSNotification*)notif{ @@ -6057,8 +6029,8 @@ -(void)chooseGame:(NSArray*)games { NSLog(@"ROMS: %@", [NSFileManager.defaultManager enumeratorAtPath:getDocumentPath(@"roms")].allObjects); NSLog(@"SOFTWARE: %@", [NSFileManager.defaultManager enumeratorAtPath:getDocumentPath(@"software")].allObjects); - // 4/14/24 TODO: commenting this out for App Store release since games are bundled - create a build config for App Store -#if 0 + // 4/14/24 TODO: commenting this out for App Store release since games are bundled +#if !TARGET_APPSTORE // NOTE: MAME 2xx has a bunch of "no-rom" arcade games, we need to check if `roms` is empty too NSInteger roms_count = [NSFileManager.defaultManager enumeratorAtPath:getDocumentPath(@"roms")].allObjects.count + [NSFileManager.defaultManager enumeratorAtPath:getDocumentPath(@"software")].allObjects.count; @@ -6067,14 +6039,12 @@ -(void)chooseGame:(NSArray*)games { if (g_no_roms_found && !g_no_roms_found_canceled) { NSLog(@"NO GAMES, ASK USER WHAT TO DO...."); -#if 0 // if iCloud is still initializing give it a litte time. if ([CloudSync status] == CloudSyncStatusUnknown) { NSLog(@"....WAITING FOR iCloud"); [self performSelector:_cmd withObject:games afterDelay:1.0]; return; } -#endif change_pause(PAUSE_INPUT); [self runAddROMS:nil]; @@ -6109,14 +6079,6 @@ -(void)chooseGame:(NSArray*)games { return; } - // now that we have passed the startup phase, check on and maybe re-enable bluetooth. - if (@available(iOS 13.1, tvOS 13.0, *)) { - if (!g_bluetooth_enabled && CBCentralManager.authorization == CBManagerAuthorizationNotDetermined) { - g_bluetooth_enabled = TRUE; - [self performSelectorOnMainThread:@selector(scanForDevices) withObject:nil waitUntilDone:NO]; - } - } - [self updateUserActivity:nil]; NSLog(@"GAMES: %@", games); diff --git a/iOS/Globals.h b/iOS/Globals.h index dba57bfc..56dec06c 100644 --- a/iOS/Globals.h +++ b/iOS/Globals.h @@ -57,8 +57,8 @@ #define PRODUCT_NAME "MAME4sim" #define PRODUCT_NAME_LONG "MAME for Simulator" #else - #define PRODUCT_NAME "MAME" - #define PRODUCT_NAME_LONG "MAME" + #define PRODUCT_NAME "MAME4iOS" + #define PRODUCT_NAME_LONG "MAME for iOS" #endif static inline BOOL IsRunningOnMac(void) { diff --git a/iOS/OptionsController.h b/iOS/OptionsController.h index c9e0e78c..85fa22b9 100644 --- a/iOS/OptionsController.h +++ b/iOS/OptionsController.h @@ -50,9 +50,7 @@ enum OptionSections kSupportSection = 0, kOtherSection, kImportSection, -#if 0 kCloudImportSection, -#endif kVideoSection, kVectorSection, kFullscreenSection, diff --git a/iOS/OptionsController.m b/iOS/OptionsController.m index 7ed57f17..e0e285d6 100644 --- a/iOS/OptionsController.m +++ b/iOS/OptionsController.m @@ -50,10 +50,7 @@ #import "HelpController.h" #import "EmulatorController.h" #import "ImageCache.h" - -#if 0 #import "CloudSync.h" -#endif #import "Alert.h" @@ -346,7 +343,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } break; } -#if 0 case kCloudImportSection: { switch (indexPath.row) @@ -382,7 +378,6 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N } break; } -#endif case kResetSection: { switch (indexPath.row) @@ -444,9 +439,7 @@ - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInte case kFilterSection: return @"Game Filter"; case kOtherSection: return @""; // @"Other"; case kImportSection: return @"Import and Export"; -#if 0 case kCloudImportSection: return @"iCloud"; -#endif case kResetSection: return @""; case kBenchmarkSection: return @""; } @@ -466,7 +459,6 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger case kMiscSection: return 8; case kFilterSection: return 3; case kImportSection: return 4; -#if 0 case kCloudImportSection: if (CloudSync.status == CloudSyncStatusAvailable) return 4; @@ -474,7 +466,6 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger return 1; else return 0; -#endif case kResetSection: return 1; case kBenchmarkSection: return self.presentingViewController == self.emuController ? 1 : 0; @@ -559,7 +550,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } break; } -#if 0 case kCloudImportSection: { if (row==0) { @@ -579,7 +569,6 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath } break; } -#endif case kResetSection: { if (row==0) { diff --git a/xcode/MAME4iOS/CloudSync.m b/xcode/MAME4iOS/CloudSync.m index 6f9553b5..f5bcf9ea 100644 --- a/xcode/MAME4iOS/CloudSync.m +++ b/xcode/MAME4iOS/CloudSync.m @@ -27,15 +27,6 @@ #import "EmulatorController.h" #import "Alert.h" -#if TARGET_OS_MACCATALYST -#import -#else -// declare *just* the Security APIs we need to check for entitlments on iOS -typedef CFTypeRef SecTaskRef; -extern SecTaskRef SecTaskCreateFromSelf(CFAllocatorRef allocator); -extern CFTypeRef SecTaskCopyValueForEntitlement(SecTaskRef task, CFStringRef entitlement, CFErrorRef *error); -#endif - #define DebugLog 1 #if DebugLog == 0 || !defined(DEBUG) #define NSLog(...) (void)0 @@ -71,23 +62,17 @@ +(NSString*)cloudIdentifier { return [NSString stringWithFormat:@"iCloud.%@", NSBundle.mainBundle.bundleIdentifier]; } -// use the Security framework to see if we have the iCloud entitlement +(BOOL)isEntitled { - SecTaskRef task = SecTaskCreateFromSelf(NULL); - if (task == NULL) - return FALSE; - CFTypeRef val = SecTaskCopyValueForEntitlement(task, CFSTR("com.apple.developer.icloud-services"), NULL); - CFRelease(task); - if (val == NULL) - return FALSE; - CFRelease(val); +#if ENTITLEMENTS_TYPE == -Full return TRUE; +#else + return FALSE; +#endif } +(void)updateCloudStatus { if (_container == nil) { - if ([self isEntitled]) { @try { // **NOTE** CKContainer.defaultContainer will throw a uncatchable exception, dont use it. diff --git a/xcode/MAME4iOS/MAME4iOS.xcconfig b/xcode/MAME4iOS/MAME4iOS.xcconfig index 9a5abdd2..0d4341dd 100644 --- a/xcode/MAME4iOS/MAME4iOS.xcconfig +++ b/xcode/MAME4iOS/MAME4iOS.xcconfig @@ -15,10 +15,10 @@ // you can also set the Development Team via the drop down in the Xcode project editor, for each Target. // you can find your TeamID [here](https://developer.apple.com/account/#/membership) -ORG_IDENTIFIER = com.yoshisuga // CHANGE this to your Organization Identifier. +ORG_IDENTIFIER = com.example // CHANGE this to your Organization Identifier. DEVELOPMENT_TEAM = ABC8675309 // CHANGE this to your Team ID. (or select in Xcode project editor) -CURRENT_PROJECT_VERSION = 2022.5 -MARKETING_VERSION = 2022.5 +CURRENT_PROJECT_VERSION = 2024.1 +MARKETING_VERSION = 2024.1 // 2. enable or disable entitlements // tvOS TopShelf and iCloud import/export require special app entitlements @@ -36,6 +36,9 @@ MAMELIB = libmame-139u1 // USE THIS LINE for a build of current latest MAME (via get-libmame.sh) // MAMELIB = libmame +// AppStore build +TARGET_APPSTORE = 0 // 1=AppStore build, 0=not + // let developer override with optional file. #include? "Developer.xcconfig" @@ -54,3 +57,8 @@ MAMELIB_TVOS[sdk=appletvsimulator*] = $(MAMELIB)-tvos-simulator.a PRODUCT_BUNDLE_NAME = $(TARGET_NAME) PRODUCT_BUNDLE_NAME[sdk=macosx*] = MAME4mac + +// set special #defines +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) TARGET_APPSTORE=$(TARGET_APPSTORE) +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) ENTITLEMENTS_TYPE=$(ENTITLEMENTS_TYPE) + diff --git a/xcode/MAME4iOS/MAME4iOS.xcodeproj/project.pbxproj b/xcode/MAME4iOS/MAME4iOS.xcodeproj/project.pbxproj index 4fc7bb4d..4900e2cd 100644 --- a/xcode/MAME4iOS/MAME4iOS.xcodeproj/project.pbxproj +++ b/xcode/MAME4iOS/MAME4iOS.xcodeproj/project.pbxproj @@ -128,6 +128,7 @@ EF29C8822401C73A00AFFA4E /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EF29C8802401C73900AFFA4E /* Launch Screen.storyboard */; }; EF301CF3240460F3000510FD /* ZipFile.m in Sources */ = {isa = PBXBuildFile; fileRef = EF27F36323F73CD400B1E50A /* ZipFile.m */; }; EF31447C27BB1E81002C3C6A /* ControllerButtonPress.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF31447B27BB1E81002C3C6A /* ControllerButtonPress.swift */; }; + EF3D60262BF6B0870028C7C4 /* CloudSync.m in Sources */ = {isa = PBXBuildFile; fileRef = EF286D33253CA930007DA6D3 /* CloudSync.m */; }; EF474B892791E42900578663 /* EmulatorController+EmulatorKeyboardSupport.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF474B882791E42900578663 /* EmulatorController+EmulatorKeyboardSupport.swift */; }; EF474B8B2791E4CD00578663 /* EmulatorKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = EF474B8A2791E4CD00578663 /* EmulatorKeyboard.swift */; }; EF490D91277A5C8C00407865 /* history.dat.zip in Resources */ = {isa = PBXBuildFile; fileRef = EF490D90277A5C8C00407865 /* history.dat.zip */; }; @@ -163,14 +164,6 @@ EF8E4284249915F30049C84C /* lineTron.metal in Sources */ = {isa = PBXBuildFile; fileRef = EF8E4282249915F20049C84C /* lineTron.metal */; }; EF8E428B249FE5410049C84C /* ulTron.metal in Sources */ = {isa = PBXBuildFile; fileRef = EF8E428A249FE5410049C84C /* ulTron.metal */; }; EF8E428C249FE5410049C84C /* ulTron.metal in Sources */ = {isa = PBXBuildFile; fileRef = EF8E428A249FE5410049C84C /* ulTron.metal */; }; - EF8EAA86244F7F5D00DA02BB /* SteamControllerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA7F244F7F5D00DA02BB /* SteamControllerManager.m */; }; - EF8EAA87244F7F5D00DA02BB /* SteamControllerManager.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA7F244F7F5D00DA02BB /* SteamControllerManager.m */; }; - EF8EAA88244F7F5D00DA02BB /* SteamController.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA80244F7F5D00DA02BB /* SteamController.m */; }; - EF8EAA89244F7F5D00DA02BB /* SteamController.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA80244F7F5D00DA02BB /* SteamController.m */; }; - EF8EAA8A244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA82244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m */; }; - EF8EAA8B244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA82244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m */; }; - EF8EAA8C244F7F5D00DA02BB /* SteamControllerInput.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA83244F7F5D00DA02BB /* SteamControllerInput.m */; }; - EF8EAA8D244F7F5D00DA02BB /* SteamControllerInput.m in Sources */ = {isa = PBXBuildFile; fileRef = EF8EAA83244F7F5D00DA02BB /* SteamControllerInput.m */; }; EF926C9B24BA36980048392B /* SkinManager.m in Sources */ = {isa = PBXBuildFile; fileRef = EF926C9A24BA36980048392B /* SkinManager.m */; }; EF941F0024427D1200D58F7F /* OptionsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EF941EFF24427D1200D58F7F /* OptionsTableViewController.m */; }; EF941F0124427D1200D58F7F /* OptionsTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = EF941EFF24427D1200D58F7F /* OptionsTableViewController.m */; }; @@ -294,7 +287,7 @@ 920BBDED201FC29700AE7D50 /* dpad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = dpad.png; path = "../../iOS-res/dpad.png"; sourceTree = ""; }; 920BBDF020210C3700AE7D50 /* menu.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = menu.png; path = "../../iOS-res/menu.png"; sourceTree = ""; }; 920D97592BCECB410038F00B /* UICollectionView+ZeroState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UICollectionView+ZeroState.swift"; sourceTree = ""; }; - 925ABCE21E46DCC500997182 /* MAME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MAME.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 925ABCE21E46DCC500997182 /* MAME4iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MAME4iOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; 925ABCE41E46DD6E00997182 /* libmame.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmame.a; path = ../../libmame.a; sourceTree = ""; }; 926C76FD21F1C87700103EDE /* TVOptionsController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TVOptionsController.h; sourceTree = ""; }; 926C76FE21F1C87700103EDE /* TVOptionsController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TVOptionsController.m; sourceTree = ""; }; @@ -452,16 +445,6 @@ EF8E427C249348220049C84C /* megaTron.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = megaTron.metal; sourceTree = ""; }; EF8E4282249915F20049C84C /* lineTron.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = lineTron.metal; sourceTree = ""; }; EF8E428A249FE5410049C84C /* ulTron.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; path = ulTron.metal; sourceTree = ""; }; - EF8EAA7E244F7F5D00DA02BB /* SteamControllerExtendedGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SteamControllerExtendedGamepad.h; sourceTree = ""; }; - EF8EAA7F244F7F5D00DA02BB /* SteamControllerManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SteamControllerManager.m; sourceTree = ""; }; - EF8EAA80244F7F5D00DA02BB /* SteamController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SteamController.m; sourceTree = ""; }; - EF8EAA81244F7F5D00DA02BB /* SteamControllerInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SteamControllerInput.h; sourceTree = ""; }; - EF8EAA82244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SteamControllerExtendedGamepad.m; sourceTree = ""; }; - EF8EAA83244F7F5D00DA02BB /* SteamControllerInput.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SteamControllerInput.m; sourceTree = ""; }; - EF8EAA84244F7F5D00DA02BB /* SteamController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SteamController.h; sourceTree = ""; }; - EF8EAA85244F7F5D00DA02BB /* SteamControllerManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SteamControllerManager.h; sourceTree = ""; }; - EF8EAA8E244F822C00DA02BB /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; - EF8EAA8F244F822C00DA02BB /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; EF926C9924BA36980048392B /* SkinManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SkinManager.h; sourceTree = ""; }; EF926C9A24BA36980048392B /* SkinManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SkinManager.m; sourceTree = ""; }; EF941EFE24427D1200D58F7F /* OptionsTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OptionsTableViewController.h; path = ../../iOS/OptionsTableViewController.h; sourceTree = ""; }; @@ -747,7 +730,6 @@ EF8E427B24900FE40049C84C /* UIKit Classes */, 92A5338421EBDBAD0089FBB9 /* GCDWebServer */, 92A533CB21EBDDF20089FBB9 /* GCDWebUploader */, - EF8EAA7D244F7F5D00DA02BB /* SteamController */, CEE6808F1635BA7000051BC2 /* MAME4iOS */, 92ECB8EC21EA984E00D1E3D0 /* MAME4tvOS */, EFEEA4B325C9D41E00314132 /* TopShelf */, @@ -761,7 +743,7 @@ CEE680861635BA7000051BC2 /* Products */ = { isa = PBXGroup; children = ( - 925ABCE21E46DCC500997182 /* MAME.app */, + 925ABCE21E46DCC500997182 /* MAME4iOS.app */, 92ECB8EB21EA984D00D1E3D0 /* MAME4tvOS.app */, EFEEA4B125C9D41E00314132 /* TopShelf.appex */, ); @@ -936,23 +918,6 @@ name = "UIKit Classes"; sourceTree = ""; }; - EF8EAA7D244F7F5D00DA02BB /* SteamController */ = { - isa = PBXGroup; - children = ( - EF8EAA8E244F822C00DA02BB /* README.md */, - EF8EAA8F244F822C00DA02BB /* LICENSE */, - EF8EAA7E244F7F5D00DA02BB /* SteamControllerExtendedGamepad.h */, - EF8EAA7F244F7F5D00DA02BB /* SteamControllerManager.m */, - EF8EAA80244F7F5D00DA02BB /* SteamController.m */, - EF8EAA81244F7F5D00DA02BB /* SteamControllerInput.h */, - EF8EAA82244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m */, - EF8EAA83244F7F5D00DA02BB /* SteamControllerInput.m */, - EF8EAA84244F7F5D00DA02BB /* SteamController.h */, - EF8EAA85244F7F5D00DA02BB /* SteamControllerManager.h */, - ); - path = SteamController; - sourceTree = ""; - }; EFA7571E2408308000A02AAB /* help */ = { isa = PBXGroup; children = ( @@ -992,9 +957,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 925ABCA41E46DCC500997182 /* MAME */ = { + 925ABCA41E46DCC500997182 /* MAME4iOS */ = { isa = PBXNativeTarget; - buildConfigurationList = 925ABCDF1E46DCC500997182 /* Build configuration list for PBXNativeTarget "MAME" */; + buildConfigurationList = 925ABCDF1E46DCC500997182 /* Build configuration list for PBXNativeTarget "MAME4iOS" */; buildPhases = ( EF79BDD924B7D71800824BFD /* ShellScript */, 925ABCA51E46DCC500997182 /* Sources */, @@ -1008,9 +973,9 @@ ); dependencies = ( ); - name = MAME; + name = MAME4iOS; productName = MAME4iOS; - productReference = 925ABCE21E46DCC500997182 /* MAME.app */; + productReference = 925ABCE21E46DCC500997182 /* MAME4iOS.app */; productType = "com.apple.product-type.application"; }; 92ECB8EA21EA984D00D1E3D0 /* MAME4tvOS */ = { @@ -1092,7 +1057,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 925ABCA41E46DCC500997182 /* MAME */, + 925ABCA41E46DCC500997182 /* MAME4iOS */, 92ECB8EA21EA984D00D1E3D0 /* MAME4tvOS */, EFEEA4B025C9D41E00314132 /* TopShelf */, ); @@ -1215,6 +1180,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + EF3D60262BF6B0870028C7C4 /* CloudSync.m in Sources */, 92A533B121EBDBAD0089FBB9 /* GCDWebServerConnection.m in Sources */, EFB7B2192479FBD900AD96A4 /* MetalViewShaders.metal in Sources */, 925ABCA61E46DCC500997182 /* KeyboardView.m in Sources */, @@ -1234,8 +1200,6 @@ EFB7B21C247ACFE300AD96A4 /* MameShaders.metal in Sources */, 925ABCA91E46DCC500997182 /* OptionsController.m in Sources */, EFE003382638ACA000E42246 /* XmlFile.m in Sources */, - EF8EAA8A244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m in Sources */, - EF8EAA8C244F7F5D00DA02BB /* SteamControllerInput.m in Sources */, 92A533C021EBDBAD0089FBB9 /* GCDWebServerURLEncodedFormRequest.m in Sources */, 92A533D821EE601D0089FBB9 /* WebServer.m in Sources */, EFB3C6D624890F6200F44780 /* simpleCRT.metal in Sources */, @@ -1257,7 +1221,6 @@ EFB7B2172479FBD900AD96A4 /* MetalView.m in Sources */, 925ABCB21E46DCC500997182 /* LayoutView.m in Sources */, EFEEA4ED25CC8A2F00314132 /* MacMenu.m in Sources */, - EF8EAA86244F7F5D00DA02BB /* SteamControllerManager.m in Sources */, 92A533A521EBDBAD0089FBB9 /* GCDWebServerResponse.m in Sources */, EFE4B6AB2453D7F80009A6F1 /* InfoDatabase.m in Sources */, 925ABCB61E46DCC500997182 /* InputOptionController.m in Sources */, @@ -1272,7 +1235,6 @@ EFF9F82A2470755800DDA88C /* MetalScreenView.m in Sources */, EF19F22C235D1BDF00C8EE7F /* ChooseGameController.m in Sources */, EF926C9B24BA36980048392B /* SkinManager.m in Sources */, - EF8EAA88244F7F5D00DA02BB /* SteamController.m in Sources */, 92A533AE21EBDBAD0089FBB9 /* GCDWebServer.m in Sources */, EF51444A282C5C68001457B1 /* GameInfo.swift in Sources */, 92A5332321EB57F00089FBB9 /* Options.m in Sources */, @@ -1298,7 +1260,6 @@ EF8E427E249348220049C84C /* megaTron.metal in Sources */, 92A5332621EBC8D00089FBB9 /* Bootstrapper.m in Sources */, 92A533A921EBDBAD0089FBB9 /* GCDWebServerRequest.m in Sources */, - EF8EAA8B244F7F5D00DA02BB /* SteamControllerExtendedGamepad.m in Sources */, EFF9F82B2470755800DDA88C /* MetalScreenView.m in Sources */, EF51444F28305E36001457B1 /* GameInfoCell.swift in Sources */, 92A533B221EBDBAD0089FBB9 /* GCDWebServerConnection.m in Sources */, @@ -1307,21 +1268,18 @@ 92ECB91921EAD57900D1E3D0 /* UIView+Toast.m in Sources */, EF19F22D235D1BDF00C8EE7F /* ChooseGameController.m in Sources */, 928F7B2E27F0223100377C40 /* CommandLineArgsHelper.swift in Sources */, - EF8EAA89244F7F5D00DA02BB /* SteamController.m in Sources */, 92A533A621EBDBAD0089FBB9 /* GCDWebServerResponse.m in Sources */, 92A533D921EE601D0089FBB9 /* WebServer.m in Sources */, EFE0033E2638D97E00E42246 /* SoftwareList.m in Sources */, EFB7B21D247ACFE300AD96A4 /* MameShaders.metal in Sources */, 92A533D421EBDDF20089FBB9 /* GCDWebUploader.m in Sources */, 92ECB91221EAA1B700D1E3D0 /* EmulatorController.m in Sources */, - EF8EAA87244F7F5D00DA02BB /* SteamControllerManager.m in Sources */, EF514448282815E4001457B1 /* GameInfoController.swift in Sources */, EF24BAFD24C786A900D9C55A /* SkinManager.m in Sources */, 92A533AC21EBDBAD0089FBB9 /* GCDWebServerFunctions.m in Sources */, EF51444B282C5C68001457B1 /* GameInfo.swift in Sources */, EF7B232D23FD0469001FF51D /* (null) in Sources */, 92A533AF21EBDBAD0089FBB9 /* GCDWebServer.m in Sources */, - EF8EAA8D244F7F5D00DA02BB /* SteamControllerInput.m in Sources */, 92A533B521EBDBAD0089FBB9 /* GCDWebServerErrorResponse.m in Sources */, EFE003392638ACA000E42246 /* XmlFile.m in Sources */, EFE4B6AC2453D7F80009A6F1 /* InfoDatabase.m in Sources */, @@ -1367,7 +1325,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = "MAME4iOS/MAME4iOS$(ENTITLEMENTS_TYPE).entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; ENABLE_BITCODE = NO; @@ -1379,8 +1336,7 @@ ); HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "MAME4iOS/MAME4iOS-Info.plist"; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games"; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1411,7 +1367,6 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; - CODE_SIGN_ENTITLEMENTS = "MAME4iOS/MAME4iOS$(ENTITLEMENTS_TYPE).entitlements"; CODE_SIGN_IDENTITY = "iPhone Developer"; CODE_SIGN_STYLE = Automatic; ENABLE_BITCODE = NO; @@ -1419,8 +1374,7 @@ GCC_PREFIX_HEADER = "MAME4iOS/MAME4iOS-Prefix.pch"; HEADER_SEARCH_PATHS = ""; INFOPLIST_FILE = "MAME4iOS/MAME4iOS-Info.plist"; - INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.games"; - IPHONEOS_DEPLOYMENT_TARGET = 13.4; + IPHONEOS_DEPLOYMENT_TARGET = 15.6; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -1507,7 +1461,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 13.4; + TVOS_DEPLOYMENT_TARGET = 15.6; VALID_ARCHS = "$(ARCHS_STANDARD_64_BIT)"; }; name = Debug; @@ -1576,7 +1530,7 @@ SWIFT_OBJC_INTERFACE_HEADER_NAME = "$(PROJECT_NAME)-Swift.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 13.4; + TVOS_DEPLOYMENT_TARGET = 15.6; VALID_ARCHS = "$(ARCHS_STANDARD_64_BIT)"; }; name = Release; @@ -1631,7 +1585,6 @@ MTL_FAST_MATH = YES; MTL_LANGUAGE_REVISION = UseDeploymentTarget; ONLY_ACTIVE_ARCH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "$(ORG_IDENTIFIER).mame"; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; @@ -1682,7 +1635,6 @@ MTL_LANGUAGE_REVISION = UseDeploymentTarget; ONLY_ACTIVE_ARCH = NO; OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; - PRODUCT_BUNDLE_IDENTIFIER = "$(ORG_IDENTIFIER).mame"; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; TARGETED_DEVICE_FAMILY = "1,2"; @@ -1724,7 +1676,7 @@ SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 13.4; + TVOS_DEPLOYMENT_TARGET = 15.6; }; name = Debug; }; @@ -1761,14 +1713,14 @@ SKIP_INSTALL = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = 3; - TVOS_DEPLOYMENT_TARGET = 13.4; + TVOS_DEPLOYMENT_TARGET = 15.6; }; name = Release; }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 925ABCDF1E46DCC500997182 /* Build configuration list for PBXNativeTarget "MAME" */ = { + 925ABCDF1E46DCC500997182 /* Build configuration list for PBXNativeTarget "MAME4iOS" */ = { isa = XCConfigurationList; buildConfigurations = ( 925ABCE01E46DCC500997182 /* Debug */, diff --git a/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Debug.xcscheme b/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Debug.xcscheme index 23721916..2201ef8c 100644 --- a/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Debug.xcscheme +++ b/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Debug.xcscheme @@ -15,8 +15,8 @@ @@ -45,8 +45,8 @@ @@ -62,8 +62,8 @@ diff --git a/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Release.xcscheme b/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Release.xcscheme index 3403a155..b4abdbae 100644 --- a/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Release.xcscheme +++ b/xcode/MAME4iOS/MAME4iOS.xcodeproj/xcshareddata/xcschemes/MAME4iOS Release.xcscheme @@ -1,7 +1,7 @@ + version = "1.3"> @@ -15,8 +15,8 @@ @@ -49,8 +49,8 @@ @@ -66,8 +66,8 @@ diff --git a/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Base.entitlements b/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Base.entitlements index 083d24e5..2861597d 100644 --- a/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Base.entitlements +++ b/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Base.entitlements @@ -2,17 +2,15 @@ - com.apple.security.app-sandbox - - com.apple.security.device.bluetooth - - com.apple.security.files.downloads.read-only - - com.apple.security.files.user-selected.read-write - - com.apple.security.network.client - - com.apple.security.network.server - + com.apple.security.app-sandbox + + com.apple.security.files.downloads.read-only + + com.apple.security.files.user-selected.read-write + + com.apple.security.network.client + + com.apple.security.network.server + diff --git a/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Full.entitlements b/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Full.entitlements index 0e39f992..4da8a03f 100644 --- a/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Full.entitlements +++ b/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Full.entitlements @@ -16,9 +16,7 @@ $(APP_GROUP_IDENTIFIER) - com.apple.security.app-sandbox - - com.apple.security.device.bluetooth + com.apple.security.app-sandbox com.apple.security.files.downloads.read-only diff --git a/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Info.plist b/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Info.plist index eda71c17..e56cde7c 100644 --- a/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Info.plist +++ b/xcode/MAME4iOS/MAME4iOS/MAME4iOS-Info.plist @@ -31,220 +31,220 @@ public.zip-archive - - CFBundleTypeExtensions - - 7z - 7Z - - CFBundleTypeMIMETypes - - application/x-7z-compressed - - CFBundleTypeName - 7-Zip Archive - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - org.7-zip.7-zip-archive - - - - CFBundleTypeName - MAME Disk Image - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - org.mamedev.disk-image - - CFBundleTypeExtensions - - chd - - - - CFBundleTypeName - MAME ROM Image - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - org.mamedev.rom-image - - CFBundleTypeExtensions - - ROM - rom - cue - iso - cdr - bin - a78 - a26 - a52 - sms - smc - fig - sfc - gb - gbc - sgb - gba - nes - fds - lnx - ngp - ngc - ngpc - npc - pce - ws - wsc - vb - n64 - z64 - v64 - gen - md - gg - smd - 32x - 32X - min - cdi - gdi - bios - d64 - t64 - p00 - prg - pgm - crt - dsk - woz - wav - col - unf - unif - - + + CFBundleTypeExtensions + + 7z + 7Z + + CFBundleTypeMIMETypes + + application/x-7z-compressed + + CFBundleTypeName + 7-Zip Archive + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + org.7-zip.7-zip-archive + + + + CFBundleTypeName + MAME Disk Image + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + org.mamedev.disk-image + + CFBundleTypeExtensions + + chd + + + + CFBundleTypeName + MAME ROM Image + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + org.mamedev.rom-image + + CFBundleTypeExtensions + + ROM + rom + cue + iso + cdr + bin + a78 + a26 + a52 + sms + smc + fig + sfc + gb + gbc + sgb + gba + nes + fds + lnx + ngp + ngc + ngpc + npc + pce + ws + wsc + vb + n64 + z64 + v64 + gen + md + gg + smd + 32x + 32X + min + cdi + gdi + bios + d64 + t64 + p00 + prg + pgm + crt + dsk + woz + wav + col + unf + unif + + + + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + MAME Disk Image + UTTypeIdentifier + org.mamedev.disk-image + UTTypeTagSpecification + + public.filename-extension + + chd + + + + + UTTypeConformsTo + + public.data + + UTTypeDescription + 7-Zip Archive + UTTypeIdentifier + org.7-zip.7-zip-archive + UTTypeTagSpecification + + public.filename-extension + + 7z + 7Z + + + + + UTTypeConformsTo + + public.data + + UTTypeDescription + MAME ROM Image + UTTypeIdentifier + org.mamedev.rom-image + UTTypeTagSpecification + + public.filename-extension + + ROM + rom + cue + iso + cdr + bin + a78 + a26 + a52 + sms + smc + fig + sfc + gb + gbc + sgb + gba + nes + fds + lnx + ngp + ngc + ngpc + npc + pce + ws + wsc + vb + n64 + z64 + v64 + gen + md + gg + smd + 32x + 32X + min + cdi + gdi + bios + d64 + t64 + p00 + prg + pgm + crt + dsk + woz + wav + col + unf + unif + + + - UTImportedTypeDeclarations - - - UTTypeConformsTo - - public.data - - UTTypeDescription - MAME Disk Image - UTTypeIdentifier - org.mamedev.disk-image - UTTypeTagSpecification - - public.filename-extension - - chd - - - - - UTTypeConformsTo - - public.data - - UTTypeDescription - 7-Zip Archive - UTTypeIdentifier - org.7-zip.7-zip-archive - UTTypeTagSpecification - - public.filename-extension - - 7z - 7Z - - - - - UTTypeConformsTo - - public.data - - UTTypeDescription - MAME ROM Image - UTTypeIdentifier - org.mamedev.rom-image - UTTypeTagSpecification - - public.filename-extension - - ROM - rom - cue - iso - cdr - bin - a78 - a26 - a52 - sms - smc - fig - sfc - gb - gbc - sgb - gba - nes - fds - lnx - ngp - ngc - ngpc - npc - pce - ws - wsc - vb - n64 - z64 - v64 - gen - md - gg - smd - 32x - 32X - min - cdi - gdi - bios - d64 - t64 - p00 - prg - pgm - crt - dsk - woz - wav - col - unf - unif - - - - - CFBundleExecutable + CFBundleExecutable ${EXECUTABLE_NAME} CFBundleIdentifier $(PRODUCT_BUNDLE_IDENTIFIER) @@ -284,8 +284,8 @@ GCSupportsControllerUserInteraction - LSApplicationCategoryType - public.app-category.arcade-games + LSApplicationCategoryType + public.app-category.arcade-games LSRequiresIPhoneOS LSSupportsOpeningDocumentsInPlace @@ -295,8 +295,6 @@ NSAllowsArbitraryLoads - NSBluetoothAlwaysUsageDescription - We need bluetooth for steam controllers NSUserActivityTypes $(PRODUCT_BUNDLE_IDENTIFIER).play @@ -335,7 +333,7 @@ UIApplicationSupportsIndirectInputEvents - UIUserInterfaceStyle - Dark + UIUserInterfaceStyle + Dark diff --git a/xcode/MAME4iOS/MAME4tvOS/Info.plist b/xcode/MAME4iOS/MAME4tvOS/Info.plist index bdded244..fa400b53 100644 --- a/xcode/MAME4iOS/MAME4tvOS/Info.plist +++ b/xcode/MAME4iOS/MAME4tvOS/Info.plist @@ -44,8 +44,8 @@ GCSupportsControllerUserInteraction - LSApplicationCategoryType - public.app-category.arcade-games + LSApplicationCategoryType + public.app-category.arcade-games LSRequiresIPhoneOS LSSupportsOpeningDocumentsInPlace @@ -55,8 +55,6 @@ NSAllowsArbitraryLoads - NSBluetoothAlwaysUsageDescription - We need bluetooth for steam controllers UIFileSharingEnabled UILaunchStoryboardName @@ -67,241 +65,241 @@ UIUserInterfaceStyle Dark - CFBundleDocumentTypes - - - CFBundleTypeExtensions - - zip - ZIP - - CFBundleTypeMIMETypes - - application/zip - - CFBundleTypeName - ZIP Archive - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - public.zip-archive - - - - CFBundleTypeExtensions - - 7z - 7Z - - CFBundleTypeMIMETypes - - application/x-7z-compressed - - CFBundleTypeName - 7-Zip Archive - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - org.7-zip.7-zip-archive - - - - CFBundleTypeName - MAME Disk Image - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - org.mamedev.disk-image - - CFBundleTypeExtensions - - chd - - - - CFBundleTypeName - MAME ROM Image - CFBundleTypeRole - Viewer - LSHandlerRank - Alternate - LSItemContentTypes - - org.mamedev.rom-image - - CFBundleTypeExtensions - - ROM - rom - cue - iso - cdr - bin - a78 - a26 - a52 - sms - smc - fig - sfc - gb - gbc - sgb - gba - nes - fds - lnx - ngp - ngc - ngpc - npc - pce - ws - wsc - vb - n64 - z64 - v64 - gen - md - gg - smd - 32x - 32X - min - cdi - gdi - bios - d64 - t64 - p00 - prg - pgm - crt - dsk - woz - wav - col - unf - unif - - - - UTImportedTypeDeclarations - - - UTTypeConformsTo - - public.data - - UTTypeDescription - MAME Disk Image - UTTypeIdentifier - org.mamedev.disk-image - UTTypeTagSpecification - - public.filename-extension - - chd - - - - - UTTypeConformsTo - - public.data - - UTTypeDescription - 7-Zip Archive - UTTypeIdentifier - org.7-zip.7-zip-archive - UTTypeTagSpecification - - public.filename-extension - - 7z - 7Z - - - - - UTTypeConformsTo - - public.data - - UTTypeDescription - MAME ROM Image - UTTypeIdentifier - org.mamedev.rom-image - UTTypeTagSpecification - - public.filename-extension - - ROM - rom - cue - iso - cdr - bin - a78 - a26 - a52 - sms - smc - fig - sfc - gb - gbc - sgb - gba - nes - fds - lnx - ngp - ngc - ngpc - npc - pce - ws - wsc - vb - n64 - z64 - v64 - gen - md - gg - smd - 32x - 32X - min - cdi - gdi - bios - d64 - t64 - p00 - prg - pgm - crt - dsk - woz - wav - col - unf - unif - - - - + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + zip + ZIP + + CFBundleTypeMIMETypes + + application/zip + + CFBundleTypeName + ZIP Archive + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + public.zip-archive + + + + CFBundleTypeExtensions + + 7z + 7Z + + CFBundleTypeMIMETypes + + application/x-7z-compressed + + CFBundleTypeName + 7-Zip Archive + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + org.7-zip.7-zip-archive + + + + CFBundleTypeName + MAME Disk Image + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + org.mamedev.disk-image + + CFBundleTypeExtensions + + chd + + + + CFBundleTypeName + MAME ROM Image + CFBundleTypeRole + Viewer + LSHandlerRank + Alternate + LSItemContentTypes + + org.mamedev.rom-image + + CFBundleTypeExtensions + + ROM + rom + cue + iso + cdr + bin + a78 + a26 + a52 + sms + smc + fig + sfc + gb + gbc + sgb + gba + nes + fds + lnx + ngp + ngc + ngpc + npc + pce + ws + wsc + vb + n64 + z64 + v64 + gen + md + gg + smd + 32x + 32X + min + cdi + gdi + bios + d64 + t64 + p00 + prg + pgm + crt + dsk + woz + wav + col + unf + unif + + + + UTImportedTypeDeclarations + + + UTTypeConformsTo + + public.data + + UTTypeDescription + MAME Disk Image + UTTypeIdentifier + org.mamedev.disk-image + UTTypeTagSpecification + + public.filename-extension + + chd + + + + + UTTypeConformsTo + + public.data + + UTTypeDescription + 7-Zip Archive + UTTypeIdentifier + org.7-zip.7-zip-archive + UTTypeTagSpecification + + public.filename-extension + + 7z + 7Z + + + + + UTTypeConformsTo + + public.data + + UTTypeDescription + MAME ROM Image + UTTypeIdentifier + org.mamedev.rom-image + UTTypeTagSpecification + + public.filename-extension + + ROM + rom + cue + iso + cdr + bin + a78 + a26 + a52 + sms + smc + fig + sfc + gb + gbc + sgb + gba + nes + fds + lnx + ngp + ngc + ngpc + npc + pce + ws + wsc + vb + n64 + z64 + v64 + gen + md + gg + smd + 32x + 32X + min + cdi + gdi + bios + d64 + t64 + p00 + prg + pgm + crt + dsk + woz + wav + col + unf + unif + + + + diff --git a/xcode/MAME4iOS/SteamController/LICENSE b/xcode/MAME4iOS/SteamController/LICENSE deleted file mode 100644 index 93ba7707..00000000 --- a/xcode/MAME4iOS/SteamController/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2018 Jesús A. Álvarez - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/xcode/MAME4iOS/SteamController/README.md b/xcode/MAME4iOS/SteamController/README.md deleted file mode 100644 index 7e3b3896..00000000 --- a/xcode/MAME4iOS/SteamController/README.md +++ /dev/null @@ -1,106 +0,0 @@ -# SteamController - -Drop-in support for Steam Controllers for iOS and tvOS. - -For information about how to use a Steam Controller in Bluetoth LE mode, see [Steam Controller BLE](https://support.steampowered.com/kb_article.php?ref=7728-QESJ-4420#switch). - -forked from [here](https://github.com/zydeco/SteamController) - -## Example - -To run the example project, clone the repo, and run the SteamControllerTestApp target. - -![Screenshot](screenshot.png) - -In the example app, power on your controller (in BLE or BLE pairing mode) and press Scan. Connected controllers will appear in the list, and the UI will reflect the state of the controller. Tapping on a controller from the list will open the settings view for that controller, where you can also see the battery level, and change its configuration (seen above). - -## Requirements - -- iOS 12 or later (not tested on earlier versions). -- Steam Controller with [BLE firmware](https://support.steampowered.com/kb_article.php?ref=7728-QESJ-4420#switch). -- A game supporting MFi controllers using the `GameController` framework. -- Starting on iOS 13, your app's Info.plist needs a `NSBluetoothAlwaysUsageDescription` key with a description of how it uses bluetooth. - -## Installation - -### CocoaPods - -[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: - -```bash -$ gem install cocoapods -``` -To integrate SteamController into your Xcode project using CocoaPods, specify it in your `Podfile`: - -```ruby -pod 'SteamController' -``` - -Then, run the following command: - -```bash -$ pod install -``` - -### Carthage - -[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. - -You can install Carthage with [Homebrew](http://brew.sh/) using the following command: - -```bash -$ brew update -$ brew install carthage -``` - -To integrate SteamController into your Xcode project using Carthage, specify it in your `Cartfile`: - -```ogdl -github "zydeco/SteamController" -``` - -Run `carthage update` to build the framework and drag the built `SteamController.framework` into your Xcode project. - -## Usage - -Everything should work like with MFi controllers. Depending on how your game works, you might not need any changes at all. - -- `#import `. -- To listen for steam controllers, either: - - Call `[SteamControllerManager listenForConnections]` when your app starts (uses private IOKit API). - - Call `[[SteamControllerManager sharedManager] scanForControllers]` when you want to scan for controllers. -- The framework will post `GCControllerDidConnectNotification` and `GCControllerDidDisconnectNotification`, as with native controllers. -- Connected Steam Controllers will be returned in `[GCController controllers]`. -- Steam Controllers are a subclass of `GCController` (`SteamController`) that implements the `extendedGamepad` profile. -- Core buttons are mapped to Apple's MFi Extended Gamepad Profile. -- Trackpads and stick can be mapped to D-pad and thumbsticks. (see below) -- Trackpads can be set to require click for input (default), or not. - -#### Button Mapping -- Analog Stick: L-Thumbstick -- Left Trackpad: D-Pad *(Requires Click)* -- Right Trackpad: R-Thumbstick / C-Buttons *(Requires Click)* -- A, B, X, Y: Equivalent -- Bumpers/Shoulders: L1 / R1 -- Triggers: L2 / R2 -- Grip buttons: L3 / R3 -- Steam Button: Pause handler and combinations via `steamButtonCombinationHandler` -- Analog Stick click: L3 *(Default)* -- Trackpad clicks: L3 / R3 (when click is not required for input) -- Back: Options button -- Forward: Menu button - -##### Alternate mapping for backward compatibility: -Since options and menu buttons were added in iOS 13, back and forward are also added as a class extension to `GCExtendedGamepad`. -- Back: `steamBackButton` -- Forward: `steamForwardButton` - -#### Controller Configuration - -The `SteamController` class has some additional properties to customise its configuration. -See the [documentation](https://namedfork.net/SteamController/Classes/SteamController.html) for more info. -These are available as GUI options in the example app. - -## License - -The SteamController framework is available under the MIT license. See the LICENSE file for more info. diff --git a/xcode/MAME4iOS/SteamController/SteamController.h b/xcode/MAME4iOS/SteamController/SteamController.h deleted file mode 100644 index 71b2d5ac..00000000 --- a/xcode/MAME4iOS/SteamController/SteamController.h +++ /dev/null @@ -1,204 +0,0 @@ -// -// SteamController.h -// SteamController -// -// Created by Jesús A. Álvarez on 20/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import -#import "SteamControllerManager.h" - -@class CBPeripheral; - -/** Represents the mapping of a Steam Controller's trackpad or stick to a GCController thumbstick or directional pad. */ -typedef NS_ENUM(NSUInteger, SteamControllerMapping) { - /// Not mapped to anything. - SteamControllerMappingNone, - /// Mapped to the left thumbstick. - SteamControllerMappingLeftThumbstick, - /// Mapped to the right thumbstick. - SteamControllerMappingRightThumbstick, - /// Mapped to the directional pad. - SteamControllerMappingDPad -}; - -/** Represents a Steam Controller's behaviour. This allows changing between Game Controller emulation (the default), - and keyboard/mouse. - - In Keyboard/Mouse mode, the controls are mapped to the following keys: - * **Left trackpad**: arrows - * **Analog stick**: arrows - * **Analog stick button**: F4 - * **A**: return - * **B**: escape - * **Back**: tab - * **Forward**: escape - * **Left grip**: F7 - * **Right grip**: F9 - * **Left bumper**: space - * **Right bumper**: F9 - - Other controls are not mapped to keys. */ -typedef NS_ENUM(NSUInteger, SteamControllerMode) { - /// The controller behaves as an MFi Game Controller. - SteamControllerModeGameController, - /// The controller behaves as a keyboard and mouse. - SteamControllerModeKeyboardAndMouse -}; - -/** Represents a physical push button input (or combination thereof) from the Steam Controller. - - The values of this enumeration are the same ones used by the controller's bluetooth protocol. - */ -typedef NS_OPTIONS(uint32_t, SteamControllerButton) { - /// The button on the right underside of the controller. - SteamControllerButtonRightGrip = 0x000001, - /// Press on the left trackpad. - SteamControllerButtonLeftTrackpadClick = 0x000002, - /// Press on the right trackpad. - SteamControllerButtonRightTrackpadClick = 0x000004, - /// Touch on the left trackpad. - SteamControllerButtonLeftTrackpadTouch = 0x000008, - /// Touch on the left trackpad. - SteamControllerButtonRightTrackpadTouch = 0x000010, - /// Press on the analog stick. - SteamControllerButtonStick = 0x000040, - /// Press in the up area of the left trackpad. - SteamControllerButtonLeftTrackpadClickUp = 0x000100, - /// Press in the right area of the left trackpad. - SteamControllerButtonLeftTrackpadClickRight = 0x000200, - /// Press in the left area of the left trackpad. - SteamControllerButtonLeftTrackpadClickLeft = 0x000400, - /// Press in the down area of the left trackpad. - SteamControllerButtonLeftTrackpadClickDown = 0x000800, - /// The left pointing button to the left of the Steam button. - SteamControllerButtonBack = 0x001000, - /// Steam Button. The big round one in the middle of the controller. - SteamControllerButtonSteam = 0x002000, - /// The right pointing button to the right of the Steam button. - SteamControllerButtonForward = 0x004000, - /// The button on the left underside of the controller. - SteamControllerButtonLeftGrip = 0x008000, - /// A full press on the right trigger (the button below the right bumper). - SteamControllerButtonRightTrigger = 0x010000, - /// A full press on the left trigger (the button below the left bumper). - SteamControllerButtonLeftTrigger = 0x020000, - /// The right bumper button, also known as right shoulder button. - SteamControllerButtonRightBumper = 0x040000, - /// The left bumper button, also known as left shoulder button. - SteamControllerButtonLeftBumper = 0x080000, - /// The button marked A on the front of the controller. - SteamControllerButtonA = 0x800000, - /// The button marked B on the front of the controller. - SteamControllerButtonB = 0x200000, - /// The button marked X on the front of the controller. - SteamControllerButtonX = 0x400000, - /// The button marked Y on the front of the controller. - SteamControllerButtonY = 0x100000 -}; - -/// Returns a string representing the name of a button. -NSString* _Nonnull NSStringFromSteamControllerButton(SteamControllerButton button); - -/// A block called when a button is pressed or released. -typedef void(^SteamControllerButtonHandler)(SteamController * _Nonnull controller, SteamControllerButton button, BOOL isDown); - -NS_ASSUME_NONNULL_BEGIN - -/** - Steam Controllers are available to an application that links to `SteamController.framework`. To detect connected - or pairing Steam Controllers, call `scanForControllers` on `SteamControllerManager`. Because of the way bluetooth - accessories communicate with iOS apps, it's not possible to detect the connection automatically using public API, - so you will need to call `scanForControllers` accordingly to ensure they're available when needed (e.g. before - starting a game, after a controller is disconnected). - - Once connected, they work in the same way as the native `GCGameController` from `GameController.framework`, and - can be accessed in the same ways: - - 1. Querying for the the current array of controllers using `[GCController controllers]`. - 2. Registering for Connection/Disconnection notifications from `NSNotificationCenter`. - - Steam Controllers are represented by the `SteamController` class, a subclass of `GCController`. It implements the - `GCGamepad` and `GCExtendedGamepad` profiles, and has additional functionality relevant to the Steam Controller: - - - Changing the mapping of the trackpads and stick. - - Requiring clicking on the trackpads for input to be sent. - - Identifying a controller by playing a tune on it. - - Handling combinations of Steam button + another button. - - */ -@interface SteamController : GCController - -#pragma mark - Input Mapping -/** Mapping of the Steam Controller's left trackpad. Defaults to `SteamControllerMappingDPad`. */ -@property (nonatomic, assign) SteamControllerMapping steamLeftTrackpadMapping; -/** Mapping of the Steam Controller's right trackpad. Defaults to `SteamControllerMappingRightThumbstick`. */ -@property (nonatomic, assign) SteamControllerMapping steamRightTrackpadMapping; -/** Mapping of the Steam Controller's analog stick. Defaults to `SteamControllerMappingLeftThumbstick`. */ -@property (nonatomic, assign) SteamControllerMapping steamThumbstickMapping; - -#pragma mark - Trackpad Configuration -/** If `YES`, the input from the left trackpad will only be sent when it is clicked. Otherwise, input -will be sent as soon as it's touched. Defaults to `YES`. */ -@property (nonatomic, assign) BOOL steamLeftTrackpadRequiresClick; -/** If `YES`, the input from the right trackpad will only be sent when it is clicked. Otherwise, input - will be sent as soon as it's touched. Defaults to `YES`. */ -@property (nonatomic, assign) BOOL steamRightTrackpadRequiresClick; - -#pragma mark - Miscellaneous -/** The CoreBluetooth peripheral associated with this controller. */ -@property (nonatomic, readonly, retain) CBPeripheral *peripheral; - -/** Battery level (0.0 to 1.0). - - This is derived from the voltage reported by the controller, 1.0 meaning 3 volts. - This property is KVO-compliant. - */ -@property (nonatomic, readonly) float batteryLevel; - -/** Plays the identify tune on the controller. */ -- (void)identify; - -/// :nodoc: -- (instancetype)initWithPeripheral:(CBPeripheral*)peripheral NS_DESIGNATED_INITIALIZER; - -/** Handler for combinations using the Steam button. - - If set, this handler will be called on the handler queue when another button is pressed or released - in combination with the Steam button: - - - When the Steam button is pressed, this handler will be called once for every other button that is - currently pressed, with `isDown=YES`. - - While the Steam button is held down, this handler will be called whenever the buttons change. - - When the Steam button is released, this handler will be called for every other button that was pressed - with `isDown=NO`, and the other handlers will be updated to reflect the current state of the buttons. If - there were no button presses while the Steam button was down, `controllerPausedHandler` will be called - on the main queue. - */ -@property (nonatomic, copy, nullable) SteamControllerButtonHandler steamButtonCombinationHandler; - -/** Sets the mode of the controller. - - Defaults to SteamControllerModeGameController. */ -@property (nonatomic, assign) SteamControllerMode steamControllerMode; - -@end - -/** - Extension to `GCExtendedGamepad` to support additional buttons in the Steam Controller. - - For a non-steam controller, the additional buttons will return `nil`. -*/ -@interface GCExtendedGamepad (SteamController) -/// The left pointing button to the left of the Steam button. -@property (nonatomic, readonly, nullable) GCControllerButtonInput *steamBackButton; -/// The right pointing button to the right of the Steam button. -@property (nonatomic, readonly, nullable) GCControllerButtonInput *steamForwardButton; -/// The Steam button. -@property (nonatomic, readonly, nullable) GCControllerButtonInput *steamSteamButton; -@end - -NS_ASSUME_NONNULL_END - - diff --git a/xcode/MAME4iOS/SteamController/SteamController.m b/xcode/MAME4iOS/SteamController/SteamController.m deleted file mode 100644 index 5cd04c03..00000000 --- a/xcode/MAME4iOS/SteamController/SteamController.m +++ /dev/null @@ -1,513 +0,0 @@ -// -// SteamController.m -// SteamController -// -// Created by Jesús A. Álvarez on 16/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import "SteamController.h" -#import "SteamControllerInput.h" -#import "SteamControllerExtendedGamepad.h" -#import - -#ifndef STEAMCONTROLLER_NO_PRIVATE_API -static void (*GSEventResetIdleTimer)(void); -static void fakeGSEventResetIdleTimer() {}; -@import Darwin.POSIX.dlfcn; -#endif - - -static inline float S16ToFloat(int16_t value) { - if (value == 0) { - return 0.0; - } else if (value > 0) { - return value / (float)INT16_MAX; - } else { - return value / (float)-INT16_MIN; - } -} - -static void UpdateStatePad(SteamControllerExtendedGamepadSnapshotData* state, SteamControllerMapping pad, float x, float y, BOOL button) { - switch (pad) { - case SteamControllerMappingLeftThumbstick: - state->leftThumbstickX = x; - state->leftThumbstickY = y; - state->leftThumbstickButton = button; - break; - case SteamControllerMappingRightThumbstick: - state->rightThumbstickX = x; - state->rightThumbstickY = y; - state->rightThumbstickButton = button; - break; - case SteamControllerMappingDPad: - state->dpadX = x; - state->dpadY = y; - state->leftThumbstickButton |= button; - break; - default: - break; - } -} - -static CBUUID *SteamControllerInputCharacteristicUUID; -static CBUUID *SteamControllerInputDescriptorUUID; -static CBUUID *SteamControllerReportCharacteristicUUID; - -@interface SteamController () -- (void)playTune:(uint8_t)tune; -@end - -@implementation SteamController -{ - CBCharacteristic *reportCharacteristic; - SteamControllerExtendedGamepad *extendedGamepad; - GCControllerPlayerIndex playerIndex; - dispatch_queue_t handlerQueue; - void (^controllerPausedHandler)(GCController *controller); - BOOL handledSteamCombos; - SteamControllerState state; - uint32_t currentSteamCombos; -} - -+ (void)load { -#ifndef STEAMCONTROLLER_NO_PRIVATE_API - GSEventResetIdleTimer = dlsym(RTLD_DEFAULT, "GSEventResetIdleTimer"); - if (GSEventResetIdleTimer == NULL) { - GSEventResetIdleTimer = fakeGSEventResetIdleTimer; - } -#endif -} - -- (instancetype)init { - @throw [NSException exceptionWithName:NSInternalInconsistencyException reason:@"Please don't init SteamController without a peripheral." userInfo:nil]; - return [self initWithPeripheral:nil]; -} - -- (instancetype)initWithPeripheral:(CBPeripheral *)peripheral { - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - SteamControllerInputCharacteristicUUID = [CBUUID UUIDWithString:@"100F6C33-1735-4313-B402-38567131E5F3"]; - SteamControllerInputDescriptorUUID = [CBUUID UUIDWithString:@"00002902-0000-1000-8000-00805f9b34fb"]; - SteamControllerReportCharacteristicUUID = [CBUUID UUIDWithString:@"100F6C34-1735-4313-B402-38567131E5F3"]; - }); - if ((self = [super init])) { - _peripheral = peripheral; - _peripheral.delegate = self; - _steamLeftTrackpadMapping = SteamControllerMappingDPad; - _steamRightTrackpadMapping = SteamControllerMappingRightThumbstick; - _steamThumbstickMapping = SteamControllerMappingLeftThumbstick; - _steamLeftTrackpadRequiresClick = YES; - _steamRightTrackpadRequiresClick = YES; - _steamControllerMode = SteamControllerModeGameController; // will set on connection - memset(&state, 0, sizeof(state)); - extendedGamepad = [[SteamControllerExtendedGamepad alloc] initWithController:self]; - self.playerIndex = GCControllerPlayerIndexUnset; - self.handlerQueue = dispatch_get_main_queue(); - } - return self; -} - -#pragma mark - Accessors - -- (GCControllerPlayerIndex)playerIndex { - return playerIndex; -} - -- (void)setPlayerIndex:(GCControllerPlayerIndex)newPlayerIndex { - playerIndex = newPlayerIndex; -} - -- (BOOL)isAttachedToDevice { - return NO; -} - -- (NSString *)vendorName { - return @"Steam Controller"; -} - -- (NSString *)productCategory { - return @"Steam"; -} - -- (dispatch_queue_t)handlerQueue { - return handlerQueue; -} - -- (void)setHandlerQueue:(dispatch_queue_t)newHandlerQueue { - handlerQueue = newHandlerQueue; -} - -- (GCExtendedGamepad *)extendedGamepad { - return extendedGamepad; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -- (GCGamepad *)gamepad { - return (GCGamepad *)extendedGamepad; -} -#pragma clang diagnostic pop - -- (GCMicroGamepad *)microGamepad { - return nil; -} - -- (GCMotion *)motion { - return nil; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -- (void (^)(GCController * _Nonnull))controllerPausedHandler { - return controllerPausedHandler; -} - -- (void)setControllerPausedHandler:(void (^)(GCController * _Nonnull))newHandler { - controllerPausedHandler = newHandler; -} -#pragma clang diagnostic pop - -- (void)setSteamControllerMode:(SteamControllerMode)steamControllerMode { - _steamControllerMode = steamControllerMode; - if (reportCharacteristic == nil) { - return; // will do after discovering characteristic - } - NSData *packet = nil; - switch (steamControllerMode) { - case SteamControllerModeGameController: - packet = [NSData dataWithBytes:"\xC0\x87\x03\x08\x07\x00" length:6]; - break; - case SteamControllerModeKeyboardAndMouse: - packet = [NSData dataWithBytes:"\xC0\x87\x03\x08\x00\x00" length:6]; - break; - default: - break; - } - if (packet) { - [_peripheral writeValue:packet forCharacteristic:reportCharacteristic type:CBCharacteristicWriteWithResponse]; - } -} - -- (BOOL)isSnapshot { - return NO; -} - -#pragma mark - CBPeripheralDelegate - -- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(NSError *)error { - -} - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error { - for (CBService *service in peripheral.services) { - [peripheral discoverCharacteristics:nil forService:service]; - } -} - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error { - for (CBCharacteristic *characteristic in service.characteristics) { - if ([characteristic.UUID isEqual:SteamControllerInputCharacteristicUUID]) { - [peripheral setNotifyValue:YES forCharacteristic:characteristic]; - } - [peripheral discoverDescriptorsForCharacteristic:characteristic]; - } -} - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { - if ([characteristic.UUID isEqual:SteamControllerReportCharacteristicUUID]) { - reportCharacteristic = characteristic; - self.steamControllerMode = _steamControllerMode; - [[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) - withObject:[NSNotification notificationWithName:GCControllerDidConnectNotification object:self] - waitUntilDone:NO]; - } -} - -- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { - -} - -- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { - -} - -- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error { - -} - -- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error { - if ([characteristic.UUID isEqual:SteamControllerInputCharacteristicUUID]) { - NSData *value = characteristic.value; - const uint8_t *bytes = value.bytes; - if (value.length < 2 || bytes[0] != 0xc0) return; // interesting events start with c0 - uint16_t packetType = OSReadLittleInt16(bytes, 1); - if ((packetType & 0x5000) == 0x5000) { - [self didReceiveStatus:value]; - } else if (packetType & 0x03b0) { - [self didReceiveInput:packetType data:value]; - } - } -} - -- (void)didConnect { - [_peripheral discoverServices:nil]; -} - -- (void)didDisconnect { - [[NSNotificationCenter defaultCenter] performSelectorOnMainThread:@selector(postNotification:) - withObject:[NSNotification notificationWithName:GCControllerDidDisconnectNotification object:self] - waitUntilDone:NO]; -} - -- (void)didReceiveStatus:(NSData*)data { - const uint8_t *bytes = data.bytes; - //uint32_t seqn = OSReadLittleInt32(bytes, 4); - uint16_t voltage = OSReadLittleInt16(bytes, 12); - float level = voltage / 3000.0; - if (level != _batteryLevel) { - [self willChangeValueForKey:@"batteryLevel"]; - _batteryLevel = level; - [self didChangeValueForKey:@"batteryLevel"]; - } -} - -- (void)didReceiveInput:(uint16_t)packetType data:(NSData*)data { - const uint8_t *bytes = data.bytes; - - // Parse update - BOOL hasButtons = packetType & 0x0010; - BOOL hasTriggers = packetType & 0x0020; - BOOL hasStick = packetType & 0x0080; - BOOL hasLeftTrackpad = packetType & 0x0100; - BOOL hasRightTrackpad = packetType & 0x0200; - - // Update internal state - const uint8_t *buf = bytes + 3; - uint32_t previousButtons = state.buttons; - if (hasButtons) { - state.buttons = OSReadBigInt32(buf, -1) & 0xffffff; - buf += 3; - } - - if (hasTriggers) { - state.leftTrigger = buf[0]; - state.rightTrigger = buf[1]; - buf += 2; - } - - if (hasStick) { - state.stick.x = OSReadLittleInt16(buf, 0); - state.stick.y = OSReadLittleInt16(buf, 2); - buf += 4; - } - - if (hasLeftTrackpad) { - state.leftPad.x = OSReadLittleInt16(buf, 0); - state.leftPad.y = OSReadLittleInt16(buf, 2); - buf += 4; - } - - if (hasRightTrackpad) { - state.rightPad.x = OSReadLittleInt16(buf, 0); - state.rightPad.y = OSReadLittleInt16(buf, 2); - buf += 4; - } - - // Update extended gamepad state - SteamControllerExtendedGamepadSnapshotData snapshot = extendedGamepad.state; -#define ButtonToFloat(b) ((state.buttons & b) ? 1.0 : 0.0) -#define ButtonToBool(b) ((state.buttons & b) ? YES : NO) - snapshot.buttonA = ButtonToFloat(SteamControllerButtonA); - snapshot.buttonB = ButtonToFloat(SteamControllerButtonB); - snapshot.buttonX = ButtonToFloat(SteamControllerButtonX); - snapshot.buttonY = ButtonToFloat(SteamControllerButtonY); - snapshot.leftShoulder = ButtonToFloat(SteamControllerButtonLeftBumper); - snapshot.rightShoulder = ButtonToFloat(SteamControllerButtonRightBumper); - snapshot.leftTrigger = (state.buttons & SteamControllerButtonLeftTrigger) ? 1.0 : state.leftTrigger / 255.0; - snapshot.rightTrigger = (state.buttons & SteamControllerButtonRightTrigger) ? 1.0 : state.rightTrigger / 255.0; - snapshot.leftThumbstickButton = (state.buttons & SteamControllerButtonLeftGrip); - snapshot.rightThumbstickButton = (state.buttons & SteamControllerButtonRightGrip); - snapshot.steamBackButton = (state.buttons & SteamControllerButtonBack); - snapshot.steamForwardButton = (state.buttons & SteamControllerButtonForward); - snapshot.steamSteamButton = (state.buttons & SteamControllerButtonSteam); - - BOOL hasUpdatedPads[] = { - [SteamControllerMappingDPad] = NO, - [SteamControllerMappingLeftThumbstick] = NO, - [SteamControllerMappingRightThumbstick] = NO - }; - - if (_steamLeftTrackpadRequiresClick) { - if ((state.buttons & SteamControllerButtonLeftTrackpadClick)) { - UpdateStatePad(&snapshot, _steamLeftTrackpadMapping, S16ToFloat(state.leftPad.x), S16ToFloat(state.leftPad.y), (state.buttons & SteamControllerButtonLeftGrip)); - hasUpdatedPads[_steamLeftTrackpadMapping] = state.leftPad.x || state.leftPad.y; - } else { - UpdateStatePad(&snapshot, _steamLeftTrackpadMapping, 0.0, 0.0, (state.buttons & SteamControllerButtonLeftGrip)); - } - } else { - UpdateStatePad(&snapshot, _steamLeftTrackpadMapping, S16ToFloat(state.leftPad.x), S16ToFloat(state.leftPad.y), (state.buttons & (SteamControllerButtonLeftTrackpadClick))); - hasUpdatedPads[_steamLeftTrackpadMapping] = state.leftPad.x || state.leftPad.y; - } - - if (_steamRightTrackpadRequiresClick) { - if ((state.buttons & SteamControllerButtonRightTrackpadClick)) { - UpdateStatePad(&snapshot, _steamRightTrackpadMapping, S16ToFloat(state.rightPad.x), S16ToFloat(state.rightPad.y), (state.buttons & SteamControllerButtonRightGrip)); - hasUpdatedPads[_steamRightTrackpadMapping] |= state.rightPad.x || state.rightPad.y; - } else { - UpdateStatePad(&snapshot, _steamRightTrackpadMapping, 0.0, 0.0, (state.buttons & SteamControllerButtonRightGrip)); - } - } else { - UpdateStatePad(&snapshot, _steamRightTrackpadMapping, S16ToFloat(state.rightPad.x), S16ToFloat(state.rightPad.y), (state.buttons & (SteamControllerButtonRightTrackpadClick))); - hasUpdatedPads[_steamRightTrackpadMapping] |= state.rightPad.x || state.rightPad.y; - } - - if (_steamThumbstickMapping && !hasUpdatedPads[_steamThumbstickMapping]) { - UpdateStatePad(&snapshot, _steamThumbstickMapping, S16ToFloat(state.stick.x), S16ToFloat(state.stick.y), (state.buttons & SteamControllerButtonStick)); - hasUpdatedPads[_steamThumbstickMapping] = state.stick.x || state.stick.y; - } - - // Ensure grip buttons override thumbstick button state - snapshot.leftThumbstickButton |= (state.buttons & SteamControllerButtonLeftGrip); - snapshot.rightThumbstickButton |= (state.buttons & SteamControllerButtonRightGrip); - - // Reset idle timer -#ifndef STEAMCONTROLLER_NO_PRIVATE_API - GSEventResetIdleTimer(); -#endif - - if (_steamButtonCombinationHandler == nil) { - // Update client - extendedGamepad.state = snapshot; - } - else if (hasButtons && (state.buttons & SteamControllerButtonSteam)) { - // Handle steam button combos - handledSteamCombos |= [self handleSteamButtonCombos:(state.buttons & ~SteamControllerButtonSteam)]; - } else if (hasButtons && (previousButtons & SteamControllerButtonSteam)) { - // Released steam button - if (handledSteamCombos) { - [self handleSteamButtonCombos:0]; - handledSteamCombos = NO; - // Update client - extendedGamepad.state = snapshot; - } else if (controllerPausedHandler) { - dispatch_async(dispatch_get_main_queue(), ^{ - self->controllerPausedHandler(self); - }); - } - } else if (!(state.buttons & SteamControllerButtonSteam)) { - // Update client - extendedGamepad.state = snapshot; - } -} - -- (BOOL)handleSteamButtonCombos:(uint32_t)buttons { - uint32_t changes = buttons ^ currentSteamCombos; - if (changes == 0 || _steamButtonCombinationHandler == nil) { - return NO; - } - for (uint32_t mask = 0x800000; mask; mask >>= 1) { - if (changes & mask) { - dispatch_async(handlerQueue, ^{ - self->_steamButtonCombinationHandler(self, mask, buttons & mask); - }); - } - } - currentSteamCombos = buttons; - return YES; -} - -#pragma mark - Operations - -- (void)identify { - [self playTune:4]; -} - -- (void)playTune:(uint8_t)tune { - if (reportCharacteristic == nil) { - // ignore - return; - } - char command[] = "\xC0\xB6\x04\x04\x00\x00\x00"; - command[3] = (tune & 0xf); - [_peripheral writeValue:[NSData dataWithBytes:command length:7] forCharacteristic:reportCharacteristic type:CBCharacteristicWriteWithResponse]; -} - -- (GCController *)capture { - if (@available(iOS 13.0, tvOS 13.0, *)) { - GCController *controller = [GCController controllerWithExtendedGamepad]; - [controller.extendedGamepad setStateFromExtendedGamepad:extendedGamepad]; - return controller; - } else { - return nil; - } -} - -@end - -NSString* NSStringFromSteamControllerButton(SteamControllerButton button) { - switch (button) { - case SteamControllerButtonRightGrip: - return @"Right Grip"; - case SteamControllerButtonLeftTrackpadClick: - return @"Left Trackpad Click"; - case SteamControllerButtonRightTrackpadClick: - return @"Right Trackpad Click"; - case SteamControllerButtonLeftTrackpadTouch: - return @"Left Trackpad Touch"; - case SteamControllerButtonRightTrackpadTouch: - return @"Right Trackpad Touch"; - case SteamControllerButtonStick: - return @"Stick Click"; - case SteamControllerButtonLeftTrackpadClickUp: - return @"Left Trackpad Click Up"; - case SteamControllerButtonLeftTrackpadClickRight: - return @"Left Trackpad Click Right"; - case SteamControllerButtonLeftTrackpadClickLeft: - return @"Left Trackpad Click Left"; - case SteamControllerButtonLeftTrackpadClickDown: - return @"LeftTrackpad Click Down"; - case SteamControllerButtonBack: - return @"Back"; - case SteamControllerButtonSteam: - return @"Steam"; - case SteamControllerButtonForward: - return @"Forward"; - case SteamControllerButtonLeftGrip: - return @"Left Grip"; - case SteamControllerButtonRightTrigger: - return @"Right Trigger"; - case SteamControllerButtonLeftTrigger: - return @"Left Trigger"; - case SteamControllerButtonRightBumper: - return @"Right Bumper"; - case SteamControllerButtonLeftBumper: - return @"Left Bumper"; - case SteamControllerButtonA: - return @"A"; - case SteamControllerButtonB: - return @"B"; - case SteamControllerButtonX: - return @"X"; - case SteamControllerButtonY: - return @"Y"; - default: - return [NSString stringWithFormat:@"%06x", button & 0xffffff]; - } -} - -@implementation GCExtendedGamepad (SteamController) - -- (GCControllerButtonInput *)steamBackButton { - return nil; -} - -- (GCControllerButtonInput *)steamForwardButton { - return nil; -} - -- (GCControllerButtonInput *)steamSteamButton { - return nil; -} - -@end diff --git a/xcode/MAME4iOS/SteamController/SteamControllerExtendedGamepad.h b/xcode/MAME4iOS/SteamController/SteamControllerExtendedGamepad.h deleted file mode 100644 index 650d01d2..00000000 --- a/xcode/MAME4iOS/SteamController/SteamControllerExtendedGamepad.h +++ /dev/null @@ -1,85 +0,0 @@ -// -// SteamControllerExtendedGamepad.h -// SteamController -// -// Created by Jesús A. Álvarez on 18/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import -#import "SteamController.h" -#import "SteamControllerInput.h" - -#pragma pack(push, 1) -typedef struct { - -#pragma mark - GCExtendedGamepadSnapshotDataVersion1+ - uint16_t version; - uint16_t size; - - // Extended gamepad data - // Axes in the range [-1.0, 1.0] - float dpadX; - float dpadY; - - // Buttons in the range [0.0, 1.0] - float buttonA; - float buttonB; - float buttonX; - float buttonY; - float leftShoulder; - float rightShoulder; - - // Axes in the range [-1.0, 1.0] - float leftThumbstickX; - float leftThumbstickY; - float rightThumbstickX; - float rightThumbstickY; - - // Buttons in the range [0.0, 1.0] - float leftTrigger; - float rightTrigger; - -#pragma mark - GCExtendedGamepadSnapshotDataVersion2+ - BOOL supportsClickableThumbsticks; - // Left and right thumbstick clickable values (0, 1) - BOOL leftThumbstickButton; - BOOL rightThumbstickButton; - -#pragma mark - Steam Controller - BOOL steamBackButton; - BOOL steamForwardButton; - BOOL steamSteamButton; -} SteamControllerExtendedGamepadSnapshotData; -#pragma pack(pop) - -NS_ASSUME_NONNULL_BEGIN - -@interface SteamControllerExtendedGamepad : GCExtendedGamepad - -@property (nonatomic, readonly) SteamControllerDirectionPad *dpad; -@property (nonatomic, readonly) SteamControllerButtonInput *buttonA; -@property (nonatomic, readonly) SteamControllerButtonInput *buttonB; -@property (nonatomic, readonly) SteamControllerButtonInput *buttonX; -@property (nonatomic, readonly) SteamControllerButtonInput *buttonY; -@property (nonatomic, readonly) SteamControllerDirectionPad *leftThumbstick; -@property (nonatomic, readonly) SteamControllerDirectionPad *rightThumbstick; -@property (nonatomic, readonly) SteamControllerButtonInput *leftShoulder; -@property (nonatomic, readonly) SteamControllerButtonInput *rightShoulder; -@property (nonatomic, readonly) SteamControllerButtonInput *leftTrigger; -@property (nonatomic, readonly) SteamControllerButtonInput *rightTrigger; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *leftThumbstickButton; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *rightThumbstickButton; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *buttonOptions; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *buttonMenu; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *buttonHome; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *steamBackButton; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *steamForwardButton; -@property (nonatomic, readonly, nullable) SteamControllerButtonInput *steamSteamButton; -@property (nonatomic, assign) SteamControllerExtendedGamepadSnapshotData state; - -- (instancetype)initWithController:(SteamController*)controller; - -@end - -NS_ASSUME_NONNULL_END diff --git a/xcode/MAME4iOS/SteamController/SteamControllerExtendedGamepad.m b/xcode/MAME4iOS/SteamController/SteamControllerExtendedGamepad.m deleted file mode 100644 index 8991942a..00000000 --- a/xcode/MAME4iOS/SteamController/SteamControllerExtendedGamepad.m +++ /dev/null @@ -1,137 +0,0 @@ -// -// SteamControllerExtendedGamepad.m -// SteamController -// -// Created by Jesús A. Álvarez on 18/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import "SteamControllerExtendedGamepad.h" -#import "SteamController.h" -#import "SteamControllerInput.h" - -@implementation SteamControllerExtendedGamepad -{ - SteamControllerDirectionPad *leftThumbstick, *rightThumbstick, *dpad; - SteamControllerButtonInput *leftShoulder, *rightShoulder; - SteamControllerButtonInput *leftThumbstickButton, *rightThumbstickButton; - SteamControllerButtonInput *leftTrigger, *rightTrigger; - SteamControllerButtonInput *buttonA, *buttonB, *buttonX, *buttonY; - SteamControllerButtonInput *steamBackButton, *steamForwardButton, *steamSteamButton; - __weak SteamController *steamController; - SteamControllerExtendedGamepadSnapshotData state; - GCExtendedGamepadValueChangedHandler valueChangedHandler; -} - -@synthesize leftThumbstick, rightThumbstick, dpad; -@synthesize leftShoulder, rightShoulder; -@synthesize leftTrigger, rightTrigger; -@synthesize buttonA, buttonB, buttonX, buttonY; -@synthesize leftThumbstickButton, rightThumbstickButton; -@synthesize steamBackButton, steamForwardButton, steamSteamButton; -@synthesize state; - -- (instancetype)initWithController:(SteamController *)controller { - if (self = [super init]) { - steamController = controller; - leftThumbstick = [[SteamControllerDirectionPad alloc] initWithController:controller]; - rightThumbstick = [[SteamControllerDirectionPad alloc] initWithController:controller]; - dpad = [[SteamControllerDirectionPad alloc] initWithController:controller]; - leftShoulder = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - rightShoulder = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - leftTrigger = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - rightTrigger = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - buttonA = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - buttonB = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - buttonX = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - buttonY = [[SteamControllerButtonInput alloc] initWithController:controller analog:YES]; - if ([GCExtendedGamepad instancesRespondToSelector:@selector(leftThumbstickButton)]) { - // runtime supports thumbstick buttons - leftThumbstickButton = [[SteamControllerButtonInput alloc] initWithController:controller analog:NO]; - rightThumbstickButton = [[SteamControllerButtonInput alloc] initWithController:controller analog:NO]; - state.version = 0x0101; - state.size = 62; - state.supportsClickableThumbsticks = YES; - } else { - leftThumbstickButton = nil; - rightThumbstickButton = nil; - // pretend to be GCExtendedGamepadSnapShotDataV100 - state.version = 0x0100; - state.size = 60; - state.supportsClickableThumbsticks = NO; - } - steamBackButton = [[SteamControllerButtonInput alloc] initWithController:controller analog:NO]; - steamForwardButton = [[SteamControllerButtonInput alloc] initWithController:controller analog:NO]; - steamSteamButton = [[SteamControllerButtonInput alloc] initWithController:controller analog:NO]; - } - return self; -} - -- (GCController *)controller { - return steamController; -} - -- (GCExtendedGamepadValueChangedHandler)valueChangedHandler { - return valueChangedHandler; -} - -- (void)setValueChangedHandler:(GCExtendedGamepadValueChangedHandler)newHandler { - valueChangedHandler = newHandler; -} - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-implementations" -- (GCExtendedGamepadSnapshot *)saveSnapshot { - NSData *snapshotData = [NSData dataWithBytes:&state length:state.size]; - return [[GCExtendedGamepadSnapshot alloc] initWithController:self.controller snapshotData:snapshotData]; -} -#pragma clang diagnostic pop - -- (void)setState:(SteamControllerExtendedGamepadSnapshotData)newState { - SteamControllerExtendedGamepadSnapshotData oldState = state; - state = newState; -#define ChangedState(_field) (oldState._field != newState._field) -#define UpdateStateValue(_field) if (ChangedState(_field)) { _field.value = newState._field; [self didChangeValueForElement:_field]; } -#define UpdateStateBool(_field) if (ChangedState(_field)) { _field.value = newState._field ? 1.0 : 0.0; [self didChangeValueForElement:_field]; } -#define UpdateXYValue(_fieldX, _fieldY, _input) if (ChangedState(_fieldX) || ChangedState(_fieldY)) { [_input setX:newState._fieldX Y:newState._fieldY]; [self didChangeValueForElement:_input]; } - UpdateStateValue(buttonA); - UpdateStateValue(buttonB); - UpdateStateValue(buttonX); - UpdateStateValue(buttonY); - UpdateStateValue(leftShoulder); - UpdateStateValue(leftTrigger); - UpdateStateValue(rightShoulder); - UpdateStateValue(rightTrigger); - UpdateXYValue(dpadX, dpadY, dpad); - UpdateXYValue(leftThumbstickX, leftThumbstickY, leftThumbstick); - UpdateXYValue(rightThumbstickX, rightThumbstickY, rightThumbstick); - UpdateStateBool(leftThumbstickButton); - UpdateStateBool(rightThumbstickButton); - UpdateStateBool(steamBackButton); - UpdateStateBool(steamForwardButton); - UpdateStateBool(steamSteamButton); -} - -- (void)didChangeValueForElement:(GCControllerElement*)element { - if (valueChangedHandler) dispatch_async(steamController.handlerQueue, ^{ - self->valueChangedHandler(self, element); - }); -} - -- (SteamControllerButtonInput *)buttonOptions { - return steamBackButton; -} - -- (SteamControllerButtonInput *)buttonMenu { - return steamForwardButton; -} - -- (SteamControllerButtonInput *)buttonHome { - return steamSteamButton; -} - -- (void)setStateFromExtendedGamepad:(GCExtendedGamepad *)extendedGamepad { - // ignore -} - -@end diff --git a/xcode/MAME4iOS/SteamController/SteamControllerInput.h b/xcode/MAME4iOS/SteamController/SteamControllerInput.h deleted file mode 100644 index 7e7cf9f4..00000000 --- a/xcode/MAME4iOS/SteamController/SteamControllerInput.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// SteamControllerInput.h -// SteamController -// -// Created by Jesús A. Álvarez on 18/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import -#import - -typedef struct SteamPadState { - int16_t x, y; -} SteamPadState; - -typedef struct SteamControllerState { - uint32_t buttons; - SteamPadState leftPad, rightPad, stick; - uint8_t leftTrigger, rightTrigger; -} SteamControllerState; - -@class SteamControllerDirectionPad, SteamController; - -NS_ASSUME_NONNULL_BEGIN - -@interface SteamControllerButtonInput : GCControllerButtonInput - -- (instancetype)initWithDirectionPad:(SteamControllerDirectionPad*)dpad; -- (instancetype)initWithController:(SteamController *)controller analog:(BOOL)isAnalog; -- (void)setValue:(float)value; - -@end - -@interface SteamControllerAxisInput : GCControllerAxisInput - -- (instancetype)initWithDirectionPad:(SteamControllerDirectionPad*)dpad; -- (instancetype)initWithController:(SteamController *)controller; -- (void)setValue:(float)value; - -@end - -@interface SteamControllerDirectionPad : GCControllerDirectionPad - -@property (nonatomic, readonly) SteamControllerAxisInput *xAxis; -@property (nonatomic, readonly) SteamControllerAxisInput *yAxis; - -@property (nonatomic, readonly) SteamControllerButtonInput *up; -@property (nonatomic, readonly) SteamControllerButtonInput *down; -@property (nonatomic, readonly) SteamControllerButtonInput *left; -@property (nonatomic, readonly) SteamControllerButtonInput *right; - -@property (nonatomic, readonly, weak) SteamController *steamController; - -- (instancetype)initWithController:(SteamController *)controller; -- (void)setX:(float)x Y:(float)y; - -@end - -NS_ASSUME_NONNULL_END diff --git a/xcode/MAME4iOS/SteamController/SteamControllerInput.m b/xcode/MAME4iOS/SteamController/SteamControllerInput.m deleted file mode 100644 index ba7a5aad..00000000 --- a/xcode/MAME4iOS/SteamController/SteamControllerInput.m +++ /dev/null @@ -1,201 +0,0 @@ -// -// SteamControllerInput.m -// SteamController -// -// Created by Jesús A. Álvarez on 18/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import "SteamControllerInput.h" -#import "SteamController.h" - -@implementation SteamControllerAxisInput -{ - GCControllerAxisValueChangedHandler valueChangedHandler; - SteamControllerDirectionPad *directionPad; - __weak SteamController *steamController; - float value; -} - -- (instancetype)initWithDirectionPad:(SteamControllerDirectionPad*)dpad { - if (self = [super init]) { - directionPad = dpad; - steamController = dpad.steamController; - } - return self; -} - -- (instancetype)initWithController:(SteamController *)controller { - if (self = [super init]) { - steamController = controller; - } - return self; -} - -- (BOOL)isAnalog { - return YES; -} - -- (GCControllerAxisValueChangedHandler)valueChangedHandler { - return valueChangedHandler; -} - -- (void)setValueChangedHandler:(GCControllerAxisValueChangedHandler)newHandler { - valueChangedHandler = newHandler; -} - -- (GCControllerElement *)collection { - return directionPad; -} - -- (float)value { - return value; -} - -- (void)setValue:(float)newValue { - float oldValue = value; - value = newValue; - if (value != oldValue && valueChangedHandler) dispatch_async(steamController.handlerQueue, ^{ - self->valueChangedHandler(self, newValue); - }); -} - -@end - -#define kButtonPressedThreshold 0.3 - -@implementation SteamControllerButtonInput -{ - GCControllerButtonValueChangedHandler valueChangedHandler, pressedChangedHandler; - SteamControllerDirectionPad *directionPad; - __weak SteamController *steamController; - BOOL analog; - float value; -} - -- (instancetype)initWithDirectionPad:(SteamControllerDirectionPad*)dpad { - if (self = [super init]) { - directionPad = dpad; - steamController = dpad.steamController; - analog = YES; - } - return self; -} - -- (instancetype)initWithController:(SteamController *)controller analog:(BOOL)isAnalog { - if (self = [super init]) { - steamController = controller; - analog = isAnalog; - } - return self; -} - -- (BOOL)isAnalog { - return analog; -} - -- (GCControllerButtonValueChangedHandler)valueChangedHandler { - return valueChangedHandler; -} - -- (void)setValueChangedHandler:(GCControllerButtonValueChangedHandler)newHandler { - valueChangedHandler = newHandler; -} - -- (GCControllerButtonValueChangedHandler)pressedChangedHandler { - return pressedChangedHandler; -} - -- (void)setPressedChangedHandler:(GCControllerButtonValueChangedHandler)newHandler { - pressedChangedHandler = newHandler; -} - -- (GCControllerElement *)collection { - return directionPad; -} - -- (float)value { - return value; -} - -- (void)setValue:(float)newValue { - BOOL wasPressed = value > kButtonPressedThreshold; - BOOL pressed = newValue > kButtonPressedThreshold; - float oldValue = value; - value = newValue; - if (value != oldValue && valueChangedHandler) dispatch_async(steamController.handlerQueue, ^{ - self->valueChangedHandler(self, newValue, pressed); - }); - if (pressed != wasPressed && pressedChangedHandler) dispatch_async(steamController.handlerQueue, ^{ - self->pressedChangedHandler(self, newValue, pressed); - }); -} - -- (BOOL)isPressed { - return value > kButtonPressedThreshold; -} - -@end - -@implementation SteamControllerDirectionPad -{ - SteamControllerAxisInput *xAxis, *yAxis; - SteamControllerButtonInput *up, *down, *left, *right; - GCControllerDirectionPadValueChangedHandler valueChangedHandler; -} - -@synthesize xAxis, yAxis; -@synthesize up, down, left, right; - -- (instancetype)initWithController:(SteamController *)controller { - if (self = [super init]) { - _steamController = controller; - xAxis = [[SteamControllerAxisInput alloc] initWithDirectionPad:self]; - yAxis = [[SteamControllerAxisInput alloc] initWithDirectionPad:self]; - up = [[SteamControllerButtonInput alloc] initWithDirectionPad:self]; - down = [[SteamControllerButtonInput alloc] initWithDirectionPad:self]; - left = [[SteamControllerButtonInput alloc] initWithDirectionPad:self]; - right = [[SteamControllerButtonInput alloc] initWithDirectionPad:self]; - } - return self; -} - -- (GCControllerDirectionPadValueChangedHandler)valueChangedHandler { - return valueChangedHandler; -} - -- (void)setValueChangedHandler:(GCControllerDirectionPadValueChangedHandler)newHandler { - valueChangedHandler = newHandler; -} - -- (void)setX:(float)xValue Y:(float)yValue { - [xAxis setValue:xValue]; - if (xValue > 0.0) { - [right setValue:xValue]; - [left setValue:0.0]; - } else if (xValue < 0.0) { - [right setValue:0.0]; - [left setValue:-xValue]; - } else { - [left setValue:0.0]; - [right setValue:0.0]; - } - - [yAxis setValue:yValue]; - if (yValue > 0.0) { - [up setValue:yValue]; - [down setValue:0.0]; - } else if (yValue < 0.0) { - [up setValue:0.0]; - [down setValue:-yValue]; - } else { - [up setValue:0.0]; - [down setValue:0.0]; - } - - if (valueChangedHandler) dispatch_async(_steamController.handlerQueue, ^{ - self->valueChangedHandler(self, xValue, yValue); - }); -} - -@end diff --git a/xcode/MAME4iOS/SteamController/SteamControllerManager.h b/xcode/MAME4iOS/SteamController/SteamControllerManager.h deleted file mode 100644 index f2da6ef9..00000000 --- a/xcode/MAME4iOS/SteamController/SteamControllerManager.h +++ /dev/null @@ -1,55 +0,0 @@ -// -// SteamControllerManager.h -// SteamController -// -// Created by Jesús A. Álvarez on 16/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import - -#define STEAMCONTROLLER_NO_SWIZZLING -#define STEAMCONTROLLER_NO_PRIVATE_API - -@class SteamController; - -NS_ASSUME_NONNULL_BEGIN - -/** - `SteamControllerManager` handles the connection and disconnection of Steam Controllers, and inserts connected Steam - Controllers into the array of controllers returned by `[GCController controllers]`. - */ -@interface SteamControllerManager : NSObject - -/** Returns the shared instance of `SteamControllerManager`. */ -+ (instancetype)sharedManager; - -/** - Returns the currently connected Steam Controllers. Unless you only want to support Steam Controllers, you should - use `[GCController controllers]` instead of this property. */ -@property (nonatomic, readonly) NSArray *controllers; - -/** - Detects connected and pairing Steam Controllers. - If a controller is in pairing mode, this will initiate the pairing process. If it is already paired and connected, - it will configure it and post a `GCControllerDidConnectNotification` notification when it's ready. */ -- (void)scanForControllers; - -@end - -#ifndef STEAMCONTROLLER_NO_PRIVATE_API -/// Implements listening for controller connections over bluetooth using IOKit. -@interface SteamControllerManager (Listening) -/** Starts listening for controller connections. - - You should call this method in your app delegate's `application:didFinishLaunchingWithOptions:` method. - - This enables controllers to be detected automatically when they connect/reconnect, without having to call `scanForControllers`. - This feature calls IOKit functions dynamically, which is private API on iOS/tvOS, it can be excluded from the build by - passing `-DSTEAMCONTROLLER_NO_PRIVATE_API` to the compiler, or using the `SteamController/no-private-api` subspec in your Podfile. - */ -+ (BOOL)listenForConnections; -@end -#endif - -NS_ASSUME_NONNULL_END diff --git a/xcode/MAME4iOS/SteamController/SteamControllerManager.m b/xcode/MAME4iOS/SteamController/SteamControllerManager.m deleted file mode 100644 index b1f86a26..00000000 --- a/xcode/MAME4iOS/SteamController/SteamControllerManager.m +++ /dev/null @@ -1,214 +0,0 @@ -// -// SteamControllerManager.m -// SteamController -// -// Created by Jesús A. Álvarez on 16/12/2018. -// Copyright © 2018 namedfork. All rights reserved. -// - -#import "SteamControllerManager.h" -#import "SteamController.h" -#import - -#ifndef STEAMCONTROLLER_NO_SWIZZLING -@import ObjectiveC.runtime; -#endif - -#ifndef STEAMCONTROLLER_NO_PRIVATE_API -@import Darwin.POSIX.dlfcn; -#endif - -@interface SteamController (Private) -- (void)didConnect; -- (void)didDisconnect; -@end - -@interface SteamControllerManager () -@end - -@implementation SteamControllerManager -{ - CBCentralManager *centralManager; - CBUUID *controllerServiceUUID; - NSMutableDictionary *controllers; - NSMutableSet *connectingPeripherals; -} - -+ (instancetype)sharedManager { - static dispatch_once_t onceToken; - static SteamControllerManager *sharedManager = nil; - dispatch_once(&onceToken, ^{ - sharedManager = [SteamControllerManager new]; - }); - return sharedManager; -} - -- (instancetype)init { - if ((self = [super init])) { - controllerServiceUUID = [CBUUID UUIDWithString:@"100F6C32-1735-4313-B402-38567131E5F3"]; - centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; - controllers = [NSMutableDictionary dictionaryWithCapacity:4]; - connectingPeripherals = [NSMutableSet setWithCapacity:4]; - } - return self; -} - -- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { - [connectingPeripherals addObject:peripheral]; - [central connectPeripheral:peripheral options:nil]; -} - -- (SteamController*)controllerForPeripheral:(CBPeripheral*)peripheral { - NSUUID *uuid = peripheral.identifier; - SteamController *controller = nil; - @synchronized (controllers) { - controller = controllers[uuid]; - if (controller == nil) { - controller = [[SteamController alloc] initWithPeripheral:peripheral]; - controllers[uuid] = controller; - } - } - return controller; -} - -- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral { - SteamController *controller = [self controllerForPeripheral:peripheral]; - [connectingPeripherals removeObject:peripheral]; - [controller didConnect]; -} - -- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error { - SteamController *controller = nil; - @synchronized (controllers) { - controller = controllers[peripheral.identifier]; - [controllers removeObjectForKey:peripheral.identifier]; - } - [connectingPeripherals removeObject:peripheral]; - [controller didDisconnect]; -} - -- (void)centralManagerDidUpdateState:(nonnull CBCentralManager *)central { - if (central.state == CBManagerStatePoweredOn) { - [self scanForControllers]; - } -} - -- (NSArray *)controllers { - return controllers.allValues; -} - -- (void)scanForControllers:(id)sender { - [self scanForControllers]; -} - -- (void)scanForControllers { - if (centralManager.state == CBManagerStatePoweredOn) { - [centralManager scanForPeripheralsWithServices:@[controllerServiceUUID] options:nil]; - NSArray *peripherals = [centralManager retrieveConnectedPeripheralsWithServices:@[controllerServiceUUID]]; - for (CBPeripheral *peripheral in peripherals) { - if (peripheral.state == CBPeripheralStateDisconnected) { - [connectingPeripherals addObject:peripheral]; - [centralManager connectPeripheral:peripheral options:nil]; - } // TODO: something if it's disconnected? - } - } -} - -#pragma mark - Swizzling - -#ifndef STEAMCONTROLLER_NO_SWIZZLING -+ (void)load { - Method m1 = class_getClassMethod([GCController class], @selector(controllers)); - Method m2 = class_getClassMethod([SteamControllerManager class], @selector(controllers)); - Method m3 = class_getClassMethod([SteamControllerManager class], @selector(originalControllers)); - method_exchangeImplementations(m1, m3); - method_exchangeImplementations(m1, m2); -} - -+ (NSArray*)originalControllers { - return @[]; -} - -+ (NSArray*)controllers { - NSArray* originalControllers = [SteamControllerManager originalControllers]; - NSArray* steamControllers = [SteamControllerManager sharedManager].controllers; - return [originalControllers arrayByAddingObjectsFromArray:steamControllers]; -} -#endif - -@end - - -#pragma mark - IOKit - -#ifndef STEAMCONTROLLER_NO_PRIVATE_API -typedef mach_port_t io_object_t; -typedef io_object_t io_connect_t; -typedef io_object_t io_enumerator_t; -typedef io_object_t io_iterator_t; -typedef io_object_t io_registry_entry_t; -typedef io_object_t io_service_t; -typedef char io_name_t[128]; -typedef struct IONotificationPort *IONotificationPortRef; -static IONotificationPortRef (*IONotificationPortCreate)(mach_port_t masterPort); -#define kIOMasterPortDefault 0 -static CFMutableDictionaryRef (*IOServiceMatching)(const char *name); -static CFRunLoopSourceRef (*IONotificationPortGetRunLoopSource)(IONotificationPortRef notify); -typedef void (*IOServiceMatchingCallback)(void *refcon, io_iterator_t iterator); -static kern_return_t (*IOServiceAddMatchingNotification)(IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching CF_RELEASES_ARGUMENT, IOServiceMatchingCallback callback, void *refCon, io_iterator_t *notification); -static io_object_t (*IOIteratorNext)(io_iterator_t iterator); -static kern_return_t (*IOObjectRelease)(io_object_t object); - -static void didConnectHIDDevice(void *refcon, io_iterator_t iterator) { - io_object_t obj; - while ((obj = IOIteratorNext(iterator))) { - IOObjectRelease(obj); - }; - // delay scanning so disconnected notifications fire first - [[SteamControllerManager sharedManager] performSelector:@selector(scanForControllers) withObject:nil afterDelay:0.01]; -} - -@implementation SteamControllerManager (Listening) - -+ (BOOL)listenForConnections { - static dispatch_once_t onceToken; - static BOOL loadedSymbols = NO; - dispatch_once(&onceToken, ^{ - void * IOKit = dlopen("/System/Library/Frameworks/IOKit.framework/IOKit", RTLD_NOLOAD); - if (IOKit) { -#define LoadSymbol(sym) sym = dlsym(IOKit, #sym); if (!sym) {dlclose(IOKit); return;} - LoadSymbol(IONotificationPortCreate); - LoadSymbol(IOServiceMatching); - LoadSymbol(IONotificationPortGetRunLoopSource); - LoadSymbol(IOServiceAddMatchingNotification); - LoadSymbol(IOIteratorNext); - LoadSymbol(IOObjectRelease); - dlclose(IOKit); - loadedSymbols = YES; - } - }); - - if (!loadedSymbols) { - return NO; - } - - IONotificationPortRef notificationPort = IONotificationPortCreate(kIOMasterPortDefault); - CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notificationPort), kCFRunLoopDefaultMode); - CFMutableDictionaryRef matchingDict = IOServiceMatching("IOHIDUserDevice"); - io_iterator_t portIterator = 0; - kern_return_t result = IOServiceAddMatchingNotification(notificationPort, - "IOServicePublish", - matchingDict, - didConnectHIDDevice, - NULL, - &portIterator); - if (result == KERN_SUCCESS) { - didConnectHIDDevice(NULL, portIterator); - return YES; - } - return NO; -} - -@end - -#endif diff --git a/xcode/MAME4iOS/UICollectionView+ZeroState.swift b/xcode/MAME4iOS/UICollectionView+ZeroState.swift index 0f4bff9a..f0313387 100644 --- a/xcode/MAME4iOS/UICollectionView+ZeroState.swift +++ b/xcode/MAME4iOS/UICollectionView+ZeroState.swift @@ -11,6 +11,8 @@ import UIKit extension UICollectionView { @objc func showZeroState() { + guard self.backgroundView == nil else { return } + let backgroundView = UIView() let titleLabel = UILabel() titleLabel.translatesAutoresizingMaskIntoConstraints = false diff --git a/xcode/MAME4iOS/ZipFile.m b/xcode/MAME4iOS/ZipFile.m index b6b6e415..179e2bcc 100644 --- a/xcode/MAME4iOS/ZipFile.m +++ b/xcode/MAME4iOS/ZipFile.m @@ -8,7 +8,7 @@ #import "ZipFile.h" #import -#define SEVEN_ZIP_SUPPORT 0 // minimal support for reading and creating empty 7z files. +#define SEVEN_ZIP_SUPPORT 1 // minimal support for reading and creating empty 7z files. #if !__has_feature(objc_arc) #error("This file assumes ARC")