1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

hapticFeedback

This commit is contained in:
Michael 2023-07-08 17:02:44 +02:00 committed by GitHub
parent 1050dee429
commit a5fe6cc80b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -22,6 +22,10 @@
#include "../gui/MouseButton.h"
#include "../gui/WindowHandler.h"
#ifdef VCMI_ANDROID
#include "../../lib/CAndroidVMHelper.h"
#endif
#include <SDL_events.h>
#include <SDL_hints.h>
#include <SDL_timer.h>
@ -166,6 +170,7 @@ void InputSourceTouch::handleEventFingerUp(const SDL_TouchFingerEvent & tfinger)
GH.input().setCursorPosition(convertTouchToMouse(tfinger));
GH.events().dispatchMouseLeftButtonPressed(convertTouchToMouse(tfinger));
GH.events().dispatchMouseLeftButtonReleased(convertTouchToMouse(tfinger));
hapticFeedback();
state = TouchState::IDLE;
break;
}
@ -215,6 +220,7 @@ void InputSourceTouch::handleUpdate()
if (currentTime > lastTapTimeTicks + params.longTouchTimeMilliseconds)
{
GH.events().dispatchShowPopup(GH.getCursorPosition());
hapticFeedback();
if (GH.windows().isTopWindowPopup())
state = TouchState::TAP_DOWN_LONG;
@ -287,3 +293,10 @@ void InputSourceTouch::emitPinchEvent(const SDL_TouchFingerEvent & tfinger)
if (distanceOld > params.pinchSensitivityThreshold)
GH.events().dispatchGesturePinch(lastTapPosition, distanceNew / distanceOld);
}
void InputSourceTouch::hapticFeedback() {
#if defined(VCMI_ANDROID)
CAndroidVMHelper vmHelper;
vmHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "hapticFeedback");
#endif
}

View File

@ -94,6 +94,8 @@ class InputSourceTouch
void emitPanningEvent(const SDL_TouchFingerEvent & tfinger);
void emitPinchEvent(const SDL_TouchFingerEvent & tfinger);
void hapticFeedback();
public:
InputSourceTouch();