From fdf1b42aae74a098d335e02ac5f06e2e53fd7f34 Mon Sep 17 00:00:00 2001 From: emmaus Date: Mon, 26 Feb 2018 13:11:57 +0000 Subject: [PATCH] handle touch input from Touches struct --- Ryujinx.Core/Hid.cs | 3 --- Ryujinx.Core/Hid/HidTouchScreen.cs | 12 +++++++++++- Ryujinx/Ui/GLScreen.cs | 4 +--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Ryujinx.Core/Hid.cs b/Ryujinx.Core/Hid.cs index fec7d9e54..382c10723 100644 --- a/Ryujinx.Core/Hid.cs +++ b/Ryujinx.Core/Hid.cs @@ -206,9 +206,6 @@ namespace Ryujinx.Core + (uint)((uint)(TouchScreenHeader.LatestEntry) * Marshal.SizeOf(typeof(HidTouchScreenEntry))); HidPtr = new IntPtr(Ns.Ram.ToInt64() + (uint)SharedMemOffset + InnerOffset); - //Truncate number of touches - TouchPoints.NumberOfTouches = TouchPoints.NumberOfTouches > 16 ? 16 : TouchPoints.NumberOfTouches; - HidTouchScreenEntry hidTouchScreenEntry = new HidTouchScreenEntry() { Header = new HidTouchScreenEntryHeader() diff --git a/Ryujinx.Core/Hid/HidTouchScreen.cs b/Ryujinx.Core/Hid/HidTouchScreen.cs index 590bed611..fd7ddd1e4 100644 --- a/Ryujinx.Core/Hid/HidTouchScreen.cs +++ b/Ryujinx.Core/Hid/HidTouchScreen.cs @@ -56,8 +56,18 @@ namespace Ryujinx.Core { public uint[] XTouches; public uint[] YTouches; - public uint NumberOfTouches; + public uint NumberOfTouches { get; private set; } public const uint Hid_Max_Num_Touches = 16; + + public void AddTouch(uint X, uint Y) + { + if (NumberOfTouches < Hid_Max_Num_Touches) + { + XTouches[NumberOfTouches] = X; + YTouches[NumberOfTouches] = Y; + NumberOfTouches++; + } + } } } \ No newline at end of file diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index ecdef0040..f8bbd8920 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -98,9 +98,7 @@ namespace Ryujinx { if (Mouse.GetState().LeftButton == OpenTK.Input.ButtonState.Pressed && Focused) { - CurrentTouchPoints.XTouches[CurrentTouchPoints.NumberOfTouches] = (uint)Mouse.X; - CurrentTouchPoints.YTouches[CurrentTouchPoints.NumberOfTouches] = (uint)Mouse.Y; - CurrentTouchPoints.NumberOfTouches++; + CurrentTouchPoints.AddTouch((uint)Mouse.X, (uint)Mouse.Y); } }