瀏覽代碼

haptic feedback on radial menu action

Michael 2 年之前
父節點
當前提交
ce00069dcd

+ 5 - 0
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();

+ 3 - 0
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;
 

+ 2 - 2
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;

+ 4 - 0
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();
+	}
 }