From b74849f1e1c6ce54f995f0078bfe15b9724a6104 Mon Sep 17 00:00:00 2001 From: jduncanator Date: Wed, 6 Feb 2019 15:36:41 +1100 Subject: [PATCH] Resolve style nits --- .../Logging/Targets/AsyncLogTargetWrapper.cs | 4 +- .../Logging/Targets/JsonLogTarget.cs | 2 +- Ryujinx.Common/Pools/ObjectPool.cs | 3 +- Ryujinx.Common/Pools/SharedPools.cs | 3 +- Ryujinx/Config.jsonc | 8 +-- Ryujinx/Configuration.cs | 55 ++++++++++--------- Ryujinx/Ui/GLScreen.cs | 12 ++-- Ryujinx/Ui/NpadController.cs | 32 +++++------ 8 files changed, 61 insertions(+), 58 deletions(-) diff --git a/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs b/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs index 832d6ae693..a805a83b6e 100644 --- a/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs +++ b/Ryujinx.Common/Logging/Targets/AsyncLogTargetWrapper.cs @@ -33,8 +33,8 @@ namespace Ryujinx.Common.Logging public AsyncLogTargetWrapper(ILogTarget target, int queueLimit, AsyncLogTargetOverflowAction overflowAction) { - _target = target; - _messageQueue = new BlockingCollection(queueLimit); + _target = target; + _messageQueue = new BlockingCollection(queueLimit); _overflowTimeout = overflowAction == AsyncLogTargetOverflowAction.Block ? -1 : 0; _messageThread = new Thread(() => { diff --git a/Ryujinx.Common/Logging/Targets/JsonLogTarget.cs b/Ryujinx.Common/Logging/Targets/JsonLogTarget.cs index e8b2a7de56..410394aa2d 100644 --- a/Ryujinx.Common/Logging/Targets/JsonLogTarget.cs +++ b/Ryujinx.Common/Logging/Targets/JsonLogTarget.cs @@ -15,7 +15,7 @@ namespace Ryujinx.Common.Logging public JsonLogTarget(Stream stream, bool leaveOpen) { - _stream = stream; + _stream = stream; _leaveOpen = leaveOpen; } diff --git a/Ryujinx.Common/Pools/ObjectPool.cs b/Ryujinx.Common/Pools/ObjectPool.cs index c26f2484c7..f996e9d768 100644 --- a/Ryujinx.Common/Pools/ObjectPool.cs +++ b/Ryujinx.Common/Pools/ObjectPool.cs @@ -15,8 +15,8 @@ namespace Ryujinx.Common public ObjectPool(Func factory, int size) { + _items = new T[size - 1]; _factory = factory; - _items = new T[size - 1]; } public T Allocate() @@ -69,7 +69,6 @@ namespace Ryujinx.Common if (items[i] == null) { items[i] = obj; - break; } } diff --git a/Ryujinx.Common/Pools/SharedPools.cs b/Ryujinx.Common/Pools/SharedPools.cs index 9a2f4e996f..51112d867c 100644 --- a/Ryujinx.Common/Pools/SharedPools.cs +++ b/Ryujinx.Common/Pools/SharedPools.cs @@ -12,7 +12,8 @@ namespace Ryujinx.Common public static readonly ObjectPool Instance = new ObjectPool(() => new T(), 20); } - public static ObjectPool Default() where T : class, new() + public static ObjectPool Default() + where T : class, new() { return DefaultPool.Instance; } diff --git a/Ryujinx/Config.jsonc b/Ryujinx/Config.jsonc index 47839ff44c..0f3a906ac3 100644 --- a/Ryujinx/Config.jsonc +++ b/Ryujinx/Config.jsonc @@ -2,7 +2,7 @@ "$schema": "./_schema.json", // Dump shaders in local directory (e.g. `C:\ShaderDumps`) - "graphics_shaders_dump_path": "WowHello", + "graphics_shaders_dump_path": "", // Enable print debug logs "logging_enable_debug": false, @@ -19,7 +19,7 @@ // Enable print error logs "logging_enable_error": true, - // Filtered log classes, in a JSON array, eg. `[ "Loader", "ServiceFS" ]` + // Filtered log classes, in a JSON array, eg. `[ "Loader", "ServiceFs" ]` "logging_filtered_classes": [ ], // Enable file logging @@ -41,12 +41,12 @@ // Enable integrity checks on Switch content files "enable_fs_integrity_checks": true, - // The primary controller's type. + // The primary controller's type // Supported Values: Handheld, ProController, NpadPair, NpadLeft, NpadRight "controller_type": "Handheld", // Keyboard Controls - // https://github.com/opentk/opentk/blob/develop/src/OpenTK/Input/Key.cs + // https://github.com/opentk/opentk/blob/master/src/OpenTK/Input/Key.cs "keyboard_controls": { // Left JoyCon Keyboard Bindings "left_joycon": { diff --git a/Ryujinx/Configuration.cs b/Ryujinx/Configuration.cs index 22a4dfb99e..8fe55bacde 100644 --- a/Ryujinx/Configuration.cs +++ b/Ryujinx/Configuration.cs @@ -26,7 +26,7 @@ namespace Ryujinx /// /// The default configuration instance /// - public static Configuration Default { get; private set; } + public static Configuration Instance { get; private set; } /// /// Dumps shaders in this local directory @@ -94,17 +94,17 @@ namespace Ryujinx public bool EnableFsIntegrityChecks { get; private set; } /// - /// + /// The primary controller's type /// public HidControllerType ControllerType { get; private set; } /// - /// + /// Keyboard control bindings /// public NpadKeyboard KeyboardControls { get; private set; } /// - /// + /// Controller control bindings /// public NpadController GamepadControls { get; private set; } @@ -121,7 +121,7 @@ namespace Ryujinx using (Stream stream = File.OpenRead(path)) { - Default = JsonSerializer.Deserialize(stream, resolver); + Instance = JsonSerializer.Deserialize(stream, resolver); } } @@ -131,11 +131,14 @@ namespace Ryujinx /// The path to the JSON configuration file public static async Task LoadAsync(string path) { - var resolver = CompositeResolver.Create(StandardResolver.AllowPrivateSnakeCase); + var resolver = CompositeResolver.Create( + new[] { new ConfigurationEnumFormatter() }, + new[] { StandardResolver.AllowPrivateSnakeCase } + ); using (Stream stream = File.OpenRead(path)) { - Default = await JsonSerializer.DeserializeAsync(stream, resolver); + Instance = await JsonSerializer.DeserializeAsync(stream, resolver); } } @@ -145,12 +148,12 @@ namespace Ryujinx /// The instance to configure public static void Configure(Switch device) { - if (Default == null) + if (Instance == null) { throw new InvalidOperationException("Configuration has not been loaded yet."); } - GraphicsConfig.ShadersDumpPath = Default.GraphicsShadersDumpPath; + GraphicsConfig.ShadersDumpPath = Instance.GraphicsShadersDumpPath; Logger.AddTarget(new AsyncLogTargetWrapper( new ConsoleLogTarget(), @@ -158,7 +161,7 @@ namespace Ryujinx AsyncLogTargetOverflowAction.Block )); - if (Default.EnableFileLog) + if (Instance.EnableFileLog) { Logger.AddTarget(new AsyncLogTargetWrapper( new FileLogTarget("Ryujinx.log"), @@ -167,49 +170,49 @@ namespace Ryujinx )); } - Logger.SetEnable(LogLevel.Debug, Default.LoggingEnableDebug); - Logger.SetEnable(LogLevel.Stub, Default.LoggingEnableStub); - Logger.SetEnable(LogLevel.Info, Default.LoggingEnableInfo); - Logger.SetEnable(LogLevel.Warning, Default.LoggingEnableWarn); - Logger.SetEnable(LogLevel.Error, Default.LoggingEnableError); + Logger.SetEnable(LogLevel.Debug, Instance.LoggingEnableDebug); + Logger.SetEnable(LogLevel.Stub, Instance.LoggingEnableStub); + Logger.SetEnable(LogLevel.Info, Instance.LoggingEnableInfo); + Logger.SetEnable(LogLevel.Warning, Instance.LoggingEnableWarn); + Logger.SetEnable(LogLevel.Error, Instance.LoggingEnableError); - if (Default.LoggingFilteredClasses.Length > 0) + if (Instance.LoggingFilteredClasses.Length > 0) { foreach (var logClass in EnumExtensions.GetValues()) { Logger.SetEnable(logClass, false); } - foreach (var logClass in Default.LoggingFilteredClasses) + foreach (var logClass in Instance.LoggingFilteredClasses) { Logger.SetEnable(logClass, true); } } - device.EnableDeviceVsync = Default.EnableVsync; + device.EnableDeviceVsync = Instance.EnableVsync; - device.System.State.DockedMode = Default.DockedMode; + device.System.State.DockedMode = Instance.DockedMode; - device.System.State.SetLanguage(Default.SystemLanguage); + device.System.State.SetLanguage(Instance.SystemLanguage); - if (Default.EnableMultiCoreScheduling) + if (Instance.EnableMultiCoreScheduling) { device.System.EnableMultiCoreScheduling(); } - device.System.FsIntegrityCheckLevel = Default.EnableFsIntegrityChecks + device.System.FsIntegrityCheckLevel = Instance.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None; - if(Default.GamepadControls.Enabled) + if(Instance.GamepadControls.Enabled) { - if (GamePad.GetName(Default.GamepadControls.Index) == "Unmapped Controller") + if (GamePad.GetName(Instance.GamepadControls.Index) == "Unmapped Controller") { - Default.GamepadControls.SetEnabled(false); + Instance.GamepadControls.SetEnabled(false); } } - device.Hid.InitilizePrimaryController(Default.ControllerType); + device.Hid.InitilizePrimaryController(Instance.ControllerType); } private class ConfigurationEnumFormatter : IJsonFormatter diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index f453f7cee6..c7aaea2391 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -142,24 +142,24 @@ namespace Ryujinx { KeyboardState keyboard = _keyboard.Value; - currentButton = Configuration.Default.KeyboardControls.GetButtons(keyboard); + currentButton = Configuration.Instance.KeyboardControls.GetButtons(keyboard); - (leftJoystickDx, leftJoystickDy) = Configuration.Default.KeyboardControls.GetLeftStick(keyboard); + (leftJoystickDx, leftJoystickDy) = Configuration.Instance.KeyboardControls.GetLeftStick(keyboard); - (rightJoystickDx, rightJoystickDy) = Configuration.Default.KeyboardControls.GetRightStick(keyboard); + (rightJoystickDx, rightJoystickDy) = Configuration.Instance.KeyboardControls.GetRightStick(keyboard); } - currentButton |= Configuration.Default.GamepadControls.GetButtons(); + currentButton |= Configuration.Instance.GamepadControls.GetButtons(); //Keyboard has priority stick-wise if (leftJoystickDx == 0 && leftJoystickDy == 0) { - (leftJoystickDx, leftJoystickDy) = Configuration.Default.GamepadControls.GetLeftStick(); + (leftJoystickDx, leftJoystickDy) = Configuration.Instance.GamepadControls.GetLeftStick(); } if (rightJoystickDx == 0 && rightJoystickDy == 0) { - (rightJoystickDx, rightJoystickDy) = Configuration.Default.GamepadControls.GetRightStick(); + (rightJoystickDx, rightJoystickDy) = Configuration.Instance.GamepadControls.GetRightStick(); } leftJoystick = new HidJoystickPosition diff --git a/Ryujinx/Ui/NpadController.cs b/Ryujinx/Ui/NpadController.cs index b55c4a669f..9ff5bc913d 100644 --- a/Ryujinx/Ui/NpadController.cs +++ b/Ryujinx/Ui/NpadController.cs @@ -10,23 +10,23 @@ namespace Ryujinx.UI.Input { Invalid, LStick, - DPadUp, - DPadDown, - DPadLeft, - DPadRight, - Back, - LShoulder, RStick, - A, - B, - X, - Y, - Start, + LShoulder, RShoulder, LTrigger, RTrigger, LJoystick, - RJoystick + RJoystick, + DPadUp, + DPadDown, + DPadLeft, + DPadRight, + Start, + Back, + A, + B, + X, + Y } public struct NpadControllerLeft @@ -60,17 +60,17 @@ namespace Ryujinx.UI.Input /// /// Enables or disables controller support /// - public bool Enabled { get; private set; } + public bool Enabled { get; private set; } /// /// Controller Device Index /// - public int Index { get; private set; } + public int Index { get; private set; } /// /// Controller Analog Stick Deadzone /// - public float Deadzone { get; private set; } + public float Deadzone { get; private set; } /// /// Controller Trigger Threshold @@ -80,7 +80,7 @@ namespace Ryujinx.UI.Input /// /// Left JoyCon Controller Bindings /// - public NpadControllerLeft LeftJoycon { get; private set; } + public NpadControllerLeft LeftJoycon { get; private set; } /// /// Right JoyCon Controller Bindings