mirror of
https://git.743378673.xyz/MeloNX/MeloNX.git
synced 2025-08-02 07:37:09 +02:00
Creating an SDLWindow in swift just makes it magically work
This commit is contained in:
parent
16a2c8a463
commit
5511d1885c
6 changed files with 325 additions and 12 deletions
|
@ -131,6 +131,7 @@
|
|||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 4E87E29A2CCE2C1100F54325 /* Build configuration list for PBXNativeTarget "MeloNX" */;
|
||||
buildPhases = (
|
||||
4ECF0AD52CD0FB5B00A3820B /* ShellScript */,
|
||||
4E87E2882CCE2C1000F54325 /* Sources */,
|
||||
4E87E2892CCE2C1000F54325 /* Frameworks */,
|
||||
4E87E28A2CCE2C1000F54325 /* Resources */,
|
||||
|
@ -198,6 +199,28 @@
|
|||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
4ECF0AD52CD0FB5B00A3820B /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
alwaysOutOfDate = 1;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
outputFileListPaths = (
|
||||
);
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/bash;
|
||||
shellScript = "
|
||||
";
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
4E87E2882CCE2C1000F54325 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
|
@ -359,6 +382,11 @@
|
|||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.MeloNX;
|
||||
|
@ -400,6 +428,11 @@
|
|||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
"$(PROJECT_DIR)/MeloNX/Dependencies/Dynamic\\ Libraries",
|
||||
);
|
||||
MARKETING_VERSION = 1.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.stossy11.MeloNX;
|
||||
|
|
|
@ -52,7 +52,6 @@ struct ContentView: View {
|
|||
}
|
||||
|
||||
func startEmulation(game: URL) {
|
||||
|
||||
setenv("DOTNET_EnableDiagnostics", "0", 1)
|
||||
setenv("HOME", String(validatingUTF8: getenv("HOME"))! + "/Documents", 1)
|
||||
setenv("MVK_CONFIG_LOG_LEVEL", "4", 1)
|
||||
|
@ -63,12 +62,20 @@ func startEmulation(game: URL) {
|
|||
graphicsBackend: "Vulkan"
|
||||
)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
patchMakeKeyAndVisible()
|
||||
SDL_SetMainReady()
|
||||
SDL_iPhoneSetEventPump(SDL_TRUE)
|
||||
SDL_Init(SDL_INIT_VIDEO)
|
||||
patchMakeKeyAndVisible()
|
||||
SDL_SetMainReady()
|
||||
SDL_iPhoneSetEventPump(SDL_TRUE)
|
||||
print(SDL_Init(SDL_INIT_VIDEO))
|
||||
|
||||
let window = SDL_CreateWindow("Ryujinx", Int32(SDL_WINDOWPOS_CENTERED_MASK), Int32(SDL_WINDOWPOS_CENTERED_MASK), 640, 480, SDL_WINDOW_SHOWN.rawValue | SDL_WINDOW_ALLOW_HIGHDPI.rawValue)
|
||||
if window == nil {
|
||||
print("Error creating SDL window: \(String(cString: SDL_GetError()))")
|
||||
} else {
|
||||
print("SDL Window created successfully!")
|
||||
}
|
||||
|
||||
// SDL_Init(SDL_INIT_VIDEO)
|
||||
|
||||
let emulator = RyujinxEmulator()
|
||||
do {
|
||||
try emulator.startWithRunLoop(config: config)
|
||||
|
@ -87,10 +94,11 @@ func patchMakeKeyAndVisible() {
|
|||
extension UIWindow {
|
||||
@objc func wdb_makeKeyAndVisible() {
|
||||
print("Making window key and visible...")
|
||||
self.windowScene = (UIApplication.shared.connectedScenes.first! as! UIWindowScene)
|
||||
if #available(iOS 13.0, *) {
|
||||
self.windowScene = (UIApplication.shared.connectedScenes.first! as! UIWindowScene)
|
||||
}
|
||||
self.wdb_makeKeyAndVisible()
|
||||
theWindow = self
|
||||
reconnectVirtualController()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +114,9 @@ func showVirtualController(url: URL) {
|
|||
g_gcVirtualController = GCVirtualController(configuration: config)
|
||||
g_gcVirtualController.connect { err in
|
||||
print("Controller connect: \(String(describing: err))")
|
||||
startEmulation(game: url)
|
||||
DispatchQueue.main.async {
|
||||
startEmulation(game: url)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ class RyujinxEmulator {
|
|||
// args.append(contentsOf: ["--fullscreen", "true"])
|
||||
args.append(contentsOf: ["--enable-debug-logs", "true"])
|
||||
args.append(contentsOf: ["--enable-trace-logs", "true"])
|
||||
// args.append(contentsOf: ["--list-inputs-ids", "true"])
|
||||
args.append(contentsOf: ["--input-id-1", "1-47150005-05ac-0000-0100-00004f066d01"])
|
||||
// args.append("--input-path")
|
||||
|
||||
|
@ -106,7 +107,7 @@ class RyujinxEmulator {
|
|||
let port = Port()
|
||||
runLoop.add(port, forMode: .default)
|
||||
|
||||
DispatchQueue.main.async {
|
||||
//DispatchQueue.main.async {
|
||||
do {
|
||||
try Self.start(with: config)
|
||||
} catch {
|
||||
|
@ -114,7 +115,7 @@ class RyujinxEmulator {
|
|||
self.isRunning = false
|
||||
return
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue