MouseStateSnapshot.cs 984 B

12345678910111213141516171819202122232425262728293031323334
  1. using System.Numerics;
  2. using System.Runtime.CompilerServices;
  3. namespace Ryujinx.Input
  4. {
  5. /// <summary>
  6. /// A snapshot of a <see cref="IMouse"/>.
  7. /// </summary>
  8. public class MouseStateSnapshot
  9. {
  10. private bool[] _buttonState;
  11. public Vector2 Position { get; }
  12. /// <summary>
  13. /// Create a new <see cref="MouseStateSnapshot"/>.
  14. /// </summary>
  15. /// <param name="buttonState">The keys state</param>
  16. public MouseStateSnapshot(bool[] buttonState, Vector2 position)
  17. {
  18. _buttonState = buttonState;
  19. Position = position;
  20. }
  21. /// <summary>
  22. /// Check if a given button is pressed.
  23. /// </summary>
  24. /// <param name="button">The button</param>
  25. /// <returns>True if the given button is pressed</returns>
  26. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  27. public bool IsPressed(MouseButton button) => _buttonState[(int)button];
  28. }
  29. }