aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs
diff options
context:
space:
mode:
authorThog <me@thog.eu>2020-01-21 23:23:11 +0100
committerAc_K <Acoustik666@gmail.com>2020-01-21 23:23:11 +0100
commitd6b9babe1d73a78e963455a5a6ea3e7431a44ece (patch)
tree625db9119d8ecc2a9a1858f357b597fb216dfef7 /Ryujinx.HLE/FileSystem/VirtualFileSystem.cs
parentb4b2b8b162cd942d399f3420ea064bee14f5411e (diff)
Keep the GUI alive when closing a game (#888)
* Keep the GUI alive when closing a game Make HLE.Switch init when starting a game and dispose it when closing the GlScreen. This also make HLE in charge of disposing the audio and gpu backend. * Address Ac_k's comments * Make sure to dispose the Discord module and use GTK quit method Also update Discord Precense when closing a game. * Make sure to dispose MainWindow * Address gdk's comments
Diffstat (limited to 'Ryujinx.HLE/FileSystem/VirtualFileSystem.cs')
-rw-r--r--Ryujinx.HLE/FileSystem/VirtualFileSystem.cs79
1 files changed, 78 insertions, 1 deletions
diff --git a/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs b/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs
index 257a55a2..070ec3bc 100644
--- a/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs
+++ b/Ryujinx.HLE/FileSystem/VirtualFileSystem.cs
@@ -1,3 +1,7 @@
+using LibHac;
+using LibHac.Fs;
+using LibHac.FsService;
+using LibHac.FsSystem;
using Ryujinx.HLE.FileSystem.Content;
using Ryujinx.HLE.HOS;
using System;
@@ -16,6 +20,16 @@ namespace Ryujinx.HLE.FileSystem
public static string SystemNandPath = Path.Combine(NandPath, "system");
public static string UserNandPath = Path.Combine(NandPath, "user");
+ public Keyset KeySet { get; private set; }
+ public FileSystemServer FsServer { get; private set; }
+ public FileSystemClient FsClient { get; private set; }
+ public EmulatedGameCard GameCard { get; private set; }
+
+ public VirtualFileSystem()
+ {
+ Reload();
+ }
+
public Stream RomFs { get; private set; }
public void LoadRomFs(string fileName)
@@ -183,6 +197,69 @@ namespace Ryujinx.HLE.FileSystem
return Path.Combine(appDataPath, BasePath);
}
+ public void Reload()
+ {
+ ReloadKeySet();
+
+ LocalFileSystem serverBaseFs = new LocalFileSystem(GetBasePath());
+
+ DefaultFsServerObjects fsServerObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(serverBaseFs, KeySet);
+
+ GameCard = fsServerObjects.GameCard;
+
+ FileSystemServerConfig fsServerConfig = new FileSystemServerConfig
+ {
+ FsCreators = fsServerObjects.FsCreators,
+ DeviceOperator = fsServerObjects.DeviceOperator,
+ ExternalKeySet = KeySet.ExternalKeySet
+ };
+
+ FsServer = new FileSystemServer(fsServerConfig);
+ FsClient = FsServer.CreateFileSystemClient();
+ }
+
+
+ private void ReloadKeySet()
+ {
+ string keyFile = null;
+ string titleKeyFile = null;
+ string consoleKeyFile = null;
+
+ string home = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile);
+
+ LoadSetAtPath(Path.Combine(home, ".switch"));
+ LoadSetAtPath(GetSystemPath());
+
+ void LoadSetAtPath(string basePath)
+ {
+ string localKeyFile = Path.Combine(basePath, "prod.keys");
+ string localTitleKeyFile = Path.Combine(basePath, "title.keys");
+ string localConsoleKeyFile = Path.Combine(basePath, "console.keys");
+
+ if (File.Exists(localKeyFile))
+ {
+ keyFile = localKeyFile;
+ }
+
+ if (File.Exists(localTitleKeyFile))
+ {
+ titleKeyFile = localTitleKeyFile;
+ }
+
+ if (File.Exists(localConsoleKeyFile))
+ {
+ consoleKeyFile = localConsoleKeyFile;
+ }
+ }
+
+ KeySet = ExternalKeyReader.ReadKeyFile(keyFile, titleKeyFile, consoleKeyFile);
+ }
+
+ public void Unload()
+ {
+ RomFs?.Dispose();
+ }
+
public void Dispose()
{
Dispose(true);
@@ -192,7 +269,7 @@ namespace Ryujinx.HLE.FileSystem
{
if (disposing)
{
- RomFs?.Dispose();
+ Unload();
}
}
}