From ce00069dcd1d6b8a134f90dfc105e0273c1fb60e Mon Sep 17 00:00:00 2001 From: Michael <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 23 Jul 2023 15:17:30 +0200 Subject: [PATCH] haptic feedback on radial menu action --- client/eventsSDL/InputHandler.cpp | 5 +++++ client/eventsSDL/InputHandler.h | 3 +++ client/eventsSDL/InputSourceTouch.h | 4 ++-- client/widgets/RadialMenu.cpp | 4 ++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/client/eventsSDL/InputHandler.cpp b/client/eventsSDL/InputHandler.cpp index 3d46c8ef2..048112c27 100644 --- a/client/eventsSDL/InputHandler.cpp +++ b/client/eventsSDL/InputHandler.cpp @@ -239,6 +239,11 @@ void InputHandler::stopTextInput() textHandler->stopTextInput(); } +void InputHandler::hapticFeedback() +{ + fingerHandler->hapticFeedback(); +} + bool InputHandler::hasTouchInputDevice() const { return fingerHandler->hasTouchInputDevice(); diff --git a/client/eventsSDL/InputHandler.h b/client/eventsSDL/InputHandler.h index c620b3676..56216a6b3 100644 --- a/client/eventsSDL/InputHandler.h +++ b/client/eventsSDL/InputHandler.h @@ -63,6 +63,9 @@ public: /// Ends any existing text input state void stopTextInput(); + /// do a haptic feedback + void hapticFeedback(); + /// returns true if system has active touchscreen bool hasTouchInputDevice() const; diff --git a/client/eventsSDL/InputSourceTouch.h b/client/eventsSDL/InputSourceTouch.h index fb7277046..b82ae1688 100644 --- a/client/eventsSDL/InputSourceTouch.h +++ b/client/eventsSDL/InputSourceTouch.h @@ -96,8 +96,6 @@ class InputSourceTouch void emitPanningEvent(const SDL_TouchFingerEvent & tfinger); void emitPinchEvent(const SDL_TouchFingerEvent & tfinger); - - void hapticFeedback(); public: InputSourceTouch(); @@ -106,6 +104,8 @@ public: void handleEventFingerDown(const SDL_TouchFingerEvent & current); void handleEventFingerUp(const SDL_TouchFingerEvent & current); + void hapticFeedback(); + void handleUpdate(); bool hasTouchInputDevice() const; diff --git a/client/widgets/RadialMenu.cpp b/client/widgets/RadialMenu.cpp index 82a6a1983..2d6aa478b 100644 --- a/client/widgets/RadialMenu.cpp +++ b/client/widgets/RadialMenu.cpp @@ -13,6 +13,7 @@ #include "Images.h" #include "TextControls.h" +#include "../eventsSDL/InputHandler.h" #include "../gui/CGuiHandler.h" #include "../gui/WindowHandler.h" #include "../render/IImage.h" @@ -137,5 +138,8 @@ void RadialMenu::gesture(bool on, const Point & initialPosition, const Point & f // we need to close this window first so if action spawns a new window it won't be closed instead GH.windows().popWindows(1); if (item) + { + GH.input().hapticFeedback(); item->callback(); + } }