summaryrefslogtreecommitdiffstats
path: root/device.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-11 00:28:56 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-11 00:28:57 +0200
commitf19007a5252d62020c3ac8796908d9ee4653830d (patch)
treef327758d07cdb58a8e4a06f236f82f8df9515992 /device.cpp
parentMerge "Switch minadb over to C++." (diff)
parentAuto-detect whether to use the long-press UI. (diff)
downloadandroid_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.tar
android_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.tar.gz
android_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.tar.bz2
android_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.tar.lz
android_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.tar.xz
android_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.tar.zst
android_bootable_recovery-f19007a5252d62020c3ac8796908d9ee4653830d.zip
Diffstat (limited to 'device.cpp')
-rw-r--r--device.cpp50
1 files changed, 43 insertions, 7 deletions
diff --git a/device.cpp b/device.cpp
index af92b15bd..024fc3465 100644
--- a/device.cpp
+++ b/device.cpp
@@ -16,15 +16,21 @@
#include "device.h"
-// TODO: this is a lie for, say, fugu.
-static const char* HEADERS[] = {
- "Volume up/down to move highlight.",
- "Power button to select.",
+static const char* REGULAR_HEADERS[] = {
+ "Volume up/down move highlight.",
+ "Power button activates.",
"",
NULL
};
-static const char* ITEMS[] = {
+static const char* LONG_PRESS_HEADERS[] = {
+ "Any button cycles highlight.",
+ "Long-press activates.",
+ "",
+ NULL
+};
+
+static const char* MENU_ITEMS[] = {
"Reboot system now",
"Reboot to bootloader",
"Apply update from ADB",
@@ -37,8 +43,13 @@ static const char* ITEMS[] = {
NULL
};
-const char* const* Device::GetMenuHeaders() { return HEADERS; }
-const char* const* Device::GetMenuItems() { return ITEMS; }
+const char* const* Device::GetMenuHeaders() {
+ return ui_->HasThreeButtons() ? REGULAR_HEADERS : LONG_PRESS_HEADERS;
+}
+
+const char* const* Device::GetMenuItems() {
+ return MENU_ITEMS;
+}
Device::BuiltinAction Device::InvokeMenuItem(int menu_position) {
switch (menu_position) {
@@ -54,3 +65,28 @@ Device::BuiltinAction Device::InvokeMenuItem(int menu_position) {
default: return NO_ACTION;
}
}
+
+int Device::HandleMenuKey(int key, int visible) {
+ if (!visible) {
+ return kNoAction;
+ }
+
+ switch (key) {
+ case KEY_DOWN:
+ case KEY_VOLUMEDOWN:
+ return kHighlightDown;
+
+ case KEY_UP:
+ case KEY_VOLUMEUP:
+ return kHighlightUp;
+
+ case KEY_ENTER:
+ case KEY_POWER:
+ return kInvokeItem;
+
+ default:
+ // If you have all of the above buttons, any other buttons
+ // are ignored. Otherwise, any button cycles the highlight.
+ return ui_->HasThreeButtons() ? kNoAction : kHighlightDown;
+ }
+}