diff options
author | Ac_K <Acoustik666@gmail.com> | 2021-06-23 23:44:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 23:44:09 +0200 |
commit | d6b2ac33aa6d5fd21c884f218c886c6fe256acfc (patch) | |
tree | c7ec20e6ab39ce28bc070764272235096e6efb07 /Ryujinx.Input/HLE/TouchScreenManager.cs | |
parent | c71ae9c85c70bb2174807e21da16db427097c690 (diff) |
input: Fixes TouchPoint wrong attribute (#2390)
Diffstat (limited to 'Ryujinx.Input/HLE/TouchScreenManager.cs')
-rw-r--r-- | Ryujinx.Input/HLE/TouchScreenManager.cs | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/Ryujinx.Input/HLE/TouchScreenManager.cs b/Ryujinx.Input/HLE/TouchScreenManager.cs index ffa8eeac..579dcd74 100644 --- a/Ryujinx.Input/HLE/TouchScreenManager.cs +++ b/Ryujinx.Input/HLE/TouchScreenManager.cs @@ -1,5 +1,6 @@ using Ryujinx.HLE; using Ryujinx.HLE.HOS.Services.Hid; +using Ryujinx.HLE.HOS.Services.Hid.Types.SharedMemory.TouchScreen; using System; namespace Ryujinx.Input.HLE @@ -8,6 +9,7 @@ namespace Ryujinx.Input.HLE { private readonly IMouse _mouse; private Switch _device; + private bool _wasClicking; public TouchScreenManager(IMouse mouse) { @@ -19,10 +21,35 @@ namespace Ryujinx.Input.HLE _device = device; } - public bool Update(bool isFocused, float aspectRatio = 0) + public bool Update(bool isFocused, bool isClicking = false, float aspectRatio = 0) { - if (!isFocused) + if (!isFocused || (!_wasClicking && !isClicking)) { + // In case we lost focus, send the end touch. + if (_wasClicking && !isClicking) + { + MouseStateSnapshot snapshot = IMouse.GetMouseStateSnapshot(_mouse); + var touchPosition = IMouse.GetTouchPosition(snapshot.Position, _mouse.ClientSize, aspectRatio); + + TouchPoint currentPoint = new TouchPoint + { + Attribute = TouchAttribute.End, + + X = (uint)touchPosition.X, + Y = (uint)touchPosition.Y, + + // Placeholder values till more data is acquired + DiameterX = 10, + DiameterY = 10, + Angle = 90 + }; + + _device.Hid.Touchscreen.Update(currentPoint); + + } + + _wasClicking = false; + _device.Hid.Touchscreen.Update(); return false; @@ -30,11 +57,24 @@ namespace Ryujinx.Input.HLE if (aspectRatio > 0) { - var snapshot = IMouse.GetMouseStateSnapshot(_mouse); + MouseStateSnapshot snapshot = IMouse.GetMouseStateSnapshot(_mouse); var touchPosition = IMouse.GetTouchPosition(snapshot.Position, _mouse.ClientSize, aspectRatio); + TouchAttribute attribute = TouchAttribute.None; + + if (!_wasClicking && isClicking) + { + attribute = TouchAttribute.Start; + } + else if (_wasClicking && !isClicking) + { + attribute = TouchAttribute.End; + } + TouchPoint currentPoint = new TouchPoint { + Attribute = attribute, + X = (uint)touchPosition.X, Y = (uint)touchPosition.Y, @@ -46,6 +86,8 @@ namespace Ryujinx.Input.HLE _device.Hid.Touchscreen.Update(currentPoint); + _wasClicking = isClicking; + return true; } |