|
@@ -58,6 +58,15 @@ InputSourceTouch::InputSourceTouch()
|
|
|
|
|
|
void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfinger)
|
|
|
{
|
|
|
+ Point screenSize = GH.screenDimensions();
|
|
|
+
|
|
|
+ motionAccumulatedX[tfinger.fingerId] += tfinger.dx;
|
|
|
+ motionAccumulatedY[tfinger.fingerId] += tfinger.dy;
|
|
|
+
|
|
|
+ float motionThreshold = 1.0 / std::min(screenSize.x, screenSize.y);
|
|
|
+ if(std::abs(motionAccumulatedX[tfinger.fingerId]) < motionThreshold && std::abs(motionAccumulatedY[tfinger.fingerId]) < motionThreshold)
|
|
|
+ return;
|
|
|
+
|
|
|
if (CCS && CCS->curh && settings["video"]["cursor"].String() == "software" && state != TouchState::RELATIVE_MODE)
|
|
|
CCS->curh->cursorMove(GH.getCursorPosition().x, GH.getCursorPosition().y);
|
|
|
|
|
@@ -65,12 +74,11 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
|
|
|
{
|
|
|
case TouchState::RELATIVE_MODE:
|
|
|
{
|
|
|
- Point screenSize = GH.screenDimensions();
|
|
|
int scalingFactor = GH.screenHandler().getScalingFactor();
|
|
|
|
|
|
Point moveDistance {
|
|
|
- static_cast<int>(screenSize.x * params.relativeModeSpeedFactor * tfinger.dx),
|
|
|
- static_cast<int>(screenSize.y * params.relativeModeSpeedFactor * tfinger.dy)
|
|
|
+ static_cast<int>(screenSize.x * params.relativeModeSpeedFactor * motionAccumulatedX[tfinger.fingerId]),
|
|
|
+ static_cast<int>(screenSize.y * params.relativeModeSpeedFactor * motionAccumulatedY[tfinger.fingerId])
|
|
|
};
|
|
|
|
|
|
GH.input().moveCursorPosition(moveDistance);
|
|
@@ -112,6 +120,11 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if(std::abs(motionAccumulatedX[tfinger.fingerId]) >= motionThreshold)
|
|
|
+ motionAccumulatedX[tfinger.fingerId] = 0;
|
|
|
+ if(std::abs(motionAccumulatedY[tfinger.fingerId]) >= motionThreshold)
|
|
|
+ motionAccumulatedY[tfinger.fingerId] = 0;
|
|
|
}
|
|
|
|
|
|
void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinger)
|
|
@@ -293,7 +306,7 @@ int InputSourceTouch::getNumTouchFingers() const
|
|
|
|
|
|
void InputSourceTouch::emitPanningEvent(const SDL_TouchFingerEvent & tfinger)
|
|
|
{
|
|
|
- Point distance = convertTouchToMouse(-tfinger.dx, -tfinger.dy);
|
|
|
+ Point distance = convertTouchToMouse(-motionAccumulatedX[tfinger.fingerId], -motionAccumulatedY[tfinger.fingerId]);
|
|
|
|
|
|
GH.events().dispatchGesturePanning(lastTapPosition, convertTouchToMouse(tfinger), distance);
|
|
|
}
|
|
@@ -327,8 +340,8 @@ void InputSourceTouch::emitPinchEvent(const SDL_TouchFingerEvent & tfinger)
|
|
|
|
|
|
float thisX = tfinger.x * GH.screenDimensions().x;
|
|
|
float thisY = tfinger.y * GH.screenDimensions().y;
|
|
|
- float deltaX = tfinger.dx * GH.screenDimensions().x;
|
|
|
- float deltaY = tfinger.dy * GH.screenDimensions().y;
|
|
|
+ float deltaX = motionAccumulatedX[tfinger.fingerId] * GH.screenDimensions().x;
|
|
|
+ float deltaY = motionAccumulatedY[tfinger.fingerId] * GH.screenDimensions().y;
|
|
|
|
|
|
float oldX = thisX - deltaX - otherX;
|
|
|
float oldY = thisY - deltaY - otherY;
|