mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-26 03:52:01 +02:00
hapticFeedback
This commit is contained in:
parent
1050dee429
commit
a5fe6cc80b
@ -22,6 +22,10 @@
|
|||||||
#include "../gui/MouseButton.h"
|
#include "../gui/MouseButton.h"
|
||||||
#include "../gui/WindowHandler.h"
|
#include "../gui/WindowHandler.h"
|
||||||
|
|
||||||
|
#ifdef VCMI_ANDROID
|
||||||
|
#include "../../lib/CAndroidVMHelper.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <SDL_events.h>
|
#include <SDL_events.h>
|
||||||
#include <SDL_hints.h>
|
#include <SDL_hints.h>
|
||||||
#include <SDL_timer.h>
|
#include <SDL_timer.h>
|
||||||
@ -166,6 +170,7 @@ void InputSourceTouch::handleEventFingerUp(const SDL_TouchFingerEvent & tfinger)
|
|||||||
GH.input().setCursorPosition(convertTouchToMouse(tfinger));
|
GH.input().setCursorPosition(convertTouchToMouse(tfinger));
|
||||||
GH.events().dispatchMouseLeftButtonPressed(convertTouchToMouse(tfinger));
|
GH.events().dispatchMouseLeftButtonPressed(convertTouchToMouse(tfinger));
|
||||||
GH.events().dispatchMouseLeftButtonReleased(convertTouchToMouse(tfinger));
|
GH.events().dispatchMouseLeftButtonReleased(convertTouchToMouse(tfinger));
|
||||||
|
hapticFeedback();
|
||||||
state = TouchState::IDLE;
|
state = TouchState::IDLE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -215,6 +220,7 @@ void InputSourceTouch::handleUpdate()
|
|||||||
if (currentTime > lastTapTimeTicks + params.longTouchTimeMilliseconds)
|
if (currentTime > lastTapTimeTicks + params.longTouchTimeMilliseconds)
|
||||||
{
|
{
|
||||||
GH.events().dispatchShowPopup(GH.getCursorPosition());
|
GH.events().dispatchShowPopup(GH.getCursorPosition());
|
||||||
|
hapticFeedback();
|
||||||
|
|
||||||
if (GH.windows().isTopWindowPopup())
|
if (GH.windows().isTopWindowPopup())
|
||||||
state = TouchState::TAP_DOWN_LONG;
|
state = TouchState::TAP_DOWN_LONG;
|
||||||
@ -287,3 +293,10 @@ void InputSourceTouch::emitPinchEvent(const SDL_TouchFingerEvent & tfinger)
|
|||||||
if (distanceOld > params.pinchSensitivityThreshold)
|
if (distanceOld > params.pinchSensitivityThreshold)
|
||||||
GH.events().dispatchGesturePinch(lastTapPosition, distanceNew / distanceOld);
|
GH.events().dispatchGesturePinch(lastTapPosition, distanceNew / distanceOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InputSourceTouch::hapticFeedback() {
|
||||||
|
#if defined(VCMI_ANDROID)
|
||||||
|
CAndroidVMHelper vmHelper;
|
||||||
|
vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "hapticFeedback");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
@ -94,6 +94,8 @@ class InputSourceTouch
|
|||||||
|
|
||||||
void emitPanningEvent(const SDL_TouchFingerEvent & tfinger);
|
void emitPanningEvent(const SDL_TouchFingerEvent & tfinger);
|
||||||
void emitPinchEvent(const SDL_TouchFingerEvent & tfinger);
|
void emitPinchEvent(const SDL_TouchFingerEvent & tfinger);
|
||||||
|
|
||||||
|
void hapticFeedback();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
InputSourceTouch();
|
InputSourceTouch();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user