aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs')
-rw-r--r--Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs42
1 files changed, 20 insertions, 22 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs b/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs
index ee58a563..e07c1d20 100644
--- a/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs
+++ b/Ryujinx.HLE/HOS/Services/Hid/HidDevices/MouseDevice.cs
@@ -1,37 +1,35 @@
+using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Common;
+using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.Mouse;
+
namespace Ryujinx.HLE.HOS.Services.Hid
{
public class MouseDevice : BaseDevice
{
public MouseDevice(Switch device, bool active) : base(device, active) { }
- public void Update(int mouseX, int mouseY, int buttons = 0, int scrollX = 0, int scrollY = 0)
+ public void Update(int mouseX, int mouseY, uint buttons = 0, int scrollX = 0, int scrollY = 0)
{
- ref ShMemMouse mouse = ref _device.Hid.SharedMemory.Mouse;
+ ref RingLifo<MouseState> lifo = ref _device.Hid.SharedMemory.Mouse;
- int currentIndex = UpdateEntriesHeader(ref mouse.Header, out int previousIndex);
+ ref MouseState previousEntry = ref lifo.GetCurrentEntryRef();
+
+ MouseState newState = new MouseState()
+ {
+ SamplingNumber = previousEntry.SamplingNumber + 1,
+ };
- if (!Active)
+ if (Active)
{
- return;
+ newState.Buttons = (MouseButton)buttons;
+ newState.X = mouseX;
+ newState.Y = mouseY;
+ newState.DeltaX = mouseX - previousEntry.DeltaX;
+ newState.DeltaY = mouseY - previousEntry.DeltaY;
+ newState.WheelDeltaX = scrollX;
+ newState.WheelDeltaY = scrollY;
}
- ref MouseState currentEntry = ref mouse.Entries[currentIndex];
- MouseState previousEntry = mouse.Entries[previousIndex];
-
- currentEntry.SampleTimestamp = previousEntry.SampleTimestamp + 1;
- currentEntry.SampleTimestamp2 = previousEntry.SampleTimestamp2 + 1;
-
- currentEntry.Buttons = (ulong)buttons;
-
- currentEntry.Position = new MousePosition
- {
- X = mouseX,
- Y = mouseY,
- VelocityX = mouseX - previousEntry.Position.X,
- VelocityY = mouseY - previousEntry.Position.Y,
- ScrollVelocityX = scrollX,
- ScrollVelocityY = scrollY
- };
+ lifo.Write(ref newState);
}
}
} \ No newline at end of file