mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-24 08:44:16 +00:00
[Ryujinx.Headless.SDL2] Address dotnet-format issues (#5379)
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Address or silence dotnet format CA1806 and a few CA1854 warnings * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * First dotnet format pass * Add trailing commas * Fix naming and formatting issues
This commit is contained in:
parent
981e0c082d
commit
40daca5684
9 changed files with 218 additions and 208 deletions
|
@ -12,8 +12,8 @@ namespace Ryujinx.Headless.SDL2
|
||||||
private bool _canProcessInput;
|
private bool _canProcessInput;
|
||||||
|
|
||||||
public event DynamicTextChangedHandler TextChangedEvent;
|
public event DynamicTextChangedHandler TextChangedEvent;
|
||||||
public event KeyPressedHandler KeyPressedEvent { add { } remove { } }
|
public event KeyPressedHandler KeyPressedEvent { add { } remove { } }
|
||||||
public event KeyReleasedHandler KeyReleasedEvent { add { } remove { } }
|
public event KeyReleasedHandler KeyReleasedEvent { add { } remove { } }
|
||||||
|
|
||||||
public bool TextProcessingEnabled
|
public bool TextProcessingEnabled
|
||||||
{
|
{
|
||||||
|
@ -48,4 +48,4 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public void Dispose() { }
|
public void Dispose() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,10 @@ namespace Ryujinx.Headless.SDL2
|
||||||
{
|
{
|
||||||
public string FontFamily => "sans-serif";
|
public string FontFamily => "sans-serif";
|
||||||
|
|
||||||
public ThemeColor DefaultBackgroundColor => new ThemeColor(1, 0, 0, 0);
|
public ThemeColor DefaultBackgroundColor => new(1, 0, 0, 0);
|
||||||
public ThemeColor DefaultForegroundColor => new ThemeColor(1, 1, 1, 1);
|
public ThemeColor DefaultForegroundColor => new(1, 1, 1, 1);
|
||||||
public ThemeColor DefaultBorderColor => new ThemeColor(1, 1, 1, 1);
|
public ThemeColor DefaultBorderColor => new(1, 1, 1, 1);
|
||||||
public ThemeColor SelectionBackgroundColor => new ThemeColor(1, 1, 1, 1);
|
public ThemeColor SelectionBackgroundColor => new(1, 1, 1, 1);
|
||||||
public ThemeColor SelectionForegroundColor => new ThemeColor(1, 0, 0, 0);
|
public ThemeColor SelectionForegroundColor => new(1, 0, 0, 0);
|
||||||
|
|
||||||
public HeadlessHostUiTheme() { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,23 +11,31 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
{
|
{
|
||||||
class OpenGLWindow : WindowBase
|
class OpenGLWindow : WindowBase
|
||||||
{
|
{
|
||||||
|
private static void CheckResult(int result)
|
||||||
|
{
|
||||||
|
if (result < 0)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"SDL_GL function returned an error: {SDL_GetError()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void SetupOpenGLAttributes(bool sharedContext, GraphicsDebugLevel debugLevel)
|
private static void SetupOpenGLAttributes(bool sharedContext, GraphicsDebugLevel debugLevel)
|
||||||
{
|
{
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MAJOR_VERSION, 3));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 3);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_MINOR_VERSION, 3));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_PROFILE_MASK, SDL_GLprofile.SDL_GL_CONTEXT_PROFILE_COMPATIBILITY));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_FLAGS, debugLevel != GraphicsDebugLevel.None ? (int)SDL_GLcontext.SDL_GL_CONTEXT_DEBUG_FLAG : 0);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_CONTEXT_FLAGS, debugLevel != GraphicsDebugLevel.None ? (int)SDL_GLcontext.SDL_GL_CONTEXT_DEBUG_FLAG : 0));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, sharedContext ? 1 : 0);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, sharedContext ? 1 : 0));
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ACCELERATED_VISUAL, 1);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ACCELERATED_VISUAL, 1));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_RED_SIZE, 8));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_GREEN_SIZE, 8));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_BLUE_SIZE, 8));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 8);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_ALPHA_SIZE, 8));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DEPTH_SIZE, 16);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DEPTH_SIZE, 16));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STENCIL_SIZE, 0);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STENCIL_SIZE, 0));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_DOUBLEBUFFER, 1));
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STEREO, 0);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_STEREO, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OpenToolkitBindingsContext : IBindingsContext
|
private class OpenToolkitBindingsContext : IBindingsContext
|
||||||
|
@ -40,9 +48,9 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
|
|
||||||
private class SDL2OpenGLContext : IOpenGLContext
|
private class SDL2OpenGLContext : IOpenGLContext
|
||||||
{
|
{
|
||||||
private IntPtr _context;
|
private readonly IntPtr _context;
|
||||||
private IntPtr _window;
|
private readonly IntPtr _window;
|
||||||
private bool _shouldDisposeWindow;
|
private readonly bool _shouldDisposeWindow;
|
||||||
|
|
||||||
public SDL2OpenGLContext(IntPtr context, IntPtr window, bool shouldDisposeWindow = true)
|
public SDL2OpenGLContext(IntPtr context, IntPtr window, bool shouldDisposeWindow = true)
|
||||||
{
|
{
|
||||||
|
@ -62,9 +70,9 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
|
|
||||||
GL.LoadBindings(new OpenToolkitBindingsContext());
|
GL.LoadBindings(new OpenToolkitBindingsContext());
|
||||||
|
|
||||||
SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 0);
|
CheckResult(SDL_GL_SetAttribute(SDL_GLattr.SDL_GL_SHARE_WITH_CURRENT_CONTEXT, 0));
|
||||||
|
|
||||||
SDL_GL_MakeCurrent(windowHandle, IntPtr.Zero);
|
CheckResult(SDL_GL_MakeCurrent(windowHandle, IntPtr.Zero));
|
||||||
|
|
||||||
return new SDL2OpenGLContext(context, windowHandle);
|
return new SDL2OpenGLContext(context, windowHandle);
|
||||||
}
|
}
|
||||||
|
@ -99,7 +107,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private GraphicsDebugLevel _glLogLevel;
|
private readonly GraphicsDebugLevel _glLogLevel;
|
||||||
private SDL2OpenGLContext _openGLContext;
|
private SDL2OpenGLContext _openGLContext;
|
||||||
|
|
||||||
public OpenGLWindow(
|
public OpenGLWindow(
|
||||||
|
@ -120,7 +128,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
// Ensure to not share this context with other contexts before this point.
|
// Ensure to not share this context with other contexts before this point.
|
||||||
SetupOpenGLAttributes(false, _glLogLevel);
|
SetupOpenGLAttributes(false, _glLogLevel);
|
||||||
IntPtr context = SDL_GL_CreateContext(WindowHandle);
|
IntPtr context = SDL_GL_CreateContext(WindowHandle);
|
||||||
SDL_GL_SetSwapInterval(1);
|
CheckResult(SDL_GL_SetSwapInterval(1));
|
||||||
|
|
||||||
if (context == IntPtr.Zero)
|
if (context == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +165,7 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
Device.DisposeGpu();
|
Device.DisposeGpu();
|
||||||
|
|
||||||
// Unbind context and destroy everything
|
// Unbind context and destroy everything
|
||||||
SDL_GL_MakeCurrent(WindowHandle, IntPtr.Zero);
|
CheckResult(SDL_GL_MakeCurrent(WindowHandle, IntPtr.Zero));
|
||||||
_openGLContext.Dispose();
|
_openGLContext.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,4 +174,4 @@ namespace Ryujinx.Headless.SDL2.OpenGL
|
||||||
SDL_GL_SwapWindow(WindowHandle);
|
SDL_GL_SwapWindow(WindowHandle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
// System
|
// System
|
||||||
|
|
||||||
[Option("disable-ptc", Required = false, HelpText = "Disables profiled persistent translation cache.")]
|
[Option("disable-ptc", Required = false, HelpText = "Disables profiled persistent translation cache.")]
|
||||||
public bool DisablePtc { get; set; }
|
public bool DisablePTC { get; set; }
|
||||||
|
|
||||||
[Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")]
|
[Option("enable-internet-connection", Required = false, Default = false, HelpText = "Enables guest Internet connection.")]
|
||||||
public bool EnableInternetAccess { get; set; }
|
public bool EnableInternetAccess { get; set; }
|
||||||
|
@ -100,7 +100,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
public int FsGlobalAccessLogMode { get; set; }
|
public int FsGlobalAccessLogMode { get; set; }
|
||||||
|
|
||||||
[Option("disable-vsync", Required = false, HelpText = "Disables Vertical Sync.")]
|
[Option("disable-vsync", Required = false, HelpText = "Disables Vertical Sync.")]
|
||||||
public bool DisableVsync { get; set; }
|
public bool DisableVSync { get; set; }
|
||||||
|
|
||||||
[Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")]
|
[Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")]
|
||||||
public bool DisableShaderCache { get; set; }
|
public bool DisableShaderCache { get; set; }
|
||||||
|
@ -126,7 +126,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
[Option("memory-manager-mode", Required = false, Default = MemoryManagerMode.HostMappedUnsafe, HelpText = "The selected memory manager mode.")]
|
[Option("memory-manager-mode", Required = false, Default = MemoryManagerMode.HostMappedUnsafe, HelpText = "The selected memory manager mode.")]
|
||||||
public MemoryManagerMode MemoryManagerMode { get; set; }
|
public MemoryManagerMode MemoryManagerMode { get; set; }
|
||||||
|
|
||||||
[Option("audio-volume", Required = false, Default = 1.0f, HelpText ="The audio level (0 to 1).")]
|
[Option("audio-volume", Required = false, Default = 1.0f, HelpText = "The audio level (0 to 1).")]
|
||||||
public float AudioVolume { get; set; }
|
public float AudioVolume { get; set; }
|
||||||
|
|
||||||
[Option("use-hypervisor", Required = false, Default = true, HelpText = "Uses Hypervisor over JIT if available.")]
|
[Option("use-hypervisor", Required = false, Default = true, HelpText = "Uses Hypervisor over JIT if available.")]
|
||||||
|
@ -181,7 +181,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
[Option("backend-threading", Required = false, Default = BackendThreading.Auto, HelpText = "Whether or not backend threading is enabled. The \"Auto\" setting will determine whether threading should be enabled at runtime.")]
|
[Option("backend-threading", Required = false, Default = BackendThreading.Auto, HelpText = "Whether or not backend threading is enabled. The \"Auto\" setting will determine whether threading should be enabled at runtime.")]
|
||||||
public BackendThreading BackendThreading { get; set; }
|
public BackendThreading BackendThreading { get; set; }
|
||||||
|
|
||||||
[Option("disable-macro-hle", Required= false, HelpText = "Disables high-level emulation of Macro code. Leaving this enabled improves performance but may cause graphical glitches in some games.")]
|
[Option("disable-macro-hle", Required = false, HelpText = "Disables high-level emulation of Macro code. Leaving this enabled improves performance but may cause graphical glitches in some games.")]
|
||||||
public bool DisableMacroHLE { get; set; }
|
public bool DisableMacroHLE { get; set; }
|
||||||
|
|
||||||
[Option("graphics-shaders-dump-path", Required = false, HelpText = "Dumps shaders in this local directory. (Developer only)")]
|
[Option("graphics-shaders-dump-path", Required = false, HelpText = "Dumps shaders in this local directory. (Developer only)")]
|
||||||
|
@ -191,12 +191,12 @@ namespace Ryujinx.Headless.SDL2
|
||||||
public GraphicsBackend GraphicsBackend { get; set; }
|
public GraphicsBackend GraphicsBackend { get; set; }
|
||||||
|
|
||||||
[Option("preferred-gpu-vendor", Required = false, Default = "", HelpText = "When using the Vulkan backend, prefer using the GPU from the specified vendor.")]
|
[Option("preferred-gpu-vendor", Required = false, Default = "", HelpText = "When using the Vulkan backend, prefer using the GPU from the specified vendor.")]
|
||||||
public string PreferredGpuVendor { get; set; }
|
public string PreferredGPUVendor { get; set; }
|
||||||
|
|
||||||
// Hacks
|
// Hacks
|
||||||
|
|
||||||
[Option("expand-ram", Required = false, Default = false, HelpText = "Expands the RAM amount on the emulated system from 4GiB to 6GiB.")]
|
[Option("expand-ram", Required = false, Default = false, HelpText = "Expands the RAM amount on the emulated system from 4GiB to 6GiB.")]
|
||||||
public bool ExpandRam { get; set; }
|
public bool ExpandRAM { get; set; }
|
||||||
|
|
||||||
[Option("ignore-missing-services", Required = false, Default = false, HelpText = "Enable ignoring missing services.")]
|
[Option("ignore-missing-services", Required = false, Default = false, HelpText = "Enable ignoring missing services.")]
|
||||||
public bool IgnoreMissingServices { get; set; }
|
public bool IgnoreMissingServices { get; set; }
|
||||||
|
@ -206,4 +206,4 @@ namespace Ryujinx.Headless.SDL2
|
||||||
[Value(0, MetaName = "input", HelpText = "Input to load.", Required = true)]
|
[Value(0, MetaName = "input", HelpText = "Input to load.", Required = true)]
|
||||||
public string InputPath { get; set; }
|
public string InputPath { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ using Ryujinx.HLE.HOS.Services.Account.Acc;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using Ryujinx.Input.HLE;
|
using Ryujinx.Input.HLE;
|
||||||
using Ryujinx.Input.SDL2;
|
using Ryujinx.Input.SDL2;
|
||||||
|
using Ryujinx.SDL2.Common;
|
||||||
using Silk.NET.Vulkan;
|
using Silk.NET.Vulkan;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -57,7 +58,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
private static bool _enableKeyboard;
|
private static bool _enableKeyboard;
|
||||||
private static bool _enableMouse;
|
private static bool _enableMouse;
|
||||||
|
|
||||||
private static readonly InputConfigJsonSerializerContext SerializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
private static readonly InputConfigJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
|
||||||
|
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -67,10 +68,10 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
|
if (OperatingSystem.IsMacOS() || OperatingSystem.IsLinux())
|
||||||
{
|
{
|
||||||
AutoResetEvent invoked = new AutoResetEvent(false);
|
AutoResetEvent invoked = new(false);
|
||||||
|
|
||||||
// MacOS must perform SDL polls from the main thread.
|
// MacOS must perform SDL polls from the main thread.
|
||||||
Ryujinx.SDL2.Common.SDL2Driver.MainThreadDispatcher = (Action action) =>
|
SDL2Driver.MainThreadDispatcher = action =>
|
||||||
{
|
{
|
||||||
invoked.Reset();
|
invoked.Reset();
|
||||||
|
|
||||||
|
@ -140,53 +141,53 @@ namespace Ryujinx.Headless.SDL2
|
||||||
{
|
{
|
||||||
config = new StandardKeyboardInputConfig
|
config = new StandardKeyboardInputConfig
|
||||||
{
|
{
|
||||||
Version = InputConfig.CurrentVersion,
|
Version = InputConfig.CurrentVersion,
|
||||||
Backend = InputBackendType.WindowKeyboard,
|
Backend = InputBackendType.WindowKeyboard,
|
||||||
Id = null,
|
Id = null,
|
||||||
ControllerType = ControllerType.JoyconPair,
|
ControllerType = ControllerType.JoyconPair,
|
||||||
LeftJoycon = new LeftJoyconCommonConfig<Key>
|
LeftJoycon = new LeftJoyconCommonConfig<Key>
|
||||||
{
|
{
|
||||||
DpadUp = Key.Up,
|
DpadUp = Key.Up,
|
||||||
DpadDown = Key.Down,
|
DpadDown = Key.Down,
|
||||||
DpadLeft = Key.Left,
|
DpadLeft = Key.Left,
|
||||||
DpadRight = Key.Right,
|
DpadRight = Key.Right,
|
||||||
ButtonMinus = Key.Minus,
|
ButtonMinus = Key.Minus,
|
||||||
ButtonL = Key.E,
|
ButtonL = Key.E,
|
||||||
ButtonZl = Key.Q,
|
ButtonZl = Key.Q,
|
||||||
ButtonSl = Key.Unbound,
|
ButtonSl = Key.Unbound,
|
||||||
ButtonSr = Key.Unbound
|
ButtonSr = Key.Unbound,
|
||||||
},
|
},
|
||||||
|
|
||||||
LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
|
LeftJoyconStick = new JoyconConfigKeyboardStick<Key>
|
||||||
{
|
{
|
||||||
StickUp = Key.W,
|
StickUp = Key.W,
|
||||||
StickDown = Key.S,
|
StickDown = Key.S,
|
||||||
StickLeft = Key.A,
|
StickLeft = Key.A,
|
||||||
StickRight = Key.D,
|
StickRight = Key.D,
|
||||||
StickButton = Key.F,
|
StickButton = Key.F,
|
||||||
},
|
},
|
||||||
|
|
||||||
RightJoycon = new RightJoyconCommonConfig<Key>
|
RightJoycon = new RightJoyconCommonConfig<Key>
|
||||||
{
|
{
|
||||||
ButtonA = Key.Z,
|
ButtonA = Key.Z,
|
||||||
ButtonB = Key.X,
|
ButtonB = Key.X,
|
||||||
ButtonX = Key.C,
|
ButtonX = Key.C,
|
||||||
ButtonY = Key.V,
|
ButtonY = Key.V,
|
||||||
ButtonPlus = Key.Plus,
|
ButtonPlus = Key.Plus,
|
||||||
ButtonR = Key.U,
|
ButtonR = Key.U,
|
||||||
ButtonZr = Key.O,
|
ButtonZr = Key.O,
|
||||||
ButtonSl = Key.Unbound,
|
ButtonSl = Key.Unbound,
|
||||||
ButtonSr = Key.Unbound
|
ButtonSr = Key.Unbound,
|
||||||
},
|
},
|
||||||
|
|
||||||
RightJoyconStick = new JoyconConfigKeyboardStick<Key>
|
RightJoyconStick = new JoyconConfigKeyboardStick<Key>
|
||||||
{
|
{
|
||||||
StickUp = Key.I,
|
StickUp = Key.I,
|
||||||
StickDown = Key.K,
|
StickDown = Key.K,
|
||||||
StickLeft = Key.J,
|
StickLeft = Key.J,
|
||||||
StickRight = Key.L,
|
StickRight = Key.L,
|
||||||
StickButton = Key.H,
|
StickButton = Key.H,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -195,72 +196,72 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
config = new StandardControllerInputConfig
|
config = new StandardControllerInputConfig
|
||||||
{
|
{
|
||||||
Version = InputConfig.CurrentVersion,
|
Version = InputConfig.CurrentVersion,
|
||||||
Backend = InputBackendType.GamepadSDL2,
|
Backend = InputBackendType.GamepadSDL2,
|
||||||
Id = null,
|
Id = null,
|
||||||
ControllerType = ControllerType.JoyconPair,
|
ControllerType = ControllerType.JoyconPair,
|
||||||
DeadzoneLeft = 0.1f,
|
DeadzoneLeft = 0.1f,
|
||||||
DeadzoneRight = 0.1f,
|
DeadzoneRight = 0.1f,
|
||||||
RangeLeft = 1.0f,
|
RangeLeft = 1.0f,
|
||||||
RangeRight = 1.0f,
|
RangeRight = 1.0f,
|
||||||
TriggerThreshold = 0.5f,
|
TriggerThreshold = 0.5f,
|
||||||
LeftJoycon = new LeftJoyconCommonConfig<ConfigGamepadInputId>
|
LeftJoycon = new LeftJoyconCommonConfig<ConfigGamepadInputId>
|
||||||
{
|
{
|
||||||
DpadUp = ConfigGamepadInputId.DpadUp,
|
DpadUp = ConfigGamepadInputId.DpadUp,
|
||||||
DpadDown = ConfigGamepadInputId.DpadDown,
|
DpadDown = ConfigGamepadInputId.DpadDown,
|
||||||
DpadLeft = ConfigGamepadInputId.DpadLeft,
|
DpadLeft = ConfigGamepadInputId.DpadLeft,
|
||||||
DpadRight = ConfigGamepadInputId.DpadRight,
|
DpadRight = ConfigGamepadInputId.DpadRight,
|
||||||
ButtonMinus = ConfigGamepadInputId.Minus,
|
ButtonMinus = ConfigGamepadInputId.Minus,
|
||||||
ButtonL = ConfigGamepadInputId.LeftShoulder,
|
ButtonL = ConfigGamepadInputId.LeftShoulder,
|
||||||
ButtonZl = ConfigGamepadInputId.LeftTrigger,
|
ButtonZl = ConfigGamepadInputId.LeftTrigger,
|
||||||
ButtonSl = ConfigGamepadInputId.Unbound,
|
ButtonSl = ConfigGamepadInputId.Unbound,
|
||||||
ButtonSr = ConfigGamepadInputId.Unbound,
|
ButtonSr = ConfigGamepadInputId.Unbound,
|
||||||
},
|
},
|
||||||
|
|
||||||
LeftJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
LeftJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
||||||
{
|
{
|
||||||
Joystick = ConfigStickInputId.Left,
|
Joystick = ConfigStickInputId.Left,
|
||||||
StickButton = ConfigGamepadInputId.LeftStick,
|
StickButton = ConfigGamepadInputId.LeftStick,
|
||||||
InvertStickX = false,
|
InvertStickX = false,
|
||||||
InvertStickY = false,
|
InvertStickY = false,
|
||||||
Rotate90CW = false,
|
Rotate90CW = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
RightJoycon = new RightJoyconCommonConfig<ConfigGamepadInputId>
|
RightJoycon = new RightJoyconCommonConfig<ConfigGamepadInputId>
|
||||||
{
|
{
|
||||||
ButtonA = isNintendoStyle ? ConfigGamepadInputId.A : ConfigGamepadInputId.B,
|
ButtonA = isNintendoStyle ? ConfigGamepadInputId.A : ConfigGamepadInputId.B,
|
||||||
ButtonB = isNintendoStyle ? ConfigGamepadInputId.B : ConfigGamepadInputId.A,
|
ButtonB = isNintendoStyle ? ConfigGamepadInputId.B : ConfigGamepadInputId.A,
|
||||||
ButtonX = isNintendoStyle ? ConfigGamepadInputId.X : ConfigGamepadInputId.Y,
|
ButtonX = isNintendoStyle ? ConfigGamepadInputId.X : ConfigGamepadInputId.Y,
|
||||||
ButtonY = isNintendoStyle ? ConfigGamepadInputId.Y : ConfigGamepadInputId.X,
|
ButtonY = isNintendoStyle ? ConfigGamepadInputId.Y : ConfigGamepadInputId.X,
|
||||||
ButtonPlus = ConfigGamepadInputId.Plus,
|
ButtonPlus = ConfigGamepadInputId.Plus,
|
||||||
ButtonR = ConfigGamepadInputId.RightShoulder,
|
ButtonR = ConfigGamepadInputId.RightShoulder,
|
||||||
ButtonZr = ConfigGamepadInputId.RightTrigger,
|
ButtonZr = ConfigGamepadInputId.RightTrigger,
|
||||||
ButtonSl = ConfigGamepadInputId.Unbound,
|
ButtonSl = ConfigGamepadInputId.Unbound,
|
||||||
ButtonSr = ConfigGamepadInputId.Unbound,
|
ButtonSr = ConfigGamepadInputId.Unbound,
|
||||||
},
|
},
|
||||||
|
|
||||||
RightJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
RightJoyconStick = new JoyconConfigControllerStick<ConfigGamepadInputId, ConfigStickInputId>
|
||||||
{
|
{
|
||||||
Joystick = ConfigStickInputId.Right,
|
Joystick = ConfigStickInputId.Right,
|
||||||
StickButton = ConfigGamepadInputId.RightStick,
|
StickButton = ConfigGamepadInputId.RightStick,
|
||||||
InvertStickX = false,
|
InvertStickX = false,
|
||||||
InvertStickY = false,
|
InvertStickY = false,
|
||||||
Rotate90CW = false,
|
Rotate90CW = false,
|
||||||
},
|
},
|
||||||
|
|
||||||
Motion = new StandardMotionConfigController
|
Motion = new StandardMotionConfigController
|
||||||
{
|
{
|
||||||
MotionBackend = MotionInputBackendType.GamepadDriver,
|
MotionBackend = MotionInputBackendType.GamepadDriver,
|
||||||
EnableMotion = true,
|
EnableMotion = true,
|
||||||
Sensitivity = 100,
|
Sensitivity = 100,
|
||||||
GyroDeadzone = 1,
|
GyroDeadzone = 1,
|
||||||
},
|
},
|
||||||
Rumble = new RumbleConfigController
|
Rumble = new RumbleConfigController
|
||||||
{
|
{
|
||||||
StrongRumble = 1f,
|
StrongRumble = 1f,
|
||||||
WeakRumble = 1f,
|
WeakRumble = 1f,
|
||||||
EnableRumble = false
|
EnableRumble = false,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +289,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
config = JsonHelper.DeserializeFromFile(path, SerializerContext.InputConfig);
|
config = JsonHelper.DeserializeFromFile(path, _serializerContext.InputConfig);
|
||||||
}
|
}
|
||||||
catch (JsonException)
|
catch (JsonException)
|
||||||
{
|
{
|
||||||
|
@ -310,7 +311,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
{
|
{
|
||||||
if (controllerConfig.RangeLeft <= 0.0f && controllerConfig.RangeRight <= 0.0f)
|
if (controllerConfig.RangeLeft <= 0.0f && controllerConfig.RangeRight <= 0.0f)
|
||||||
{
|
{
|
||||||
controllerConfig.RangeLeft = 1.0f;
|
controllerConfig.RangeLeft = 1.0f;
|
||||||
controllerConfig.RangeRight = 1.0f;
|
controllerConfig.RangeRight = 1.0f;
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} stick range reset. Save the profile now to update your configuration");
|
Logger.Info?.Print(LogClass.Application, $"{config.PlayerIndex} stick range reset. Save the profile now to update your configuration");
|
||||||
|
@ -387,7 +388,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_enableKeyboard = option.EnableKeyboard;
|
_enableKeyboard = option.EnableKeyboard;
|
||||||
_enableMouse = option.EnableMouse;
|
_enableMouse = option.EnableMouse;
|
||||||
|
|
||||||
void LoadPlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index)
|
static void LoadPlayerConfiguration(string inputProfileName, string inputId, PlayerIndex index)
|
||||||
{
|
{
|
||||||
InputConfig inputConfig = HandlePlayerConfiguration(inputProfileName, inputId, index);
|
InputConfig inputConfig = HandlePlayerConfiguration(inputProfileName, inputId, index);
|
||||||
|
|
||||||
|
@ -468,19 +469,12 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
private static void ProgressHandler<T>(T state, int current, int total) where T : Enum
|
private static void ProgressHandler<T>(T state, int current, int total) where T : Enum
|
||||||
{
|
{
|
||||||
string label;
|
string label = state switch
|
||||||
|
|
||||||
switch (state)
|
|
||||||
{
|
{
|
||||||
case LoadState ptcState:
|
LoadState => $"PTC : {current}/{total}",
|
||||||
label = $"PTC : {current}/{total}";
|
ShaderCacheState => $"Shaders : {current}/{total}",
|
||||||
break;
|
_ => throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}"),
|
||||||
case ShaderCacheState shaderCacheState:
|
};
|
||||||
label = $"Shaders : {current}/{total}";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ArgumentException($"Unknown Progress Handler type {typeof(T)}");
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.Info?.Print(LogClass.Application, label);
|
Logger.Info?.Print(LogClass.Application, label);
|
||||||
}
|
}
|
||||||
|
@ -499,9 +493,9 @@ namespace Ryujinx.Headless.SDL2
|
||||||
string preferredGpuId = string.Empty;
|
string preferredGpuId = string.Empty;
|
||||||
Vk api = Vk.GetApi();
|
Vk api = Vk.GetApi();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(options.PreferredGpuVendor))
|
if (!string.IsNullOrEmpty(options.PreferredGPUVendor))
|
||||||
{
|
{
|
||||||
string preferredGpuVendor = options.PreferredGpuVendor.ToLowerInvariant();
|
string preferredGpuVendor = options.PreferredGPUVendor.ToLowerInvariant();
|
||||||
var devices = VulkanRenderer.GetPhysicalDevices(api);
|
var devices = VulkanRenderer.GetPhysicalDevices(api);
|
||||||
|
|
||||||
foreach (var device in devices)
|
foreach (var device in devices)
|
||||||
|
@ -520,10 +514,8 @@ namespace Ryujinx.Headless.SDL2
|
||||||
vulkanWindow.GetRequiredInstanceExtensions,
|
vulkanWindow.GetRequiredInstanceExtensions,
|
||||||
preferredGpuId);
|
preferredGpuId);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
return new OpenGLRenderer();
|
||||||
return new OpenGLRenderer();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options)
|
private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options)
|
||||||
|
@ -537,31 +529,31 @@ namespace Ryujinx.Headless.SDL2
|
||||||
renderer = new ThreadedRenderer(renderer);
|
renderer = new ThreadedRenderer(renderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
HLEConfiguration configuration = new HLEConfiguration(_virtualFileSystem,
|
HLEConfiguration configuration = new(_virtualFileSystem,
|
||||||
_libHacHorizonManager,
|
_libHacHorizonManager,
|
||||||
_contentManager,
|
_contentManager,
|
||||||
_accountManager,
|
_accountManager,
|
||||||
_userChannelPersistence,
|
_userChannelPersistence,
|
||||||
renderer,
|
renderer,
|
||||||
new SDL2HardwareDeviceDriver(),
|
new SDL2HardwareDeviceDriver(),
|
||||||
options.ExpandRam ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB,
|
options.ExpandRAM ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB,
|
||||||
window,
|
window,
|
||||||
options.SystemLanguage,
|
options.SystemLanguage,
|
||||||
options.SystemRegion,
|
options.SystemRegion,
|
||||||
!options.DisableVsync,
|
!options.DisableVSync,
|
||||||
!options.DisableDockedMode,
|
!options.DisableDockedMode,
|
||||||
!options.DisablePtc,
|
!options.DisablePTC,
|
||||||
options.EnableInternetAccess,
|
options.EnableInternetAccess,
|
||||||
!options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
|
!options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
|
||||||
options.FsGlobalAccessLogMode,
|
options.FsGlobalAccessLogMode,
|
||||||
options.SystemTimeOffset,
|
options.SystemTimeOffset,
|
||||||
options.SystemTimeZone,
|
options.SystemTimeZone,
|
||||||
options.MemoryManagerMode,
|
options.MemoryManagerMode,
|
||||||
options.IgnoreMissingServices,
|
options.IgnoreMissingServices,
|
||||||
options.AspectRatio,
|
options.AspectRatio,
|
||||||
options.AudioVolume,
|
options.AudioVolume,
|
||||||
options.UseHypervisor ?? true,
|
options.UseHypervisor ?? true,
|
||||||
options.MultiplayerLanInterfaceId);
|
options.MultiplayerLanInterfaceId);
|
||||||
|
|
||||||
return new Switch(configuration);
|
return new Switch(configuration);
|
||||||
}
|
}
|
||||||
|
@ -713,4 +705,4 @@ namespace Ryujinx.Headless.SDL2
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,4 +87,4 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_driver = null;
|
_driver = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Ryujinx.Common.Configuration;
|
using Ryujinx.Common.Configuration;
|
||||||
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Input;
|
using Ryujinx.Input;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
@ -14,7 +15,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
private const int CursorHideIdleTime = 5; // seconds
|
private const int CursorHideIdleTime = 5; // seconds
|
||||||
|
|
||||||
private bool _isDisposed;
|
private bool _isDisposed;
|
||||||
private HideCursorMode _hideCursorMode;
|
private readonly HideCursorMode _hideCursorMode;
|
||||||
private bool _isHidden;
|
private bool _isHidden;
|
||||||
private long _lastCursorMoveTime;
|
private long _lastCursorMoveTime;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public Vector2 CurrentPosition { get; private set; }
|
public Vector2 CurrentPosition { get; private set; }
|
||||||
public Vector2 Scroll { get; private set; }
|
public Vector2 Scroll { get; private set; }
|
||||||
public Size _clientSize;
|
public Size ClientSize;
|
||||||
|
|
||||||
public SDL2MouseDriver(HideCursorMode hideCursorMode)
|
public SDL2MouseDriver(HideCursorMode hideCursorMode)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +32,11 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
if (_hideCursorMode == HideCursorMode.Always)
|
if (_hideCursorMode == HideCursorMode.Always)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
if (SDL_ShowCursor(SDL_DISABLE) != SDL_DISABLE)
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, "Failed to disable the cursor.");
|
||||||
|
}
|
||||||
|
|
||||||
_isHidden = true;
|
_isHidden = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +51,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public void UpdatePosition()
|
public void UpdatePosition()
|
||||||
{
|
{
|
||||||
SDL_GetMouseState(out int posX, out int posY);
|
_ = SDL_GetMouseState(out int posX, out int posY);
|
||||||
Vector2 position = new(posX, posY);
|
Vector2 position = new(posX, posY);
|
||||||
|
|
||||||
if (CurrentPosition != position)
|
if (CurrentPosition != position)
|
||||||
|
@ -71,7 +76,11 @@ namespace Ryujinx.Headless.SDL2
|
||||||
{
|
{
|
||||||
if (!_isHidden)
|
if (!_isHidden)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
if (SDL_ShowCursor(SDL_DISABLE) != SDL_DISABLE)
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, "Failed to disable the cursor.");
|
||||||
|
}
|
||||||
|
|
||||||
_isHidden = true;
|
_isHidden = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,7 +88,11 @@ namespace Ryujinx.Headless.SDL2
|
||||||
{
|
{
|
||||||
if (_isHidden)
|
if (_isHidden)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_ENABLE);
|
if (SDL_ShowCursor(SDL_ENABLE) != SDL_ENABLE)
|
||||||
|
{
|
||||||
|
Logger.Error?.PrintMsg(LogClass.Application, "Failed to enable the cursor.");
|
||||||
|
}
|
||||||
|
|
||||||
_isHidden = false;
|
_isHidden = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,7 +131,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public void SetClientSize(int width, int height)
|
public void SetClientSize(int width, int height)
|
||||||
{
|
{
|
||||||
_clientSize = new Size(width, height);
|
ClientSize = new Size(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsButtonPressed(MouseButton button)
|
public bool IsButtonPressed(MouseButton button)
|
||||||
|
@ -128,7 +141,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public Size GetClientSize()
|
public Size GetClientSize()
|
||||||
{
|
{
|
||||||
return _clientSize;
|
return ClientSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DriverName => "SDL2";
|
public string DriverName => "SDL2";
|
||||||
|
@ -162,4 +175,4 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_isDisposed = true;
|
_isDisposed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace Ryujinx.Headless.SDL2.Vulkan
|
||||||
{
|
{
|
||||||
class VulkanWindow : WindowBase
|
class VulkanWindow : WindowBase
|
||||||
{
|
{
|
||||||
private GraphicsDebugLevel _glLogLevel;
|
private readonly GraphicsDebugLevel _glLogLevel;
|
||||||
|
|
||||||
public VulkanWindow(
|
public VulkanWindow(
|
||||||
InputManager inputManager,
|
InputManager inputManager,
|
||||||
|
@ -33,16 +33,16 @@ namespace Ryujinx.Headless.SDL2.Vulkan
|
||||||
MouseDriver.SetClientSize(DefaultWidth, DefaultHeight);
|
MouseDriver.SetClientSize(DefaultWidth, DefaultHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void BasicInvoke(Action action)
|
private static void BasicInvoke(Action action)
|
||||||
{
|
{
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe IntPtr CreateWindowSurface(IntPtr instance)
|
public IntPtr CreateWindowSurface(IntPtr instance)
|
||||||
{
|
{
|
||||||
ulong surfaceHandle = 0;
|
ulong surfaceHandle = 0;
|
||||||
|
|
||||||
Action createSurface = () =>
|
void CreateSurface()
|
||||||
{
|
{
|
||||||
if (SDL_Vulkan_CreateSurface(WindowHandle, instance, out surfaceHandle) == SDL_bool.SDL_FALSE)
|
if (SDL_Vulkan_CreateSurface(WindowHandle, instance, out surfaceHandle) == SDL_bool.SDL_FALSE)
|
||||||
{
|
{
|
||||||
|
@ -52,15 +52,15 @@ namespace Ryujinx.Headless.SDL2.Vulkan
|
||||||
|
|
||||||
throw new Exception(errorMessage);
|
throw new Exception(errorMessage);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
if (SDL2Driver.MainThreadDispatcher != null)
|
if (SDL2Driver.MainThreadDispatcher != null)
|
||||||
{
|
{
|
||||||
SDL2Driver.MainThreadDispatcher(createSurface);
|
SDL2Driver.MainThreadDispatcher(CreateSurface);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
createSurface();
|
CreateSurface();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (IntPtr)surfaceHandle;
|
return (IntPtr)surfaceHandle;
|
||||||
|
@ -101,4 +101,4 @@ namespace Ryujinx.Headless.SDL2.Vulkan
|
||||||
|
|
||||||
protected override void SwapBuffers() { }
|
protected override void SwapBuffers() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,8 @@ using Ryujinx.Common.Configuration.Hid;
|
||||||
using Ryujinx.Common.Logging;
|
using Ryujinx.Common.Logging;
|
||||||
using Ryujinx.Graphics.GAL;
|
using Ryujinx.Graphics.GAL;
|
||||||
using Ryujinx.Graphics.GAL.Multithreading;
|
using Ryujinx.Graphics.GAL.Multithreading;
|
||||||
|
using Ryujinx.Graphics.Gpu;
|
||||||
|
using Ryujinx.Graphics.OpenGL;
|
||||||
using Ryujinx.HLE.HOS.Applets;
|
using Ryujinx.HLE.HOS.Applets;
|
||||||
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
|
using Ryujinx.HLE.HOS.Services.Am.AppletOE.ApplicationProxyService.ApplicationProxy.Types;
|
||||||
using Ryujinx.HLE.Ui;
|
using Ryujinx.HLE.Ui;
|
||||||
|
@ -30,7 +32,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
private const SDL_WindowFlags DefaultFlags = SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI | SDL_WindowFlags.SDL_WINDOW_RESIZABLE | SDL_WindowFlags.SDL_WINDOW_INPUT_FOCUS | SDL_WindowFlags.SDL_WINDOW_SHOWN;
|
private const SDL_WindowFlags DefaultFlags = SDL_WindowFlags.SDL_WINDOW_ALLOW_HIGHDPI | SDL_WindowFlags.SDL_WINDOW_RESIZABLE | SDL_WindowFlags.SDL_WINDOW_INPUT_FOCUS | SDL_WindowFlags.SDL_WINDOW_SHOWN;
|
||||||
private const int TargetFps = 60;
|
private const int TargetFps = 60;
|
||||||
|
|
||||||
private static ConcurrentQueue<Action> MainThreadActions = new ConcurrentQueue<Action>();
|
private static readonly ConcurrentQueue<Action> _mainThreadActions = new();
|
||||||
|
|
||||||
[LibraryImport("SDL2")]
|
[LibraryImport("SDL2")]
|
||||||
// TODO: Remove this as soon as SDL2-CS was updated to expose this method publicly
|
// TODO: Remove this as soon as SDL2-CS was updated to expose this method publicly
|
||||||
|
@ -38,7 +40,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public static void QueueMainThreadAction(Action action)
|
public static void QueueMainThreadAction(Action action)
|
||||||
{
|
{
|
||||||
MainThreadActions.Enqueue(action);
|
_mainThreadActions.Enqueue(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NpadManager NpadManager { get; }
|
public NpadManager NpadManager { get; }
|
||||||
|
@ -55,9 +57,9 @@ namespace Ryujinx.Headless.SDL2
|
||||||
public int Height { get; private set; }
|
public int Height { get; private set; }
|
||||||
|
|
||||||
protected SDL2MouseDriver MouseDriver;
|
protected SDL2MouseDriver MouseDriver;
|
||||||
private InputManager _inputManager;
|
private readonly InputManager _inputManager;
|
||||||
private IKeyboard _keyboardInterface;
|
private readonly IKeyboard _keyboardInterface;
|
||||||
private GraphicsDebugLevel _glLogLevel;
|
private readonly GraphicsDebugLevel _glLogLevel;
|
||||||
private readonly Stopwatch _chrono;
|
private readonly Stopwatch _chrono;
|
||||||
private readonly long _ticksPerFrame;
|
private readonly long _ticksPerFrame;
|
||||||
private readonly CancellationTokenSource _gpuCancellationTokenSource;
|
private readonly CancellationTokenSource _gpuCancellationTokenSource;
|
||||||
|
@ -71,8 +73,8 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
private string _gpuVendorName;
|
private string _gpuVendorName;
|
||||||
|
|
||||||
private AspectRatio _aspectRatio;
|
private readonly AspectRatio _aspectRatio;
|
||||||
private bool _enableMouse;
|
private readonly bool _enableMouse;
|
||||||
|
|
||||||
public WindowBase(
|
public WindowBase(
|
||||||
InputManager inputManager,
|
InputManager inputManager,
|
||||||
|
@ -192,9 +194,6 @@ namespace Ryujinx.Headless.SDL2
|
||||||
case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
|
case SDL_WindowEventID.SDL_WINDOWEVENT_CLOSE:
|
||||||
Exit();
|
Exit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -260,7 +259,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
if (_ticks >= _ticksPerFrame)
|
if (_ticks >= _ticksPerFrame)
|
||||||
{
|
{
|
||||||
string dockedMode = Device.System.State.DockedMode ? "Docked" : "Handheld";
|
string dockedMode = Device.System.State.DockedMode ? "Docked" : "Handheld";
|
||||||
float scale = Graphics.Gpu.GraphicsConfig.ResScale;
|
float scale = GraphicsConfig.ResScale;
|
||||||
if (scale != 1)
|
if (scale != 1)
|
||||||
{
|
{
|
||||||
dockedMode += $" ({scale}x)";
|
dockedMode += $" ({scale}x)";
|
||||||
|
@ -309,9 +308,9 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_exitEvent.Dispose();
|
_exitEvent.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ProcessMainThreadQueue()
|
public static void ProcessMainThreadQueue()
|
||||||
{
|
{
|
||||||
while (MainThreadActions.TryDequeue(out Action action))
|
while (_mainThreadActions.TryDequeue(out Action action))
|
||||||
{
|
{
|
||||||
action();
|
action();
|
||||||
}
|
}
|
||||||
|
@ -334,7 +333,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
_exitEvent.Set();
|
_exitEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NVStutterWorkaround()
|
private void NvidiaStutterWorkaround()
|
||||||
{
|
{
|
||||||
while (_isActive)
|
while (_isActive)
|
||||||
{
|
{
|
||||||
|
@ -348,7 +347,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
// TODO: This should be removed when the issue with the GateThread is resolved.
|
// TODO: This should be removed when the issue with the GateThread is resolved.
|
||||||
|
|
||||||
ThreadPool.QueueUserWorkItem((state) => { });
|
ThreadPool.QueueUserWorkItem(state => { });
|
||||||
Thread.Sleep(300);
|
Thread.Sleep(300);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -396,20 +395,20 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
InitializeWindow();
|
InitializeWindow();
|
||||||
|
|
||||||
Thread renderLoopThread = new Thread(Render)
|
Thread renderLoopThread = new(Render)
|
||||||
{
|
{
|
||||||
Name = "GUI.RenderLoop"
|
Name = "GUI.RenderLoop",
|
||||||
};
|
};
|
||||||
renderLoopThread.Start();
|
renderLoopThread.Start();
|
||||||
|
|
||||||
Thread nvStutterWorkaround = null;
|
Thread nvidiaStutterWorkaround = null;
|
||||||
if (Renderer is Graphics.OpenGL.OpenGLRenderer)
|
if (Renderer is OpenGLRenderer)
|
||||||
{
|
{
|
||||||
nvStutterWorkaround = new Thread(NVStutterWorkaround)
|
nvidiaStutterWorkaround = new Thread(NvidiaStutterWorkaround)
|
||||||
{
|
{
|
||||||
Name = "GUI.NVStutterWorkaround"
|
Name = "GUI.NvidiaStutterWorkaround",
|
||||||
};
|
};
|
||||||
nvStutterWorkaround.Start();
|
nvidiaStutterWorkaround.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainLoop();
|
MainLoop();
|
||||||
|
@ -418,7 +417,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
// We only need to wait for all commands submitted during the main gpu loop to be processed.
|
||||||
_gpuDoneEvent.WaitOne();
|
_gpuDoneEvent.WaitOne();
|
||||||
_gpuDoneEvent.Dispose();
|
_gpuDoneEvent.Dispose();
|
||||||
nvStutterWorkaround?.Join();
|
nvidiaStutterWorkaround?.Join();
|
||||||
|
|
||||||
Exit();
|
Exit();
|
||||||
}
|
}
|
||||||
|
@ -465,13 +464,13 @@ namespace Ryujinx.Headless.SDL2
|
||||||
|
|
||||||
public bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText)
|
public bool DisplayErrorAppletDialog(string title, string message, string[] buttonsText)
|
||||||
{
|
{
|
||||||
SDL_MessageBoxData data = new SDL_MessageBoxData
|
SDL_MessageBoxData data = new()
|
||||||
{
|
{
|
||||||
title = title,
|
title = title,
|
||||||
message = message,
|
message = message,
|
||||||
buttons = new SDL_MessageBoxButtonData[buttonsText.Length],
|
buttons = new SDL_MessageBoxButtonData[buttonsText.Length],
|
||||||
numbuttons = buttonsText.Length,
|
numbuttons = buttonsText.Length,
|
||||||
window = WindowHandle
|
window = WindowHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i < buttonsText.Length; i++)
|
for (int i = 0; i < buttonsText.Length; i++)
|
||||||
|
@ -479,7 +478,7 @@ namespace Ryujinx.Headless.SDL2
|
||||||
data.buttons[i] = new SDL_MessageBoxButtonData
|
data.buttons[i] = new SDL_MessageBoxButtonData
|
||||||
{
|
{
|
||||||
buttonid = i,
|
buttonid = i,
|
||||||
text = buttonsText[i]
|
text = buttonsText[i],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,4 +508,4 @@ namespace Ryujinx.Headless.SDL2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue