From 71e9b049c21fb01d558f49844d17e792c347a930 Mon Sep 17 00:00:00 2001 From: "Samer Diab (S.a.M.e.R_d)" Date: Tue, 7 Jan 2014 20:18:47 +0000 Subject: Add haptic feedback Change-Id: I15d723f73c0b0bb4a40645d1c3f4c1c616f36998 --- gui/action.cpp | 6 ++++++ gui/button.cpp | 2 ++ gui/devices/1080x1920/res/ui.xml | 41 +++++++++++++++++++++++++++++++++++++++- gui/keyboard.cpp | 3 +++ gui/objects.hpp | 2 ++ gui/slider.cpp | 2 ++ 6 files changed, 55 insertions(+), 1 deletion(-) (limited to 'gui') diff --git a/gui/action.cpp b/gui/action.cpp index 5536c82b1..8539386a0 100644 --- a/gui/action.cpp +++ b/gui/action.cpp @@ -314,6 +314,7 @@ void* GUIAction::thread_start(void *cookie) void GUIAction::operation_start(const string operation_name) { + time(&Start); DataManager::SetValue(TW_ACTION_BUSY, 1); DataManager::SetValue("ui_progress", 0); DataManager::SetValue("tw_operation", operation_name); @@ -323,6 +324,7 @@ void GUIAction::operation_start(const string operation_name) void GUIAction::operation_end(const int operation_status, const int simulate) { + time_t Stop; int simulate_fail; DataManager::SetValue("ui_progress", 100); if (simulate) { @@ -344,6 +346,9 @@ void GUIAction::operation_end(const int operation_status, const int simulate) #ifndef TW_NO_SCREEN_TIMEOUT blankTimer.resetTimerAndUnblank(); #endif + time(&Stop); + if ((int) difftime(Stop, Start) > 10) + DataManager::Vibrate("tw_vibrate"); } int GUIAction::doAction(Action action, int isThreaded /* = 0 */) @@ -920,6 +925,7 @@ int GUIAction::doAction(Action action, int isThreaded /* = 0 */) else { operation_end(1, simulate); return -1; + } DataManager::SetValue(TW_BACKUP_NAME, "(Auto Generate)"); } else if (arg == "restore") { diff --git a/gui/button.cpp b/gui/button.cpp index be52c277e..ca386beed 100644 --- a/gui/button.cpp +++ b/gui/button.cpp @@ -30,6 +30,7 @@ #include #include #include +#include "../data.hpp" #include @@ -280,6 +281,7 @@ int GUIButton::NotifyTouch(TOUCH_STATE state, int x, int y) } else { if (last_state == 0) { last_state = 1; + DataManager::Vibrate("tw_vibrate"); if (mButtonLabel != NULL) mButtonLabel->isHighlighted = true; if (mButtonImg != NULL) diff --git a/gui/devices/1080x1920/res/ui.xml b/gui/devices/1080x1920/res/ui.xml index beaf37325..0f61faca7 100644 --- a/gui/devices/1080x1920/res/ui.xml +++ b/gui/devices/1080x1920/res/ui.xml @@ -2456,7 +2456,16 @@ - + + + + Vibration Duration + + Vibrate + + + + Restore Defaults @@ -2663,6 +2672,36 @@ + + + + + + + Vibration Settings : + + + + + + Vibration Value : + + + + + + + main + + + + + settings + + + + + diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp index 95cdbf1c8..97a980a4e 100644 --- a/gui/keyboard.cpp +++ b/gui/keyboard.cpp @@ -30,6 +30,7 @@ #include #include #include +#include "../data.hpp" #include @@ -388,6 +389,7 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y) switch (state) { case TOUCH_START: + DataManager::Vibrate("tw_vibrate"); if (GetSelection(x, y) == 0) { startSelection = -1; was_held = 0; @@ -419,6 +421,7 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y) if (highlightRenderCount != 0) mRendered = false; highlightRenderCount = 0; + DataManager::Vibrate("tw_vibrate"); startSelection = 0; } break; diff --git a/gui/objects.hpp b/gui/objects.hpp index e7bb2a0ee..1053113bd 100644 --- a/gui/objects.hpp +++ b/gui/objects.hpp @@ -25,6 +25,7 @@ #include #include #include +#include extern "C" { #ifdef HAVE_SELINUX @@ -285,6 +286,7 @@ protected: void operation_start(const string operation_name); void operation_end(const int operation_status, const int simulate); static void* command_thread(void *cookie); + time_t Start; }; class GUIConsole : public RenderObject, public ActionObject diff --git a/gui/slider.cpp b/gui/slider.cpp index b46d156f6..3908b82ab 100644 --- a/gui/slider.cpp +++ b/gui/slider.cpp @@ -15,6 +15,7 @@ #include #include #include +#include "../data.hpp" #include @@ -153,6 +154,7 @@ int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y) break; case TOUCH_RELEASE: + DataManager::Vibrate("tw_button_vibrate"); if (!dragging) return 0; -- cgit v1.2.3