Skip to content

Commit

Permalink
headless: Add Ignore Controller Applet as a configurable option
Browse files Browse the repository at this point in the history
  • Loading branch information
GreemDev committed Nov 10, 2024
1 parent 4aae82b commit 9c82d98
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
5 changes: 3 additions & 2 deletions src/Ryujinx.Headless.SDL2/OpenGL/OpenGLWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ public OpenGLWindow(
GraphicsDebugLevel glLogLevel,
AspectRatio aspectRatio,
bool enableMouse,
HideCursorMode hideCursorMode)
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursorMode)
HideCursorMode hideCursorMode,
bool ignoreControllerApplet)
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursorMode, ignoreControllerApplet)
{
_glLogLevel = glLogLevel;
}
Expand Down
3 changes: 3 additions & 0 deletions src/Ryujinx.Headless.SDL2/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ public class Options

[Option("ignore-missing-services", Required = false, Default = false, HelpText = "Enable ignoring missing services.")]
public bool IgnoreMissingServices { get; set; }

[Option("ignore-controller-applet", Required = false, Default = false, HelpText = "Enable ignoring the controller applet when your game loses connection to your controller.")]
public bool IgnoreControllerApplet { get; set; }

// Values

Expand Down
7 changes: 3 additions & 4 deletions src/Ryujinx.Headless.SDL2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -444,8 +444,7 @@ static void LoadPlayerConfiguration(string inputProfileName, string inputId, Pla
{
Logger.AddTarget(new AsyncLogTargetWrapper(
new FileLogTarget("file", logFile),
1000,
AsyncLogTargetOverflowAction.Block
1000
));
}
else
Expand Down Expand Up @@ -506,8 +505,8 @@ private static void ProgressHandler<T>(T state, int current, int total) where T
private static WindowBase CreateWindow(Options options)
{
return options.GraphicsBackend == GraphicsBackend.Vulkan
? new VulkanWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode)
: new OpenGLWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode);
? new VulkanWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode, options.IgnoreControllerApplet)
: new OpenGLWindow(_inputManager, options.LoggingGraphicsDebugLevel, options.AspectRatio, options.EnableMouse, options.HideCursorMode, options.IgnoreControllerApplet);
}

private static IRenderer CreateRenderer(Options options, WindowBase window)
Expand Down
5 changes: 3 additions & 2 deletions src/Ryujinx.Headless.SDL2/Vulkan/VulkanWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public VulkanWindow(
GraphicsDebugLevel glLogLevel,
AspectRatio aspectRatio,
bool enableMouse,
HideCursorMode hideCursorMode)
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursorMode)
HideCursorMode hideCursorMode,
bool ignoreControllerApplet)
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursorMode, ignoreControllerApplet)
{
_glLogLevel = glLogLevel;
}
Expand Down
7 changes: 6 additions & 1 deletion src/Ryujinx.Headless.SDL2/WindowBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,15 @@ public static void QueueMainThreadAction(Action action)

private readonly AspectRatio _aspectRatio;
private readonly bool _enableMouse;
private readonly bool _ignoreControllerApplet;

public WindowBase(
InputManager inputManager,
GraphicsDebugLevel glLogLevel,
AspectRatio aspectRatio,
bool enableMouse,
HideCursorMode hideCursorMode)
HideCursorMode hideCursorMode,
bool ignoreControllerApplet)
{
MouseDriver = new SDL2MouseDriver(hideCursorMode);
_inputManager = inputManager;
Expand All @@ -108,6 +110,7 @@ public WindowBase(
_gpuDoneEvent = new ManualResetEvent(false);
_aspectRatio = aspectRatio;
_enableMouse = enableMouse;
_ignoreControllerApplet = ignoreControllerApplet;
HostUITheme = new HeadlessHostUiTheme();

SDL2Driver.Instance.Initialize();
Expand Down Expand Up @@ -484,6 +487,8 @@ public bool DisplayMessageDialog(string title, string message)

public bool DisplayMessageDialog(ControllerAppletUIArgs args)
{
if (_ignoreControllerApplet) return false;

string playerCount = args.PlayerCountMin == args.PlayerCountMax ? $"exactly {args.PlayerCountMin}" : $"{args.PlayerCountMin}-{args.PlayerCountMax}";

string message = $"Application requests {playerCount} {"player".ToQuantity(args.PlayerCountMin + args.PlayerCountMax, ShowQuantityAs.None)} with:\n\n"
Expand Down

0 comments on commit 9c82d98

Please sign in to comment.