See merge request ryubing/ryujinx!202
This commit is contained in:
LotP
2025-10-30 20:55:58 -05:00
parent ab7aeee67b
commit 92b61f9d73
43 changed files with 686 additions and 315 deletions

View File

@@ -5,6 +5,7 @@ using Ryujinx.Common.Configuration.Hid.Controller.Motion;
using Ryujinx.Common.Logging;
using Ryujinx.HLE.HOS.Services.Hid;
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Numerics;
using System.Runtime.CompilerServices;
@@ -291,7 +292,7 @@ namespace Ryujinx.Input.HLE
{
if (controllerConfig.Motion.MotionBackend == MotionInputBackendType.GamepadDriver)
{
if (gamepad.Features.HasFlag(GamepadFeaturesFlag.Motion))
if ((gamepad.Features & GamepadFeaturesFlag.Motion) != 0)
{
Vector3 accelerometer = gamepad.GetMotionData(MotionInputId.Accelerometer);
Vector3 gyroscope = gamepad.GetMotionData(MotionInputId.Gyroscope);
@@ -531,6 +532,8 @@ namespace Ryujinx.Input.HLE
hidKeyboard.Modifier |= value << entry.Target;
}
ArrayPool<bool>.Shared.Return(keyboardState.KeysState);
return hidKeyboard;

View File

@@ -1,8 +1,10 @@
using Ryujinx.Common;
using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Hid.Controller;
using Ryujinx.Common.Configuration.Hid.Keyboard;
using Ryujinx.HLE.HOS.Services.Hid;
using System;
using System.Buffers;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -18,6 +20,7 @@ namespace Ryujinx.Input.HLE
{
public class NpadManager : IDisposable
{
private static readonly ObjectPool<List<SixAxisInput>> _hleMotionStatesPool = new (() => new List<SixAxisInput>(NpadDevices.MaxControllers));
private readonly CemuHookClient _cemuHookClient;
private readonly Lock _lock = new();
@@ -215,7 +218,7 @@ namespace Ryujinx.Input.HLE
lock (_lock)
{
List<GamepadInput> hleInputStates = [];
List<SixAxisInput> hleMotionStates = new(NpadDevices.MaxControllers);
List<SixAxisInput> hleMotionStates = _hleMotionStatesPool.Allocate();
KeyboardInput? hleKeyboardInput = null;
@@ -317,6 +320,8 @@ namespace Ryujinx.Input.HLE
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);
ArrayPool<bool>.Shared.Return(mouseInput.ButtonState);
}
else
{
@@ -324,6 +329,8 @@ namespace Ryujinx.Input.HLE
}
_device.TamperMachine.UpdateInput(hleInputStates);
_hleMotionStatesPool.Release(hleMotionStates);
}
}