KeyboardStateSnapshot.cs 845 B

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