mirror of
https://github.com/par274/sharpemu.git
synced 2026-07-31 06:59:45 +08:00
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:
@@ -28,8 +28,44 @@ public enum HostGamepadButtons : uint
|
||||
R3 = 1 << 13,
|
||||
Options = 1 << 14,
|
||||
TouchPad = 1 << 15,
|
||||
Create = 1 << 16,
|
||||
Ps = 1 << 17,
|
||||
Mic = 1 << 18,
|
||||
}
|
||||
|
||||
public enum HostGamepadType : byte
|
||||
{
|
||||
Generic,
|
||||
DualShock4,
|
||||
DualSense,
|
||||
}
|
||||
|
||||
public enum HostGamepadConnection : byte
|
||||
{
|
||||
Unknown,
|
||||
Wired,
|
||||
Wireless,
|
||||
}
|
||||
|
||||
public readonly record struct HostMotionState(
|
||||
bool Available,
|
||||
float AccelerationX,
|
||||
float AccelerationY,
|
||||
float AccelerationZ,
|
||||
float AngularVelocityX,
|
||||
float AngularVelocityY,
|
||||
float AngularVelocityZ);
|
||||
|
||||
public readonly record struct HostTouchPoint(
|
||||
bool Active,
|
||||
byte Id,
|
||||
float X,
|
||||
float Y);
|
||||
|
||||
public readonly record struct HostTouchState(
|
||||
HostTouchPoint First,
|
||||
HostTouchPoint Second);
|
||||
|
||||
/// <summary>
|
||||
/// Snapshot of one host gamepad: sticks are 0..255 with 128 centered and Y growing
|
||||
/// downward; triggers 0..255. Unmanaged on purpose so per-frame polls can stackalloc
|
||||
@@ -43,4 +79,57 @@ public readonly record struct HostGamepadState(
|
||||
byte RightX,
|
||||
byte RightY,
|
||||
byte LeftTrigger,
|
||||
byte RightTrigger);
|
||||
byte RightTrigger,
|
||||
HostGamepadType Type = HostGamepadType.Generic,
|
||||
HostGamepadConnection Connection = HostGamepadConnection.Unknown,
|
||||
HostMotionState Motion = default,
|
||||
HostTouchState Touch = default,
|
||||
byte BatteryPercent = 0);
|
||||
|
||||
/// <summary>A complete 11-byte DualSense adaptive-trigger command.</summary>
|
||||
public readonly record struct HostAdaptiveTriggerEffect(
|
||||
byte B0,
|
||||
byte B1,
|
||||
byte B2,
|
||||
byte B3,
|
||||
byte B4,
|
||||
byte B5,
|
||||
byte B6,
|
||||
byte B7,
|
||||
byte B8,
|
||||
byte B9,
|
||||
byte B10,
|
||||
byte FallbackStrength = 0)
|
||||
{
|
||||
public static HostAdaptiveTriggerEffect FromBytes(ReadOnlySpan<byte> source, byte fallbackStrength = 0)
|
||||
{
|
||||
if (source.Length < 11)
|
||||
{
|
||||
throw new ArgumentException("Adaptive-trigger source is too small.", nameof(source));
|
||||
}
|
||||
|
||||
return new HostAdaptiveTriggerEffect(
|
||||
source[0], source[1], source[2], source[3], source[4], source[5],
|
||||
source[6], source[7], source[8], source[9], source[10], fallbackStrength);
|
||||
}
|
||||
|
||||
public void CopyTo(Span<byte> destination)
|
||||
{
|
||||
if (destination.Length < 11)
|
||||
{
|
||||
throw new ArgumentException("Adaptive-trigger destination is too small.", nameof(destination));
|
||||
}
|
||||
|
||||
destination[0] = B0;
|
||||
destination[1] = B1;
|
||||
destination[2] = B2;
|
||||
destination[3] = B3;
|
||||
destination[4] = B4;
|
||||
destination[5] = B5;
|
||||
destination[6] = B6;
|
||||
destination[7] = B7;
|
||||
destination[8] = B8;
|
||||
destination[9] = B9;
|
||||
destination[10] = B10;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user