diff --git a/Android.mk b/Android.mk
index 85cdd325bd..7d14e64449 100644
--- a/Android.mk
+++ b/Android.mk
@@ -281,6 +281,9 @@ endif
ifeq ($(TW_NO_EXFAT_FUSE), true)
LOCAL_CFLAGS += -DTW_NO_EXFAT_FUSE
endif
+ifeq ($(TW_NO_HAPTICS), true)
+ LOCAL_CFLAGS += -DTW_NO_HAPTICS
+endif
ifeq ($(TW_INCLUDE_JB_CRYPTO), true)
TW_INCLUDE_CRYPTO := true
endif
diff --git a/data.cpp b/data.cpp
index 5d05d2badd..192915c980 100644
--- a/data.cpp
+++ b/data.cpp
@@ -530,9 +530,16 @@ void DataManager::SetDefaultValues()
mConst.SetValue("false", "0");
mConst.SetValue(TW_VERSION_VAR, TW_VERSION_STR);
+
+#ifndef TW_NO_HAPTICS
mPersist.SetValue("tw_button_vibrate", "80");
mPersist.SetValue("tw_keyboard_vibrate", "40");
mPersist.SetValue("tw_action_vibrate", "160");
+ mConst.SetValue("tw_disable_haptics", "0");
+#else
+ LOGINFO("TW_NO_HAPTICS := true\n");
+ mConst.SetValue("tw_disable_haptics", "1");
+#endif
TWPartition *store = PartitionManager.Get_Default_Storage_Partition();
if (store)
@@ -1047,9 +1054,11 @@ string DataManager::GetSettingsStoragePath(void)
void DataManager::Vibrate(const string& varName)
{
+#ifndef TW_NO_HAPTICS
int vib_value = 0;
GetValue(varName, vib_value);
if (vib_value) {
vibrate(vib_value);
}
+#endif
}
diff --git a/gui/action.cpp b/gui/action.cpp
index a395158283..11aa73723f 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -516,8 +516,10 @@ void GUIAction::operation_end(const int operation_status)
blankTimer.resetTimerAndUnblank();
property_set("twrp.action_complete", "1");
time(&Stop);
+#ifndef TW_NO_HAPTICS
if ((int) difftime(Stop, Start) > 10)
DataManager::Vibrate("tw_action_vibrate");
+#endif
LOGINFO("operation_end - status=%d\n", operation_status);
}
diff --git a/gui/button.cpp b/gui/button.cpp
index a9b02a3054..8148c3ef48 100644
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -248,7 +248,9 @@ int GUIButton::NotifyTouch(TOUCH_STATE state, int x, int y)
} else {
if (last_state == 0) {
last_state = 1;
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
+ #endif
if (mButtonLabel != NULL)
mButtonLabel->isHighlighted = true;
if (mButtonImg != NULL)
diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp
index a2958db991..e6a3757e04 100644
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -177,8 +177,9 @@ int GUICheckbox::NotifyTouch(TOUCH_STATE state, int x __unused, int y __unused)
DataManager::GetValue(mVarName, lastState);
lastState = (lastState == 0) ? 1 : 0;
DataManager::SetValue(mVarName, lastState);
-
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
+ #endif
}
return 0;
}
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index 849cf19d8f..18b0c2a536 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -549,7 +549,9 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
bool repeatKey = false;
Layout& lay = layouts[currentLayout - 1];
if (state == TOUCH_RELEASE && was_held == 0) {
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_keyboard_vibrate");
+ #endif
if (key.layout > 0) {
// Switch layouts
if (lay.is_caps && key.layout == lay.revert_layout && !CapsLockOn) {
@@ -593,7 +595,9 @@ int GUIKeyboard::NotifyTouch(TOUCH_STATE state, int x, int y)
was_held = 1;
if (key.longpresskey > 0) {
// Long Press Key
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_keyboard_vibrate");
+ #endif
PageManager::NotifyCharInput(key.longpresskey);
}
else
diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp
index c31737f329..92388c9058 100644
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -371,7 +371,9 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
mTrackingTouch = true;
ResetActiveDots();
ConnectDot(dot_idx);
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
+ #endif
mCurLineX = x;
mCurLineY = y;
mNeedRender = true;
@@ -387,7 +389,9 @@ int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
{
ConnectIntermediateDots(dot_idx);
ConnectDot(dot_idx);
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
+ #endif
}
mCurLineX = x;
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index 7540356bfd..44f8ead43c 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -504,8 +504,9 @@ int GUIScrollList::NotifyTouch(TOUCH_STATE state, int x, int y)
// We've selected an item!
NotifySelect(selectedItem);
mUpdate = 1;
-
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
+ #endif
selectedItem = NO_ITEM;
} else {
// Start kinetic scrolling
diff --git a/gui/slider.cpp b/gui/slider.cpp
index ed5c615ceb..6bac698ff7 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -205,8 +205,10 @@ int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y)
return 0;
if (sCurTouchX >= mRenderX + mRenderW - sTouchW) {
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
sAction->doActions();
+ #endif
}
sCurTouchX = mRenderX;
diff --git a/gui/terminal.cpp b/gui/terminal.cpp
index 1744788da8..bbef72a961 100644
--- a/gui/terminal.cpp
+++ b/gui/terminal.cpp
@@ -527,7 +527,9 @@ class TerminalEngine
switch (ch)
{
case 7: // BEL
+ #ifndef TW_NO_HAPTICS
DataManager::Vibrate("tw_button_vibrate");
+ #endif
break;
case 8: // BS
left();
diff --git a/gui/theme/common/landscape.xml b/gui/theme/common/landscape.xml
index c3d89fe2d4..c6a1b65ef4 100644
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -3159,6 +3159,12 @@
{@vibration_hdr=Vibration}
+
+
+
+ {@vibration_disabled=Vibration Disabled for Device}
+
+
@@ -3166,18 +3172,21 @@
+
{@button_vibration=Button Vibration:}
+
{@kb_vibration=Keyboard Vibration:}
+
{@act_vibration=Action Vibration:}
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index 8a1be1875b..5456b75246 100644
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -317,6 +317,7 @@
Time Zone
Screen
Screen Brightness
+ Vibration is disabled for this device
Vibration
Language
Time Zone
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index f163bea8bd..5d97a51b43 100644
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -3322,6 +3322,12 @@
{@vibration_hdr=Vibration}
+
+
+
+ {@vibration_disabled=Vibration Disabled for Device}
+
+
@@ -3329,18 +3335,21 @@
+
{@button_vibration=Button Vibration:}
+
{@kb_vibration=Keyboard Vibration:}
+
{@act_vibration=Action Vibration:}
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index d5ef869721..f8d4420fff 100644
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -3532,6 +3532,7 @@