|
|
@@ -35,7 +35,7 @@
|
|
|
#include <SDL_timer.h>
|
|
|
|
|
|
InputSourceTouch::InputSourceTouch()
|
|
|
- : lastTapTimeTicks(0), lastLeftClickTimeTicks(0)
|
|
|
+ : lastTapTimeTicks(0), lastLeftClickTimeTicks(0), numTouchFingers(0)
|
|
|
{
|
|
|
params.useRelativeMode = settings["general"]["userRelativePointer"].Bool();
|
|
|
params.relativeModeSpeedFactor = settings["general"]["relativePointerSpeedMultiplier"].Float();
|
|
|
@@ -116,6 +116,8 @@ void InputSourceTouch::handleEventFingerMotion(const SDL_TouchFingerEvent & tfin
|
|
|
|
|
|
void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinger)
|
|
|
{
|
|
|
+ numTouchFingers = SDL_GetNumTouchFingers(tfinger.touchId);
|
|
|
+
|
|
|
// FIXME: better place to update potentially changed settings?
|
|
|
params.longTouchTimeMilliseconds = settings["general"]["longTouchTimeMilliseconds"].Float();
|
|
|
params.hapticFeedbackEnabled = settings["general"]["hapticFeedback"].Bool();
|
|
|
@@ -174,6 +176,8 @@ void InputSourceTouch::handleEventFingerDown(const SDL_TouchFingerEvent & tfinge
|
|
|
|
|
|
void InputSourceTouch::handleEventFingerUp(const SDL_TouchFingerEvent & tfinger)
|
|
|
{
|
|
|
+ numTouchFingers = SDL_GetNumTouchFingers(tfinger.touchId);
|
|
|
+
|
|
|
switch(state)
|
|
|
{
|
|
|
case TouchState::RELATIVE_MODE:
|
|
|
@@ -282,6 +286,11 @@ bool InputSourceTouch::hasTouchInputDevice() const
|
|
|
return SDL_GetNumTouchDevices() > 0;
|
|
|
}
|
|
|
|
|
|
+int InputSourceTouch::getNumTouchFingers() const
|
|
|
+{
|
|
|
+ return numTouchFingers;
|
|
|
+}
|
|
|
+
|
|
|
void InputSourceTouch::emitPanningEvent(const SDL_TouchFingerEvent & tfinger)
|
|
|
{
|
|
|
Point distance = convertTouchToMouse(-tfinger.dx, -tfinger.dy);
|
|
|
@@ -326,8 +335,8 @@ void InputSourceTouch::emitPinchEvent(const SDL_TouchFingerEvent & tfinger)
|
|
|
float newX = thisX - otherX;
|
|
|
float newY = thisY - otherY;
|
|
|
|
|
|
- double distanceOld = std::sqrt(oldX * oldX + oldY + oldY);
|
|
|
- double distanceNew = std::sqrt(newX * newX + newY + newY);
|
|
|
+ double distanceOld = std::sqrt(oldX * oldX + oldY * oldY);
|
|
|
+ double distanceNew = std::sqrt(newX * newX + newY * newY);
|
|
|
|
|
|
if (distanceOld > params.pinchSensitivityThreshold)
|
|
|
GH.events().dispatchGesturePinch(lastTapPosition, distanceNew / distanceOld);
|