MouseStateSnapshot.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. /// <summary>
  12. /// The position of the mouse cursor
  13. /// </summary>
  14. public Vector2 Position { get; }
  15. /// <summary>
  16. /// The scroll delta of the mouse
  17. /// </summary>
  18. public Vector2 Scroll { get; }
  19. /// <summary>
  20. /// Create a new <see cref="MouseStateSnapshot"/>.
  21. /// </summary>
  22. /// <param name="buttonState">The button state</param>
  23. /// <param name="position">The position of the cursor</param>
  24. /// <param name="scroll">The scroll delta</param>
  25. public MouseStateSnapshot(bool[] buttonState, Vector2 position, Vector2 scroll)
  26. {
  27. _buttonState = buttonState;
  28. Position = position;
  29. Scroll = scroll;
  30. }
  31. /// <summary>
  32. /// Check if a given button is pressed.
  33. /// </summary>
  34. /// <param name="button">The button</param>
  35. /// <returns>True if the given button is pressed</returns>
  36. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  37. public bool IsPressed(MouseButton button) => _buttonState[(int)button];
  38. }
  39. }