See merge request ryubing/ryujinx!234
This commit is contained in:
LotP
2025-12-06 17:19:19 -06:00
committed by GreemDev
parent fd7554425a
commit c3155fcadb
37 changed files with 563 additions and 677 deletions

View File

@@ -8,6 +8,8 @@ namespace Ryujinx.Input
/// </summary>
public interface IKeyboard : IGamepad
{
private static bool[] _keyState;
/// <summary>
/// Check if a given key is pressed on the keyboard.
/// </summary>
@@ -29,15 +31,17 @@ namespace Ryujinx.Input
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static KeyboardStateSnapshot GetStateSnapshot(IKeyboard keyboard)
{
if (_keyState is null)
{
_keyState = new bool[(int)Key.Count];
}
bool[] keysState = ArrayPool<bool>.Shared.Rent((int)Key.Count);
for (Key key = 0; key < Key.Count; key++)
{
keysState[(int)key] = keyboard.IsPressed(key);
_keyState[(int)key] = keyboard.IsPressed(key);
}
return new KeyboardStateSnapshot(keysState);
return new KeyboardStateSnapshot(_keyState);
}
}
}