Sdl backend (#670)

* [audio] added sdl audio backend and in-tree atrac9 decoder

* [input] replaced per-platform pad readers with sdl gamepad input

* [video] added sdl window and host display plumbing

* [gui] added host display options and per-game render settings

* [bink] synced host movie playback to the guest audio clock

* [cpu] hooked windows write faults into guest image tracking

* [perf] added guest and render profiling, reserved host cpu lanes

* [kernel] fixed stale pthread mutex handle alias

* [host] wired the sdl session, save-data paths and project references

* [audio] hoisted ajm trace stackalloc out of its loop

* [video] Add guest image sync setting

* [build] Strip native symbols

* reuse
This commit is contained in:
Berk
2026-07-28 03:33:26 +03:00
committed by GitHub
parent b4cc5f88ca
commit 2b6bd5a532
111 changed files with 9846 additions and 4479 deletions
@@ -0,0 +1,85 @@
// Copyright (C) 2026 SharpEmu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
using SharpEmu.HLE.Host;
using SDL;
using static SDL.SDL3;
namespace SharpEmu.Libs.Pad;
/// <summary>Cross-platform SDL gamepad polling for launcher navigation.</summary>
public static unsafe class SdlLauncherGamepad
{
private const SDL_InitFlags InitFlags = SDL_InitFlags.SDL_INIT_GAMEPAD;
private static SDL_Gamepad* _gamepad;
private static bool _initialized;
public static void EnsureStarted()
{
if (_initialized)
{
return;
}
SdlGamepadStateReader.EnableSonyHidApi();
if (!SDL_InitSubSystem(InitFlags))
{
Console.Error.WriteLine("[GUI][WARN] SDL gamepad initialization failed.");
return;
}
_initialized = true;
OpenFirstGamepad();
}
public static bool TryGetState(out HostGamepadState state)
{
state = default;
if (!_initialized)
{
return false;
}
SDL_UpdateGamepads();
if (_gamepad is not null && !SDL_GamepadConnected(_gamepad))
{
SDL_CloseGamepad(_gamepad);
_gamepad = null;
}
if (_gamepad is null)
{
OpenFirstGamepad();
}
if (_gamepad is null)
{
return false;
}
state = SdlGamepadStateReader.Read(_gamepad);
return true;
}
public static void Shutdown()
{
if (!_initialized)
{
return;
}
if (_gamepad is not null)
{
SDL_CloseGamepad(_gamepad);
_gamepad = null;
}
SDL_QuitSubSystem(InitFlags);
_initialized = false;
}
private static void OpenFirstGamepad()
{
_gamepad = SdlGamepadStateReader.OpenPreferredGamepad();
}
}