/ src / Ryujinx.Input / MouseStateSnapshot.cs
MouseStateSnapshot.cs
 1  using System.Numerics;
 2  using System.Runtime.CompilerServices;
 3  
 4  namespace Ryujinx.Input
 5  {
 6      /// <summary>
 7      /// A snapshot of a <see cref="IMouse"/>.
 8      /// </summary>
 9      public class MouseStateSnapshot
10      {
11          private readonly bool[] _buttonState;
12  
13          /// <summary>
14          /// The position of the mouse cursor
15          /// </summary>
16          public Vector2 Position { get; }
17  
18          /// <summary>
19          /// The scroll delta of the mouse
20          /// </summary>
21          public Vector2 Scroll { get; }
22  
23          /// <summary>
24          /// Create a new <see cref="MouseStateSnapshot"/>.
25          /// </summary>
26          /// <param name="buttonState">The button state</param>
27          /// <param name="position">The position of the cursor</param>
28          /// <param name="scroll">The scroll delta</param>
29          public MouseStateSnapshot(bool[] buttonState, Vector2 position, Vector2 scroll)
30          {
31              _buttonState = buttonState;
32  
33              Position = position;
34              Scroll = scroll;
35          }
36  
37          /// <summary>
38          /// Check if a given button is pressed.
39          /// </summary>
40          /// <param name="button">The button</param>
41          /// <returns>True if the given button is pressed</returns>
42          [MethodImpl(MethodImplOptions.AggressiveInlining)]
43          public bool IsPressed(MouseButton button) => _buttonState[(int)button];
44      }
45  }