Skip to content
Permalink
Browse files

Fixed occasional frozen touches on windows.

  • Loading branch information...
valyard committed Jul 23, 2017
1 parent ef15e04 commit 58ae80a3047bb6e4dfda36efa7528fcd5888f6e4
@@ -104,7 +104,7 @@ void decodeWin8Touches(UINT msg, WPARAM wParam, LPARAM lParam)
ScreenToClient(_currentWindow, &p);

Vector2 position = Vector2(((float)p.x - _offsetX) * _scaleX, _screenHeight - ((float)p.y - _offsetY) * _scaleY);
PointerData data;
PointerData data {};
data.pointerFlags = pointerInfo.pointerFlags;
data.changedButtons = pointerInfo.ButtonChangeType;

@@ -156,7 +156,7 @@ void decodeWin7Touches(UINT msg, WPARAM wParam, LPARAM lParam)
ScreenToClient(_currentWindow, &p);

Vector2 position = Vector2(((float)p.x - _offsetX) * _scaleX, _screenHeight - ((float)p.y - _offsetY) * _scaleY);
PointerData data;
PointerData data {};

if ((touch.dwFlags & TOUCHEVENTF_DOWN) != 0)
{
@@ -165,7 +165,7 @@ void decodeWin7Touches(UINT msg, WPARAM wParam, LPARAM lParam)
}
else if ((touch.dwFlags & TOUCHEVENTF_UP) != 0)
{
msg = WM_POINTERUP;
msg = WM_POINTERLEAVE;
data.changedButtons = POINTER_CHANGE_FIRSTBUTTON_UP;
}
else if ((touch.dwFlags & TOUCHEVENTF_MOVE) != 0)
@@ -262,7 +262,7 @@ public virtual bool UpdateInput()
public virtual void UpdateResolution()
{
setScaling();
TouchManager.Instance.CancelPointer(mousePointer.Id);
if (mousePointer != null) TouchManager.Instance.CancelPointer(mousePointer.Id);
}

/// <inheritdoc />
@@ -500,24 +500,27 @@ private void nativePointer(int id, PointerEvent evt, PointerType type, Vector2 p
}
break;
case PointerType.Touch:
TouchPointer touchPointer;
switch (evt)
{
// Enter/Leave logic is handles in Down/Up
case PointerEvent.Enter:
break;
case PointerEvent.Leave:
// Sometimes Windows might not send Up, so have to execute touch release logic here.
// Has been working fine on test devices so far.
if (winTouchToInternalId.TryGetValue(id, out touchPointer))
{
winTouchToInternalId.Remove(id);
internalRemoveTouchPointer(touchPointer);
}
break;
case PointerEvent.Down:
TouchPointer touchPointer = internalAddTouchPointer(position);
touchPointer = internalAddTouchPointer(position);
touchPointer.Rotation = getTouchRotation(ref data);
touchPointer.Pressure = getTouchPressure(ref data);
winTouchToInternalId.Add(id, touchPointer);
break;
case PointerEvent.Up:
if (winTouchToInternalId.TryGetValue(id, out touchPointer))
{
winTouchToInternalId.Remove(id);
internalRemoveTouchPointer(touchPointer);
}
break;
case PointerEvent.Update:
if (!winTouchToInternalId.TryGetValue(id, out touchPointer)) return;

0 comments on commit 58ae80a

Please sign in to comment.
You can’t perform that action at this time.