mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-05-22 21:25:48 +00:00
Memory Changes 3.2 (ryubing/ryujinx!234)
See merge request ryubing/ryujinx!234
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user