diff options
Diffstat (limited to 'device.cpp')
-rw-r--r-- | device.cpp | 50 |
1 files changed, 43 insertions, 7 deletions
@@ -16,15 +16,21 @@ | |||
16 | 16 | ||
17 | #include "device.h" | 17 | #include "device.h" |
18 | 18 | ||
19 | // TODO: this is a lie for, say, fugu. | 19 | static const char* REGULAR_HEADERS[] = { |
20 | static const char* HEADERS[] = { | 20 | "Volume up/down move highlight.", |
21 | "Volume up/down to move highlight.", | 21 | "Power button activates.", |
22 | "Power button to select.", | ||
23 | "", | 22 | "", |
24 | NULL | 23 | NULL |
25 | }; | 24 | }; |
26 | 25 | ||
27 | static const char* ITEMS[] = { | 26 | static const char* LONG_PRESS_HEADERS[] = { |
27 | "Any button cycles highlight.", | ||
28 | "Long-press activates.", | ||
29 | "", | ||
30 | NULL | ||
31 | }; | ||
32 | |||
33 | static const char* MENU_ITEMS[] = { | ||
28 | "Reboot system now", | 34 | "Reboot system now", |
29 | "Reboot to bootloader", | 35 | "Reboot to bootloader", |
30 | "Apply update from ADB", | 36 | "Apply update from ADB", |
@@ -37,8 +43,13 @@ static const char* ITEMS[] = { | |||
37 | NULL | 43 | NULL |
38 | }; | 44 | }; |
39 | 45 | ||
40 | const char* const* Device::GetMenuHeaders() { return HEADERS; } | 46 | const char* const* Device::GetMenuHeaders() { |
41 | const char* const* Device::GetMenuItems() { return ITEMS; } | 47 | return ui_->HasThreeButtons() ? REGULAR_HEADERS : LONG_PRESS_HEADERS; |
48 | } | ||
49 | |||
50 | const char* const* Device::GetMenuItems() { | ||
51 | return MENU_ITEMS; | ||
52 | } | ||
42 | 53 | ||
43 | Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { | 54 | Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { |
44 | switch (menu_position) { | 55 | switch (menu_position) { |
@@ -54,3 +65,28 @@ Device::BuiltinAction Device::InvokeMenuItem(int menu_position) { | |||
54 | default: return NO_ACTION; | 65 | default: return NO_ACTION; |
55 | } | 66 | } |
56 | } | 67 | } |
68 | |||
69 | int Device::HandleMenuKey(int key, int visible) { | ||
70 | if (!visible) { | ||
71 | return kNoAction; | ||
72 | } | ||
73 | |||
74 | switch (key) { | ||
75 | case KEY_DOWN: | ||
76 | case KEY_VOLUMEDOWN: | ||
77 | return kHighlightDown; | ||
78 | |||
79 | case KEY_UP: | ||
80 | case KEY_VOLUMEUP: | ||
81 | return kHighlightUp; | ||
82 | |||
83 | case KEY_ENTER: | ||
84 | case KEY_POWER: | ||
85 | return kInvokeItem; | ||
86 | |||
87 | default: | ||
88 | // If you have all of the above buttons, any other buttons | ||
89 | // are ignored. Otherwise, any button cycles the highlight. | ||
90 | return ui_->HasThreeButtons() ? kNoAction : kHighlightDown; | ||
91 | } | ||
92 | } | ||