diff --git a/MeloNX-XC/MeloNX.xcodeproj/project.pbxproj b/MeloNX-XC/MeloNX.xcodeproj/project.pbxproj index 9d11421a6..d7dd6b1d9 100644 --- a/MeloNX-XC/MeloNX.xcodeproj/project.pbxproj +++ b/MeloNX-XC/MeloNX.xcodeproj/project.pbxproj @@ -359,7 +359,7 @@ CODE_SIGN_ENTITLEMENTS = MeloNX/MeloNX.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"MeloNX/Preview Content\""; + DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 95J8WZ4TN8; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -368,9 +368,9 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportsDocumentBrowser = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -387,6 +387,8 @@ "$(PROJECT_DIR)/MeloNX/Dependencies", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", + "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", + "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", ); MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.MeloNX; @@ -405,7 +407,7 @@ CODE_SIGN_ENTITLEMENTS = MeloNX/MeloNX.entitlements; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"MeloNX/Preview Content\""; + DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_TEAM = 95J8WZ4TN8; ENABLE_PREVIEWS = YES; GENERATE_INFOPLIST_FILE = YES; @@ -414,9 +416,9 @@ INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportsDocumentBrowser = YES; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -433,6 +435,8 @@ "$(PROJECT_DIR)/MeloNX/Dependencies", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", + "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", + "$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries", ); MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.MeloNX; diff --git a/MeloNX-XC/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate b/MeloNX-XC/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate index a9951fcac..f55522fbb 100644 Binary files a/MeloNX-XC/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate and b/MeloNX-XC/MeloNX.xcodeproj/project.xcworkspace/xcuserdata/stossy11.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/MeloNX-XC/MeloNX.xcodeproj/xcshareddata/xcschemes/MeloNX.xcscheme b/MeloNX-XC/MeloNX.xcodeproj/xcshareddata/xcschemes/MeloNX.xcscheme new file mode 100644 index 000000000..ee89fe56e --- /dev/null +++ b/MeloNX-XC/MeloNX.xcodeproj/xcshareddata/xcschemes/MeloNX.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 5d0175364..a2c154405 100644 --- a/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -3,4 +3,56 @@ uuid = "64A8AF27-6696-4D7A-8C62-06216A95ECF0" type = "1" version = "2.0"> + + + + + + + + + + + + + + + + + + + + + + diff --git a/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist b/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist index 940154f32..b1534966c 100644 --- a/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist +++ b/MeloNX-XC/MeloNX.xcodeproj/xcuserdata/stossy11.xcuserdatad/xcschemes/xcschememanagement.plist @@ -10,5 +10,13 @@ 0 + SuppressBuildableAutocreation + + 4E87E28B2CCE2C1000F54325 + + primary + + + diff --git a/MeloNX-XC/MeloNX/ContentView.swift b/MeloNX-XC/MeloNX/ContentView.swift index 0f3306ee4..6186367f2 100644 --- a/MeloNX-XC/MeloNX/ContentView.swift +++ b/MeloNX-XC/MeloNX/ContentView.swift @@ -16,12 +16,32 @@ struct ContentView: View { @State var gameUrl: URL? @State var showFileImporter: Bool = false @State var emulationStarted: Bool = false + @State var mainThread: Bool = false + + @State var debugmode: Int = 0 + var body: some View { ZStack { VStack { Text("NX iOS") + .font(.largeTitle) + .onTapGesture { + debugmode += 1 + } + .padding() + + if debugmode > 9 { + Text("Debug Mode:") + .font(.title) + Text("Is on Main Thread?: \(mainThread)") + .font(.title2) + Toggle(isOn: $mainThread) { + Text("Use Main Thread") + } + } + Button { showFileImporter.toggle() } label: { @@ -31,7 +51,14 @@ struct ContentView: View { Button { emulationStarted = true gameUrl.startAccessingSecurityScopedResource() - showVirtualController(url: gameUrl) + + let config = RyujinxEmulator.Configuration( + inputPath: gameUrl.path, + mainThread: mainThread, + graphicsBackend: "Vulkan" + ) + + showVirtualController(url: gameUrl, ryuconfig: config) } label: { Text("Go!") } @@ -51,18 +78,14 @@ struct ContentView: View { } } -func startEmulation(game: URL) { +func startEmulation(game: URL, config: RyujinxEmulator.Configuration) { setenv("DOTNET_EnableDiagnostics", "0", 1) setenv("HOME", String(validatingUTF8: getenv("HOME"))! + "/Documents", 1) setenv("MVK_CONFIG_LOG_LEVEL", "4", 1) - let config = RyujinxEmulator.Configuration( - inputPath: game.path, - enableKeyboard: false, - graphicsBackend: "Vulkan" - ) + let config = config - patchMakeKeyAndVisible() + // patchMakeKeyAndVisible() SDL_SetMainReady() SDL_iPhoneSetEventPump(SDL_TRUE) print(SDL_Init(SDL_INIT_VIDEO)) @@ -105,7 +128,7 @@ extension UIWindow { @available(iOS 15.0, *) var g_gcVirtualController: GCVirtualController! @available(iOS 15.0, *) -func showVirtualController(url: URL) { +func showVirtualController(url: URL, ryuconfig: RyujinxEmulator.Configuration) { print("Showing virtual controller...") let config = GCVirtualController.Configuration() config.elements = [ @@ -114,9 +137,7 @@ func showVirtualController(url: URL) { g_gcVirtualController = GCVirtualController(configuration: config) g_gcVirtualController.connect { err in print("Controller connect: \(String(describing: err))") - DispatchQueue.main.async { - startEmulation(game: url) - } + startEmulation(game: url, config: ryuconfig) } } diff --git a/MeloNX-XC/MeloNX/Core/Ryujinx.swift b/MeloNX-XC/MeloNX/Core/Ryujinx.swift index 69fcf5626..343dac026 100644 --- a/MeloNX-XC/MeloNX/Core/Ryujinx.swift +++ b/MeloNX-XC/MeloNX/Core/Ryujinx.swift @@ -25,20 +25,23 @@ class RyujinxEmulator { private var isRunning = false private var emulationThread: Thread? + + + struct Configuration { let inputPath: String - let enableKeyboard: Bool // i don't know why i added this + let mainThread: Bool // i don't know why i added this let graphicsBackend: String var additionalArgs: [String] init( inputPath: String, - enableKeyboard: Bool = true, + mainThread: Bool = true, graphicsBackend: String = "Vulkan", additionalArgs: [String] = [] ) { self.inputPath = inputPath - self.enableKeyboard = enableKeyboard + self.mainThread = mainThread self.graphicsBackend = graphicsBackend self.additionalArgs = additionalArgs } @@ -107,7 +110,18 @@ class RyujinxEmulator { let port = Port() runLoop.add(port, forMode: .default) - //DispatchQueue.main.async { + print(config.mainThread ? "Running on the main thread" : "Running on the background thread") + if config.mainThread { + DispatchQueue.main.async { + do { + try Self.start(with: config) + } catch { + Self.log("Emulation failed to start: \(error)") + self.isRunning = false + return + } + } + } else { do { try Self.start(with: config) } catch { @@ -115,13 +129,12 @@ class RyujinxEmulator { self.isRunning = false return } - // } + } while self.isRunning && runLoop.run(mode: .default, before: .distantFuture) { - autoreleasepool { - } + autoreleasepool { } } @@ -165,9 +178,9 @@ extension RyujinxEmulator.Configuration { args.append(inputPath) - if enableKeyboard { - args.append("--enable-keyboard") - } + // if enableKeyboard { + // args.append("--enable-keyboard") + // } args.append("--graphics-backend") args.append(graphicsBackend) @@ -206,7 +219,7 @@ extension RyujinxEmulator.Configuration { return RyujinxEmulator.Configuration( inputPath: inputPath, - enableKeyboard: enableKeyboard, + mainThread: enableKeyboard, graphicsBackend: graphicsBackend, additionalArgs: additionalArgs )