Skip to content

Commit

Permalink
Windows touch (#1461)
Browse files Browse the repository at this point in the history
* When a "mouse" event was caused by a touch instead of the mouse, use touch-specific logic: 1) force the rate to be 1:1; 2) in Windows, don't try to reset the cursor (via. SetCursorPos), which is usually done to avoid the mouse bumping up against the edge of the screen.  These work together to allow touch to work as expected on Windows, while preserving existing mouse behavior.

* update vstgui subproject
  • Loading branch information
nathankopp authored and baconpaul committed Jan 9, 2020
1 parent ea2b0fd commit fbf7301
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
25 changes: 9 additions & 16 deletions src/common/gui/CCursorHidingControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ CMouseEventResult CCursorHidingControl::onMouseMoved(CPoint& where, const CButto
double dy = where.y - _lastPos.y;
_lastPos = where;

if (_isDetatched)
if (_isDetatched && !buttons.isTouch())
{
double scaling = getMouseDeltaScaling(where, buttons);

Expand All @@ -57,22 +57,15 @@ CMouseEventResult CCursorHidingControl::onMouseMoved(CPoint& where, const CButto
onMouseMoveDelta(where, buttons, dx, dy);

#if WINDOWS
if (_isDetatched)
if (_isDetatched && !buttons.isTouch())
{
// test for touch. If we are in a touch screen this cursor reset seems like a messy flip. See #1443
int value = GetSystemMetrics(SM_DIGITIZER);
bool hasTouch = ( value & ( NID_INTEGRATED_TOUCH | NID_EXTERNAL_TOUCH ) ) ? true : false;

if (!hasTouch)
{
double ddx = where.x - _detachPos.x;
double ddy = where.y - _detachPos.y;
double d = sqrt(ddx * ddx + ddy * ddy);
if (d > 10 && SetCursorPos(_hideX, _hideY))
{
_lastPos = _detachPos;
}
}
double ddx = where.x - _detachPos.x;
double ddy = where.y - _detachPos.y;
double d = sqrt(ddx * ddx + ddy * ddy);
if (d > 10 && SetCursorPos(_hideX, _hideY))
{
_lastPos = _detachPos;
}
}
#endif

Expand Down
3 changes: 3 additions & 0 deletions src/common/gui/CSurgeSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ double CSurgeSlider::getMouseDeltaScaling(CPoint& where, const CButtonState& but
break;
}

if (buttons.isTouch())
rate = 1.0;

if (buttons & kRButton)
rate *= 0.1;
if (buttons & kShift)
Expand Down

0 comments on commit fbf7301

Please sign in to comment.