mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-06-07 04:49:15 +00:00
Memory changes 3 (ryubing/ryujinx!202)
See merge request ryubing/ryujinx!202
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.Input
|
||||
@@ -28,7 +29,8 @@ namespace Ryujinx.Input
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
static KeyboardStateSnapshot GetStateSnapshot(IKeyboard keyboard)
|
||||
{
|
||||
bool[] keysState = new bool[(int)Key.Count];
|
||||
|
||||
bool[] keysState = ArrayPool<bool>.Shared.Rent((int)Key.Count);
|
||||
|
||||
for (Key key = 0; key < Key.Count; key++)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Buffers;
|
||||
using System.Drawing;
|
||||
using System.Numerics;
|
||||
|
||||
@@ -47,7 +48,7 @@ namespace Ryujinx.Input
|
||||
/// <returns>A snaphost of the state of the mouse.</returns>
|
||||
public static MouseStateSnapshot GetMouseStateSnapshot(IMouse mouse)
|
||||
{
|
||||
bool[] buttons = new bool[(int)MouseButton.Count];
|
||||
bool[] buttons = ArrayPool<bool>.Shared.Rent((int)MouseButton.Count);
|
||||
|
||||
mouse.Buttons.CopyTo(buttons, 0);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Ryujinx.Input
|
||||
/// </summary>
|
||||
public class KeyboardStateSnapshot
|
||||
{
|
||||
private readonly bool[] _keysState;
|
||||
public readonly bool[] KeysState;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new <see cref="KeyboardStateSnapshot"/>.
|
||||
@@ -15,7 +15,7 @@ namespace Ryujinx.Input
|
||||
/// <param name="keysState">The keys state</param>
|
||||
public KeyboardStateSnapshot(bool[] keysState)
|
||||
{
|
||||
_keysState = keysState;
|
||||
KeysState = keysState;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -24,6 +24,6 @@ namespace Ryujinx.Input
|
||||
/// <param name="key">The key</param>
|
||||
/// <returns>True if the given key is pressed</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsPressed(Key key) => _keysState[(int)key];
|
||||
public bool IsPressed(Key key) => KeysState[(int)key];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Ryujinx.Input
|
||||
/// </summary>
|
||||
public class MouseStateSnapshot
|
||||
{
|
||||
private readonly bool[] _buttonState;
|
||||
public readonly bool[] ButtonState;
|
||||
|
||||
/// <summary>
|
||||
/// The position of the mouse cursor
|
||||
@@ -28,7 +28,7 @@ namespace Ryujinx.Input
|
||||
/// <param name="scroll">The scroll delta</param>
|
||||
public MouseStateSnapshot(bool[] buttonState, Vector2 position, Vector2 scroll)
|
||||
{
|
||||
_buttonState = buttonState;
|
||||
ButtonState = buttonState;
|
||||
|
||||
Position = position;
|
||||
Scroll = scroll;
|
||||
@@ -40,6 +40,6 @@ namespace Ryujinx.Input
|
||||
/// <param name="button">The button</param>
|
||||
/// <returns>True if the given button is pressed</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool IsPressed(MouseButton button) => _buttonState[(int)button];
|
||||
public bool IsPressed(MouseButton button) => ButtonState[(int)button];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user