diff options
author | Elliott Hughes <enh@google.com> | 2015-04-10 21:47:46 +0200 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2015-04-10 21:47:46 +0200 |
commit | 642aaa7a3e11b2de719fc9decc45174bcc235c0c (patch) | |
tree | 7e8d33676678e2240d5368fca8465712b24285cd /ui.h | |
parent | Merge "Move "Mount /system" to the main menu." (diff) | |
download | android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.gz android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.bz2 android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.lz android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.xz android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.zst android_bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.zip |
Diffstat (limited to '')
-rw-r--r-- | ui.h | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -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); |