summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2019-03-13 00:28:31 +0100
committerEthan Yonker <dees_troy@teamw.in>2019-03-18 04:39:00 +0100
commit3ed778ad6389c901077fee38bb77abd55dd4eba4 (patch)
tree57a2a9af729ca594387f71532797fb9d42bcc8cc
parentfix building TWRP for devices without cache (diff)
downloadandroid_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.tar
android_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.tar.gz
android_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.tar.bz2
android_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.tar.lz
android_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.tar.xz
android_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.tar.zst
android_bootable_recovery-3ed778ad6389c901077fee38bb77abd55dd4eba4.zip
-rwxr-xr-x[-rw-r--r--]Android.mk3
-rwxr-xr-x[-rw-r--r--]data.cpp9
-rwxr-xr-x[-rw-r--r--]data.hpp0
-rwxr-xr-x[-rw-r--r--]gui/action.cpp4
-rwxr-xr-x[-rw-r--r--]gui/button.cpp3
-rwxr-xr-x[-rw-r--r--]gui/checkbox.cpp3
-rwxr-xr-x[-rw-r--r--]gui/keyboard.cpp8
-rwxr-xr-x[-rw-r--r--]gui/patternpassword.cpp8
-rwxr-xr-x[-rw-r--r--]gui/scrolllist.cpp3
-rwxr-xr-x[-rw-r--r--]gui/slider.cpp4
-rwxr-xr-x[-rw-r--r--]gui/terminal.cpp4
-rwxr-xr-x[-rw-r--r--]gui/theme/common/landscape.xml9
-rwxr-xr-x[-rw-r--r--]gui/theme/common/languages/en.xml1
-rwxr-xr-x[-rw-r--r--]gui/theme/common/portrait.xml9
-rwxr-xr-x[-rw-r--r--]gui/theme/common/watch.xml1
-rwxr-xr-x[-rw-r--r--]minuitwrp/events.cpp4
16 files changed, 73 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk
index 403647374..9b9123554 100644..100755
--- a/Android.mk
+++ b/Android.mk
@@ -293,6 +293,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 d9239a473..cf8349ba8 100644..100755
--- a/data.cpp
+++ b/data.cpp
@@ -587,9 +587,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)
@@ -1110,9 +1117,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/data.hpp b/data.hpp
index d61fe8e7c..d61fe8e7c 100644..100755
--- a/data.hpp
+++ b/data.hpp
diff --git a/gui/action.cpp b/gui/action.cpp
index d708dd467..11d9580fb 100644..100755
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -516,8 +516,12 @@ 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 dfae5e237..7c7f69f14 100644..100755
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -248,7 +248,10 @@ 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 de63cba36..025a803a2 100644..100755
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -179,7 +179,10 @@ int GUICheckbox::NotifyTouch(TOUCH_STATE state, int x __unused, int y __unused)
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 ca7006dc3..b6a772b01 100644..100755
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -549,7 +549,11 @@ 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 +597,11 @@ 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 5559f9dd8..a75ed156b 100644..100755
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -370,7 +370,11 @@ 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;
@@ -386,7 +390,11 @@ 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 ecfb5fe81..bf5a9b06d 100644..100755
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -508,7 +508,10 @@ int GUIScrollList::NotifyTouch(TOUCH_STATE state, int x, int y)
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 fab5a2ea0..3c5f6526e 100644..100755
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -208,7 +208,11 @@ 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");
+#endif
+
sAction->doActions();
}
diff --git a/gui/terminal.cpp b/gui/terminal.cpp
index b1799ce63..a4fed9104 100644..100755
--- a/gui/terminal.cpp
+++ b/gui/terminal.cpp
@@ -530,7 +530,11 @@ private:
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 5bbfe9029..f6f14bc51 100644..100755
--- a/gui/theme/common/landscape.xml
+++ b/gui/theme/common/landscape.xml
@@ -3166,19 +3166,28 @@
<placement x="%tab5_col4_x%" y="%row_tab_y%" w="%tab5_width%" h="%tab_indicator_height%"/>
</fill>
+ <text style="text_m">
+ <condition var1="tw_disable_haptics" var2="1"/>
+ <placement x="col1_x_left" y="%row4_y%" w="%content_width%"/>
+ <text>{@vibration_disabled=Vibration Disabled for Device}</text>
+ </text>
+
<slidervalue>
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="col1_x_left" y="%row4_y%" w="%content_width%"/>
<text>{@button_vibration=Button Vibration:}</text>
<data variable="tw_button_vibrate" min="0" max="300"/>
</slidervalue>
<slidervalue>
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="col1_x_left" y="%row9_y%" w="%content_width%"/>
<text>{@kb_vibration=Keyboard Vibration:}</text>
<data variable="tw_keyboard_vibrate" min="0" max="300"/>
</slidervalue>
<slidervalue>
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="col1_x_left" y="%row14_y%" w="%content_width%"/>
<text>{@act_vibration=Action Vibration:}</text>
<data variable="tw_action_vibrate" min="0" max="500"/>
diff --git a/gui/theme/common/languages/en.xml b/gui/theme/common/languages/en.xml
index afba59a02..03d4e084c 100644..100755
--- a/gui/theme/common/languages/en.xml
+++ b/gui/theme/common/languages/en.xml
@@ -318,6 +318,7 @@
<string name="settings_tz_btn">Time Zone</string>
<string name="settings_screen_btn">Screen</string>
<string name="settings_screen_bright_btn">Screen Brightness</string>
+ <string name="vibration_disabled">Vibration is disabled for this device</string>
<string name="settings_vibration_btn">Vibration</string>
<string name="settings_language_btn">Language</string>
<string name="time_zone_hdr">Time Zone</string>
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index 11769227f..09b7c6b70 100644..100755
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -3329,19 +3329,28 @@
<placement x="%tab5_col4_x%" y="%row_tab_y%" w="%tab5_width%" h="%tab_indicator_height%"/>
</fill>
+ <text style="text_m">
+ <condition var1="tw_disable_haptics" var2="1"/>
+ <placement x="%indent%" y="%row4_y%"/>
+ <text>{@vibration_disabled=Vibration Disabled for Device}</text>
+ </text>
+
<slidervalue>
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="indent" y="%row4_y%" w="%content_width%"/>
<text>{@button_vibration=Button Vibration:}</text>
<data variable="tw_button_vibrate" min="0" max="300"/>
</slidervalue>
<slidervalue>
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="indent" y="%row9_y%" w="%content_width%"/>
<text>{@kb_vibration=Keyboard Vibration:}</text>
<data variable="tw_keyboard_vibrate" min="0" max="300"/>
</slidervalue>
<slidervalue>
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="indent" y="%row14_y%" w="%content_width%"/>
<text>{@act_vibration=Action Vibration:}</text>
<data variable="tw_action_vibrate" min="0" max="500"/>
diff --git a/gui/theme/common/watch.xml b/gui/theme/common/watch.xml
index 83f4b63f2..d36bb2d5a 100644..100755
--- a/gui/theme/common/watch.xml
+++ b/gui/theme/common/watch.xml
@@ -3518,6 +3518,7 @@
</button>
<button style="main_button">
+ <condition var1="tw_disable_haptics" var2="0"/>
<placement x="%col1_x_right%" y="%row6_y%"/>
<text>{@settings_vibration_btn=Vibration}</text>
<action function="page">settings_vibration</action>
diff --git a/minuitwrp/events.cpp b/minuitwrp/events.cpp
index bd29f718d..9374ef174 100644..100755
--- a/minuitwrp/events.cpp
+++ b/minuitwrp/events.cpp
@@ -123,6 +123,7 @@ int write_to_file(const std::string& fn, const std::string& line) {
return -1;
}
+#ifndef TW_NO_HAPTICS
int vibrate(int timeout_ms)
{
if (timeout_ms > 10000) timeout_ms = 1000;
@@ -135,6 +136,7 @@ int vibrate(int timeout_ms)
return 0;
}
+#endif
/* Returns empty tokens */
static char *vk_strtok_r(char *str, const char *delim, char **save_str)
@@ -722,7 +724,9 @@ static int vk_modify(struct ev *e, struct input_event *ev)
last_virt_key = e->vks[i].scancode;
+#ifndef TW_NO_HAPTICS
vibrate(VIBRATOR_TIME_MS);
+#endif
// Mark that all further movement until lift is discard,
// and make sure we don't come back into this area