Follow DPA advice.
This commit is contained in:
parent
5e69e99f23
commit
7e511dacd3
@ -22,7 +22,6 @@ namespace Ryujinx.Audio.Backends.SDL3
|
|||||||
private readonly int _bytesPerFrame;
|
private readonly int _bytesPerFrame;
|
||||||
private bool _started;
|
private bool _started;
|
||||||
private float _volume;
|
private float _volume;
|
||||||
private readonly SDL_AudioFormat _nativeSampleFormat;
|
|
||||||
|
|
||||||
public SDL3HardwareDeviceSession(SDL3HardwareDeviceDriver driver, IVirtualMemoryManager memoryManager,
|
public SDL3HardwareDeviceSession(SDL3HardwareDeviceDriver driver, IVirtualMemoryManager memoryManager,
|
||||||
SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) : base(
|
SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount) : base(
|
||||||
@ -34,7 +33,6 @@ namespace Ryujinx.Audio.Backends.SDL3
|
|||||||
_ringBuffer = new DynamicRingBuffer();
|
_ringBuffer = new DynamicRingBuffer();
|
||||||
_callbackDelegate = Update;
|
_callbackDelegate = Update;
|
||||||
_bytesPerFrame = BackendHelper.GetSampleSize(RequestedSampleFormat) * (int)RequestedChannelCount;
|
_bytesPerFrame = BackendHelper.GetSampleSize(RequestedSampleFormat) * (int)RequestedChannelCount;
|
||||||
_nativeSampleFormat = SDL3HardwareDeviceDriver.GetSDL3Format(RequestedSampleFormat);
|
|
||||||
_started = false;
|
_started = false;
|
||||||
_volume = 1f;
|
_volume = 1f;
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
private bool _enableKeyboard;
|
private bool _enableKeyboard;
|
||||||
private bool _enableMouse;
|
private bool _enableMouse;
|
||||||
private Switch _device;
|
private Switch _device;
|
||||||
|
private readonly List<GamepadInput> _hleInputStates;
|
||||||
|
private readonly List<SixAxisInput> _hleMotionStates;
|
||||||
|
|
||||||
public NpadManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver, IGamepadDriver mouseDriver)
|
public NpadManager(IGamepadDriver keyboardDriver, IGamepadDriver gamepadDriver, IGamepadDriver mouseDriver)
|
||||||
{
|
{
|
||||||
@ -48,6 +50,9 @@ namespace Ryujinx.Input.HLE
|
|||||||
_mouseDriver = mouseDriver;
|
_mouseDriver = mouseDriver;
|
||||||
_inputConfig = [];
|
_inputConfig = [];
|
||||||
|
|
||||||
|
_hleInputStates = [];
|
||||||
|
_hleMotionStates = new List<SixAxisInput>(NpadDevices.MaxControllers);
|
||||||
|
|
||||||
_gamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
_gamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
|
||||||
_gamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
_gamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
|
||||||
}
|
}
|
||||||
@ -205,8 +210,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
List<GamepadInput> hleInputStates = [];
|
_hleInputStates.Clear();
|
||||||
List<SixAxisInput> hleMotionStates = new(NpadDevices.MaxControllers);
|
_hleMotionStates.Clear();
|
||||||
|
|
||||||
KeyboardInput? hleKeyboardInput = null;
|
KeyboardInput? hleKeyboardInput = null;
|
||||||
|
|
||||||
@ -248,14 +253,14 @@ namespace Ryujinx.Input.HLE
|
|||||||
inputState.PlayerId = playerIndex;
|
inputState.PlayerId = playerIndex;
|
||||||
motionState.Item1.PlayerId = playerIndex;
|
motionState.Item1.PlayerId = playerIndex;
|
||||||
|
|
||||||
hleInputStates.Add(inputState);
|
_hleInputStates.Add(inputState);
|
||||||
hleMotionStates.Add(motionState.Item1);
|
_hleMotionStates.Add(motionState.Item1);
|
||||||
|
|
||||||
if (isJoyconPair && !motionState.Item2.Equals(default))
|
if (isJoyconPair && !motionState.Item2.Equals(default))
|
||||||
{
|
{
|
||||||
motionState.Item2.PlayerId = playerIndex;
|
motionState.Item2.PlayerId = playerIndex;
|
||||||
|
|
||||||
hleMotionStates.Add(motionState.Item2);
|
_hleMotionStates.Add(motionState.Item2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,8 +269,8 @@ namespace Ryujinx.Input.HLE
|
|||||||
hleKeyboardInput = NpadController.GetHLEKeyboardInput(_keyboardDriver);
|
hleKeyboardInput = NpadController.GetHLEKeyboardInput(_keyboardDriver);
|
||||||
}
|
}
|
||||||
|
|
||||||
_device.Hid.Npads.Update(hleInputStates);
|
_device.Hid.Npads.Update(_hleInputStates);
|
||||||
_device.Hid.Npads.UpdateSixAxis(hleMotionStates);
|
_device.Hid.Npads.UpdateSixAxis(_hleMotionStates);
|
||||||
|
|
||||||
if (hleKeyboardInput.HasValue)
|
if (hleKeyboardInput.HasValue)
|
||||||
{
|
{
|
||||||
@ -307,14 +312,15 @@ namespace Ryujinx.Input.HLE
|
|||||||
|
|
||||||
Vector2 position = IMouse.GetScreenPosition(mouseInput.Position, mouse.ClientSize, aspectRatio);
|
Vector2 position = IMouse.GetScreenPosition(mouseInput.Position, mouse.ClientSize, aspectRatio);
|
||||||
|
|
||||||
_device.Hid.Mouse.Update((int)position.X, (int)position.Y, buttons, (int)mouseInput.Scroll.X, (int)mouseInput.Scroll.Y, true);
|
_device.Hid.Mouse.Update((int)position.X, (int)position.Y, buttons, (int)mouseInput.Scroll.X,
|
||||||
|
(int)mouseInput.Scroll.Y, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_device.Hid.Mouse.Update(0, 0);
|
_device.Hid.Mouse.Update(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
_device.TamperMachine.UpdateInput(hleInputStates);
|
_device.TamperMachine.UpdateInput(_hleInputStates);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +143,8 @@ namespace Ryujinx.SDL3.Common
|
|||||||
{
|
{
|
||||||
OnJoyBatteryUpdated?.Invoke(evnt.jbattery.which, evnt.jbattery);
|
OnJoyBatteryUpdated?.Invoke(evnt.jbattery.which, evnt.jbattery);
|
||||||
}
|
}
|
||||||
else if (evnt.type is >= (uint)SDL_EventType.SDL_EVENT_WINDOW_FIRST and <= (uint)SDL_EventType.SDL_EVENT_WINDOW_LAST
|
else if (evnt.type is >= (uint)SDL_EventType.SDL_EVENT_WINDOW_FIRST
|
||||||
|
and <= (uint)SDL_EventType.SDL_EVENT_WINDOW_LAST
|
||||||
or (uint)SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN
|
or (uint)SDL_EventType.SDL_EVENT_MOUSE_BUTTON_DOWN
|
||||||
or (uint)SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP)
|
or (uint)SDL_EventType.SDL_EVENT_MOUSE_BUTTON_UP)
|
||||||
{
|
{
|
||||||
@ -153,23 +154,22 @@ namespace Ryujinx.SDL3.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void PollEventAction()
|
||||||
|
{
|
||||||
|
while (SDL_PollEvent(out SDL_Event evnt))
|
||||||
|
{
|
||||||
|
HandleSDLEvent(ref evnt);
|
||||||
|
}
|
||||||
|
}
|
||||||
private void EventWorker()
|
private void EventWorker()
|
||||||
{
|
{
|
||||||
const int WaitTimeMs = 10;
|
const int WaitTimeMs = 10;
|
||||||
|
|
||||||
using ManualResetEventSlim waitHandle = new(false);
|
|
||||||
while (_isRunning)
|
while (_isRunning)
|
||||||
{
|
{
|
||||||
MainThreadDispatcher?.Invoke(() =>
|
MainThreadDispatcher?.Invoke(PollEventAction);
|
||||||
{
|
|
||||||
while (SDL_PollEvent(out SDL_Event evnt))
|
|
||||||
{
|
|
||||||
HandleSDLEvent(ref evnt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
waitHandle.Wait(WaitTimeMs);
|
Thread.Sleep(WaitTimeMs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user