input: Fixes TouchPoint wrong attribute (#2390)
This commit is contained in:
parent
c71ae9c85c
commit
d6b2ac33aa
6 changed files with 71 additions and 32 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue