KeyboardStateSnapshot.cs
1 using System.Runtime.CompilerServices; 2 3 namespace Ryujinx.Input 4 { 5 /// <summary> 6 /// A snapshot of a <see cref="IKeyboard"/>. 7 /// </summary> 8 public class KeyboardStateSnapshot 9 { 10 private readonly bool[] _keysState; 11 12 /// <summary> 13 /// Create a new <see cref="KeyboardStateSnapshot"/>. 14 /// </summary> 15 /// <param name="keysState">The keys state</param> 16 public KeyboardStateSnapshot(bool[] keysState) 17 { 18 _keysState = keysState; 19 } 20 21 /// <summary> 22 /// Check if a given key is pressed. 23 /// </summary> 24 /// <param name="key">The key</param> 25 /// <returns>True if the given key is pressed</returns> 26 [MethodImpl(MethodImplOptions.AggressiveInlining)] 27 public bool IsPressed(Key key) => _keysState[(int)key]; 28 } 29 }