mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-08-17 06:08:43 +02:00
* headless: Fix typos in command line options * Remove nullable from command line options Add EnableMacroHLE option Add HideCursorOnIdle option * headless: Adjust enable-ptc help text * headless: Use switch statement instead of if-else chain * headless: Improve formatting for long constructors * headless: Remove discards from SDL_ShowCursor() * headless: Add window icon * Fix hiding cursor on idle At least on Wayland, SDL2 doesn't produce any mouse motion events. * Add new command line args: BaseDataDir and UserProfile * headless: Read icon from embedded resource * headless: Skip SetWindowIcon() on Windows if dll isn't present * headless: Fix division by zero * headless: Fix command line options not working correctly * headless: Fix crash when viewing command line options * headless: Load window icon bmp from memory * Add comment to the workaround for SDL_LoadBMP_RW * headless: Enable logging to file by default * headless: Add 3 options for --hide-cursor Replaces --disable-hide-cursor-on-idle
104 lines
3.2 KiB
C#
104 lines
3.2 KiB
C#
using Ryujinx.Common.Configuration;
|
|
using Ryujinx.Common.Logging;
|
|
using Ryujinx.Input.HLE;
|
|
using Ryujinx.SDL2.Common;
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using static SDL2.SDL;
|
|
|
|
namespace Ryujinx.Headless.SDL2.Vulkan
|
|
{
|
|
class VulkanWindow : WindowBase
|
|
{
|
|
private GraphicsDebugLevel _glLogLevel;
|
|
|
|
public VulkanWindow(
|
|
InputManager inputManager,
|
|
GraphicsDebugLevel glLogLevel,
|
|
AspectRatio aspectRatio,
|
|
bool enableMouse,
|
|
HideCursor hideCursor)
|
|
: base(inputManager, glLogLevel, aspectRatio, enableMouse, hideCursor)
|
|
{
|
|
_glLogLevel = glLogLevel;
|
|
}
|
|
|
|
public override SDL_WindowFlags GetWindowFlags() => SDL_WindowFlags.SDL_WINDOW_VULKAN;
|
|
|
|
protected override void InitializeWindowRenderer() { }
|
|
|
|
protected override void InitializeRenderer()
|
|
{
|
|
Renderer?.Window.SetSize(DefaultWidth, DefaultHeight);
|
|
MouseDriver.SetClientSize(DefaultWidth, DefaultHeight);
|
|
}
|
|
|
|
private void BasicInvoke(Action action)
|
|
{
|
|
action();
|
|
}
|
|
|
|
public unsafe IntPtr CreateWindowSurface(IntPtr instance)
|
|
{
|
|
ulong surfaceHandle = 0;
|
|
|
|
Action createSurface = () =>
|
|
{
|
|
if (SDL_Vulkan_CreateSurface(WindowHandle, instance, out surfaceHandle) == SDL_bool.SDL_FALSE)
|
|
{
|
|
string errorMessage = $"SDL_Vulkan_CreateSurface failed with error \"{SDL_GetError()}\"";
|
|
|
|
Logger.Error?.Print(LogClass.Application, errorMessage);
|
|
|
|
throw new Exception(errorMessage);
|
|
}
|
|
};
|
|
|
|
if (SDL2Driver.MainThreadDispatcher != null)
|
|
{
|
|
SDL2Driver.MainThreadDispatcher(createSurface);
|
|
}
|
|
else
|
|
{
|
|
createSurface();
|
|
}
|
|
|
|
return (IntPtr)surfaceHandle;
|
|
}
|
|
|
|
public unsafe string[] GetRequiredInstanceExtensions()
|
|
{
|
|
if (SDL_Vulkan_GetInstanceExtensions(WindowHandle, out uint extensionsCount, IntPtr.Zero) == SDL_bool.SDL_TRUE)
|
|
{
|
|
IntPtr[] rawExtensions = new IntPtr[(int)extensionsCount];
|
|
string[] extensions = new string[(int)extensionsCount];
|
|
|
|
fixed (IntPtr* rawExtensionsPtr = rawExtensions)
|
|
{
|
|
if (SDL_Vulkan_GetInstanceExtensions(WindowHandle, out extensionsCount, (IntPtr)rawExtensionsPtr) == SDL_bool.SDL_TRUE)
|
|
{
|
|
for (int i = 0; i < extensions.Length; i++)
|
|
{
|
|
extensions[i] = Marshal.PtrToStringUTF8(rawExtensions[i]);
|
|
}
|
|
|
|
return extensions;
|
|
}
|
|
}
|
|
}
|
|
|
|
string errorMessage = $"SDL_Vulkan_GetInstanceExtensions failed with error \"{SDL_GetError()}\"";
|
|
|
|
Logger.Error?.Print(LogClass.Application, errorMessage);
|
|
|
|
throw new Exception(errorMessage);
|
|
}
|
|
|
|
protected override void FinalizeWindowRenderer()
|
|
{
|
|
Device.DisposeGpu();
|
|
}
|
|
|
|
protected override void SwapBuffers() { }
|
|
}
|
|
} |