summaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-10 22:26:52 +0200
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-10 22:26:53 +0200
commit5d1630a926a02ca13a66eb1e385eabba16b04cfc (patch)
tree7e8d33676678e2240d5368fca8465712b24285cd /ui.h
parentMerge "Move "Mount /system" to the main menu." (diff)
parentFix ScreenRecoveryUI to handle devices without power/up/down. (diff)
downloadandroid_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.tar
android_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.tar.gz
android_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.tar.bz2
android_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.tar.lz
android_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.tar.xz
android_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.tar.zst
android_bootable_recovery-5d1630a926a02ca13a66eb1e385eabba16b04cfc.zip
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/ui.h b/ui.h
index bc728b05a..0d5ab557d 100644
--- a/ui.h
+++ b/ui.h
@@ -69,30 +69,27 @@ class RecoveryUI {
// --- key handling ---
- // Wait for keypress and return it. May return -1 after timeout.
+ // Wait for a key and return it. May return -1 after timeout.
virtual int WaitKey();
virtual bool IsKeyPressed(int key);
+ virtual bool IsLongPress();
// Erase any queued-up keys.
virtual void FlushKeys();
- // Called on each keypress, even while operations are in progress.
+ // Called on each key press, even while operations are in progress.
// Return value indicates whether an immediate operation should be
// triggered (toggling the display, rebooting the device), or if
// the key should be enqueued for use by the main thread.
enum KeyAction { ENQUEUE, TOGGLE, REBOOT, IGNORE };
- virtual KeyAction CheckKey(int key);
-
- // Called immediately before each call to CheckKey(), tell you if
- // the key was long-pressed.
- virtual void NextCheckKeyIsLong(bool is_long_press);
+ virtual KeyAction CheckKey(int key, bool is_long_press);
// Called when a key is held down long enough to have been a
// long-press (but before the key is released). This means that
// if the key is eventually registered (released without any other
- // keys being pressed in the meantime), NextCheckKeyIsLong() will
- // be called with "true".
+ // keys being pressed in the meantime), CheckKey will be called with
+ // 'is_long_press' true.
virtual void KeyLongPress(int key);
// Normally in recovery there's a key sequence that triggers
@@ -110,8 +107,8 @@ class RecoveryUI {
virtual void StartMenu(const char* const * headers, const char* const * items,
int initial_selection) = 0;
- // Set the menu highlight to the given index, and return it (capped to
- // the range [0..numitems).
+ // Set the menu highlight to the given index, wrapping if necessary.
+ // Returns the actual item selected.
virtual int SelectMenu(int sel) = 0;
// End menu mode, resetting the text overlay so that ui_print()
@@ -136,14 +133,20 @@ private:
int consecutive_power_keys;
int last_key;
- typedef struct {
+ bool has_power_key;
+ bool has_up_key;
+ bool has_down_key;
+
+ struct key_timer_t {
RecoveryUI* ui;
int key_code;
int count;
- } key_timer_t;
+ };
pthread_t input_t;
+ void OnKeyDetected(int key_code);
+
static void* input_thread(void* cookie);
static int input_callback(int fd, uint32_t epevents, void* data);
void process_key(int key_code, int updown);