From cee712105850ac3385cd0091a923438167433f9f Mon Sep 17 00:00:00 2001 From: TSR Berry <20988865+TSRBerry@users.noreply.github.com> Date: Sat, 8 Apr 2023 01:22:00 +0200 Subject: Move solution and projects to src --- src/Ryujinx.Common/Configuration/AntiAliasing.cs | 16 +++ src/Ryujinx.Common/Configuration/AppDataManager.cs | 149 +++++++++++++++++++++ .../Configuration/AspectRatioExtensions.cs | 63 +++++++++ .../Configuration/BackendThreading.cs | 13 ++ .../Configuration/DownloadableContentContainer.cs | 13 ++ .../DownloadableContentJsonSerializerContext.cs | 11 ++ .../Configuration/DownloadableContentNca.cs | 14 ++ .../Configuration/GraphicsBackend.cs | 12 ++ .../Configuration/GraphicsDebugLevel.cs | 14 ++ .../Configuration/Hid/Controller/GamepadInputId.cs | 58 ++++++++ .../Hid/Controller/GenericControllerInputConfig.cs | 82 ++++++++++++ .../Hid/Controller/JoyconConfigControllerStick.cs | 11 ++ .../Motion/CemuHookMotionConfigController.cs | 30 +++++ .../Motion/JsonMotionConfigControllerConverter.cs | 79 +++++++++++ .../Controller/Motion/MotionConfigController.cs | 25 ++++ .../Motion/MotionConfigJsonSerializerContext.cs | 12 ++ .../Controller/Motion/MotionInputBackendType.cs | 13 ++ .../Motion/StandardMotionConfigController.cs | 4 + .../Hid/Controller/RumbleConfigController.cs | 20 +++ .../Controller/StandardControllerInputConfig.cs | 4 + .../Configuration/Hid/Controller/StickInputId.cs | 15 +++ .../Configuration/Hid/ControllerType.cs | 23 ++++ .../Hid/GenericInputConfigurationCommon.cs | 15 +++ .../Configuration/Hid/InputBackendType.cs | 13 ++ .../Configuration/Hid/InputConfig.cs | 41 ++++++ .../Hid/InputConfigJsonSerializerContext.cs | 14 ++ .../Configuration/Hid/JsonInputConfigConverter.cs | 81 +++++++++++ src/Ryujinx.Common/Configuration/Hid/Key.cs | 143 ++++++++++++++++++++ .../Hid/Keyboard/GenericKeyboardInputConfig.cs | 15 +++ .../Hid/Keyboard/JoyconConfigKeyboardStick.cs | 11 ++ .../Hid/Keyboard/StandardKeyboardInputConfig.cs | 4 + .../Configuration/Hid/KeyboardHotkeys.cs | 17 +++ .../Configuration/Hid/LeftJoyconCommonConfig.cs | 15 +++ .../Configuration/Hid/PlayerIndex.cs | 22 +++ .../Configuration/Hid/RightJoyconCommonConfig.cs | 15 +++ .../Configuration/MemoryManagerMode.cs | 13 ++ src/Ryujinx.Common/Configuration/ScalingFilter.cs | 13 ++ .../Configuration/TitleUpdateMetadata.cs | 10 ++ .../TitleUpdateMetadataJsonSerializerContext.cs | 10 ++ 39 files changed, 1133 insertions(+) create mode 100644 src/Ryujinx.Common/Configuration/AntiAliasing.cs create mode 100644 src/Ryujinx.Common/Configuration/AppDataManager.cs create mode 100644 src/Ryujinx.Common/Configuration/AspectRatioExtensions.cs create mode 100644 src/Ryujinx.Common/Configuration/BackendThreading.cs create mode 100644 src/Ryujinx.Common/Configuration/DownloadableContentContainer.cs create mode 100644 src/Ryujinx.Common/Configuration/DownloadableContentJsonSerializerContext.cs create mode 100644 src/Ryujinx.Common/Configuration/DownloadableContentNca.cs create mode 100644 src/Ryujinx.Common/Configuration/GraphicsBackend.cs create mode 100644 src/Ryujinx.Common/Configuration/GraphicsDebugLevel.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/GamepadInputId.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/JoyconConfigControllerStick.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/Motion/CemuHookMotionConfigController.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/Motion/JsonMotionConfigControllerConverter.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/Motion/MotionConfigController.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/Motion/MotionConfigJsonSerializerContext.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/Motion/MotionInputBackendType.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/Motion/StandardMotionConfigController.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/RumbleConfigController.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/StandardControllerInputConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Controller/StickInputId.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/ControllerType.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/GenericInputConfigurationCommon.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/InputBackendType.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/InputConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/InputConfigJsonSerializerContext.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/JsonInputConfigConverter.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Key.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Keyboard/GenericKeyboardInputConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Keyboard/JoyconConfigKeyboardStick.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/Keyboard/StandardKeyboardInputConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/KeyboardHotkeys.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/LeftJoyconCommonConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/PlayerIndex.cs create mode 100644 src/Ryujinx.Common/Configuration/Hid/RightJoyconCommonConfig.cs create mode 100644 src/Ryujinx.Common/Configuration/MemoryManagerMode.cs create mode 100644 src/Ryujinx.Common/Configuration/ScalingFilter.cs create mode 100644 src/Ryujinx.Common/Configuration/TitleUpdateMetadata.cs create mode 100644 src/Ryujinx.Common/Configuration/TitleUpdateMetadataJsonSerializerContext.cs (limited to 'src/Ryujinx.Common/Configuration') diff --git a/src/Ryujinx.Common/Configuration/AntiAliasing.cs b/src/Ryujinx.Common/Configuration/AntiAliasing.cs new file mode 100644 index 00000000..159108ae --- /dev/null +++ b/src/Ryujinx.Common/Configuration/AntiAliasing.cs @@ -0,0 +1,16 @@ +using Ryujinx.Common.Utilities; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + [JsonConverter(typeof(TypedStringEnumConverter))] + public enum AntiAliasing + { + None, + Fxaa, + SmaaLow, + SmaaMedium, + SmaaHigh, + SmaaUltra + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/AppDataManager.cs b/src/Ryujinx.Common/Configuration/AppDataManager.cs new file mode 100644 index 00000000..d6e77843 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/AppDataManager.cs @@ -0,0 +1,149 @@ +using Ryujinx.Common.Logging; +using System; +using System.IO; + +namespace Ryujinx.Common.Configuration +{ + public static class AppDataManager + { + public const string DefaultBaseDir = "Ryujinx"; + public const string DefaultPortableDir = "portable"; + + // The following 3 are always part of Base Directory + private const string GamesDir = "games"; + private const string ProfilesDir = "profiles"; + private const string KeysDir = "system"; + + public enum LaunchMode + { + UserProfile, + Portable, + Custom + } + + public static LaunchMode Mode { get; private set; } + + public static string BaseDirPath { get; private set; } + public static string GamesDirPath { get; private set; } + public static string ProfilesDirPath { get; private set; } + public static string KeysDirPath { get; private set; } + public static string KeysDirPathUser { get; } + + public const string DefaultNandDir = "bis"; + public const string DefaultSdcardDir = "sdcard"; + private const string DefaultModsDir = "mods"; + + public static string CustomModsPath { get; set; } + public static string CustomSdModsPath {get; set; } + public static string CustomNandPath { get; set; } // TODO: Actually implement this into VFS + public static string CustomSdCardPath { get; set; } // TODO: Actually implement this into VFS + + static AppDataManager() + { + KeysDirPathUser = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".switch"); + } + + public static void Initialize(string baseDirPath) + { + string appDataPath; + if (OperatingSystem.IsMacOS()) + { + appDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "Library", "Application Support"); + } + else + { + appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); + } + + if (appDataPath.Length == 0) + { + appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + } + + string userProfilePath = Path.Combine(appDataPath, DefaultBaseDir); + string portablePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DefaultPortableDir); + + if (Directory.Exists(portablePath)) + { + BaseDirPath = portablePath; + Mode = LaunchMode.Portable; + } + else + { + BaseDirPath = userProfilePath; + Mode = LaunchMode.UserProfile; + } + + if (baseDirPath != null && baseDirPath != userProfilePath) + { + if (!Directory.Exists(baseDirPath)) + { + Logger.Error?.Print(LogClass.Application, $"Custom Data Directory '{baseDirPath}' does not exist. Falling back to {Mode}..."); + } + else + { + BaseDirPath = baseDirPath; + Mode = LaunchMode.Custom; + } + } + + BaseDirPath = Path.GetFullPath(BaseDirPath); // convert relative paths + + // NOTE: Moves the Ryujinx folder in `~/.config` to `~/Library/Application Support` if one is found + // and a Ryujinx folder does not already exist in Application Support. + // Also creates a symlink from `~/.config/Ryujinx` to `~/Library/Application Support/Ryujinx` to preserve backwards compatibility. + // This should be removed in the future. + if (OperatingSystem.IsMacOS() && Mode == LaunchMode.UserProfile) + { + string oldConfigPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), DefaultBaseDir); + if (Path.Exists(oldConfigPath) && !Path.Exists(BaseDirPath)) + { + CopyDirectory(oldConfigPath, BaseDirPath); + Directory.Delete(oldConfigPath, true); + Directory.CreateSymbolicLink(oldConfigPath, BaseDirPath); + } + } + + SetupBasePaths(); + } + + private static void SetupBasePaths() + { + Directory.CreateDirectory(BaseDirPath); + Directory.CreateDirectory(GamesDirPath = Path.Combine(BaseDirPath, GamesDir)); + Directory.CreateDirectory(ProfilesDirPath = Path.Combine(BaseDirPath, ProfilesDir)); + Directory.CreateDirectory(KeysDirPath = Path.Combine(BaseDirPath, KeysDir)); + } + + private static void CopyDirectory(string sourceDir, string destinationDir) + { + var dir = new DirectoryInfo(sourceDir); + + if (!dir.Exists) + { + throw new DirectoryNotFoundException($"Source directory not found: {dir.FullName}"); + } + + DirectoryInfo[] subDirs = dir.GetDirectories(); + Directory.CreateDirectory(destinationDir); + + foreach (FileInfo file in dir.GetFiles()) + { + if (file.Name == ".DS_Store") + { + continue; + } + + file.CopyTo(Path.Combine(destinationDir, file.Name)); + } + + foreach (DirectoryInfo subDir in subDirs) + { + CopyDirectory(subDir.FullName, Path.Combine(destinationDir, subDir.Name)); + } + } + + public static string GetModsPath() => CustomModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultModsDir)).FullName; + public static string GetSdModsPath() => CustomSdModsPath ?? Directory.CreateDirectory(Path.Combine(BaseDirPath, DefaultSdcardDir, "atmosphere")).FullName; + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/AspectRatioExtensions.cs b/src/Ryujinx.Common/Configuration/AspectRatioExtensions.cs new file mode 100644 index 00000000..5e97ed19 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/AspectRatioExtensions.cs @@ -0,0 +1,63 @@ +using Ryujinx.Common.Utilities; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + [JsonConverter(typeof(TypedStringEnumConverter))] + public enum AspectRatio + { + Fixed4x3, + Fixed16x9, + Fixed16x10, + Fixed21x9, + Fixed32x9, + Stretched + } + + public static class AspectRatioExtensions + { + public static float ToFloat(this AspectRatio aspectRatio) + { + return aspectRatio.ToFloatX() / aspectRatio.ToFloatY(); + } + + public static float ToFloatX(this AspectRatio aspectRatio) + { + return aspectRatio switch + { + AspectRatio.Fixed4x3 => 4.0f, + AspectRatio.Fixed16x9 => 16.0f, + AspectRatio.Fixed16x10 => 16.0f, + AspectRatio.Fixed21x9 => 21.0f, + AspectRatio.Fixed32x9 => 32.0f, + _ => 16.0f + }; + } + + public static float ToFloatY(this AspectRatio aspectRatio) + { + return aspectRatio switch + { + AspectRatio.Fixed4x3 => 3.0f, + AspectRatio.Fixed16x9 => 9.0f, + AspectRatio.Fixed16x10 => 10.0f, + AspectRatio.Fixed21x9 => 9.0f, + AspectRatio.Fixed32x9 => 9.0f, + _ => 9.0f + }; + } + + public static string ToText(this AspectRatio aspectRatio) + { + return aspectRatio switch + { + AspectRatio.Fixed4x3 => "4:3", + AspectRatio.Fixed16x9 => "16:9", + AspectRatio.Fixed16x10 => "16:10", + AspectRatio.Fixed21x9 => "21:9", + AspectRatio.Fixed32x9 => "32:9", + _ => "Stretched" + }; + } + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/BackendThreading.cs b/src/Ryujinx.Common/Configuration/BackendThreading.cs new file mode 100644 index 00000000..8833b3f0 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/BackendThreading.cs @@ -0,0 +1,13 @@ +using Ryujinx.Common.Utilities; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + [JsonConverter(typeof(TypedStringEnumConverter))] + public enum BackendThreading + { + Auto, + Off, + On + } +} diff --git a/src/Ryujinx.Common/Configuration/DownloadableContentContainer.cs b/src/Ryujinx.Common/Configuration/DownloadableContentContainer.cs new file mode 100644 index 00000000..b6ae2f3f --- /dev/null +++ b/src/Ryujinx.Common/Configuration/DownloadableContentContainer.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + public struct DownloadableContentContainer + { + [JsonPropertyName("path")] + public string ContainerPath { get; set; } + [JsonPropertyName("dlc_nca_list")] + public List DownloadableContentNcaList { get; set; } + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/DownloadableContentJsonSerializerContext.cs b/src/Ryujinx.Common/Configuration/DownloadableContentJsonSerializerContext.cs new file mode 100644 index 00000000..132c45a4 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/DownloadableContentJsonSerializerContext.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(List))] + public partial class DownloadableContentJsonSerializerContext : JsonSerializerContext + { + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/DownloadableContentNca.cs b/src/Ryujinx.Common/Configuration/DownloadableContentNca.cs new file mode 100644 index 00000000..80b67300 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/DownloadableContentNca.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + public struct DownloadableContentNca + { + [JsonPropertyName("path")] + public string FullPath { get; set; } + [JsonPropertyName("title_id")] + public ulong TitleId { get; set; } + [JsonPropertyName("is_enabled")] + public bool Enabled { get; set; } + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/GraphicsBackend.cs b/src/Ryujinx.Common/Configuration/GraphicsBackend.cs new file mode 100644 index 00000000..d74dd6e1 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/GraphicsBackend.cs @@ -0,0 +1,12 @@ +using Ryujinx.Common.Utilities; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + [JsonConverter(typeof(TypedStringEnumConverter))] + public enum GraphicsBackend + { + Vulkan, + OpenGl + } +} diff --git a/src/Ryujinx.Common/Configuration/GraphicsDebugLevel.cs b/src/Ryujinx.Common/Configuration/GraphicsDebugLevel.cs new file mode 100644 index 00000000..ad12302a --- /dev/null +++ b/src/Ryujinx.Common/Configuration/GraphicsDebugLevel.cs @@ -0,0 +1,14 @@ +using Ryujinx.Common.Utilities; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration +{ + [JsonConverter(typeof(TypedStringEnumConverter))] + public enum GraphicsDebugLevel + { + None, + Error, + Slowdowns, + All + } +} diff --git a/src/Ryujinx.Common/Configuration/Hid/Controller/GamepadInputId.cs b/src/Ryujinx.Common/Configuration/Hid/Controller/GamepadInputId.cs new file mode 100644 index 00000000..ad1fa667 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/Hid/Controller/GamepadInputId.cs @@ -0,0 +1,58 @@ +using Ryujinx.Common.Utilities; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration.Hid.Controller +{ + [JsonConverter(typeof(TypedStringEnumConverter))] + public enum GamepadInputId : byte + { + Unbound, + A, + B, + X, + Y, + LeftStick, + RightStick, + LeftShoulder, + RightShoulder, + + // Likely axis + LeftTrigger, + // Likely axis + RightTrigger, + + DpadUp, + DpadDown, + DpadLeft, + DpadRight, + + // Special buttons + + Minus, + Plus, + + Back = Minus, + Start = Plus, + + Guide, + Misc1, + + // Xbox Elite paddle + Paddle1, + Paddle2, + Paddle3, + Paddle4, + + // PS5 touchpad button + Touchpad, + + // Virtual buttons for single joycon + SingleLeftTrigger0, + SingleRightTrigger0, + + SingleLeftTrigger1, + SingleRightTrigger1, + + Count + } +} \ No newline at end of file diff --git a/src/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs b/src/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs new file mode 100644 index 00000000..d7f0e788 --- /dev/null +++ b/src/Ryujinx.Common/Configuration/Hid/Controller/GenericControllerInputConfig.cs @@ -0,0 +1,82 @@ +using Ryujinx.Common.Configuration.Hid.Controller.Motion; +using System; +using System.Text.Json.Serialization; + +namespace Ryujinx.Common.Configuration.Hid.Controller +{ + public class GenericControllerInputConfig : GenericInputConfigurationCommon