aboutsummaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2015-04-10 12:47:46 -0700
committerElliott Hughes <enh@google.com>2015-04-10 12:47:46 -0700
commit642aaa7a3e11b2de719fc9decc45174bcc235c0c (patch)
tree7e8d33676678e2240d5368fca8465712b24285cd /ui.h
parent6b0dd1d7e1e1f3645230f880db95cad1279a826b (diff)
downloadbootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.zip
bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.gz
bootable_recovery-642aaa7a3e11b2de719fc9decc45174bcc235c0c.tar.bz2
Fix ScreenRecoveryUI to handle devices without power/up/down.
Currently fugu has a custom subclass to handle this. The default code supports devices with trackballs but not all shipping Nexus devices? That's just silly. Change-Id: Id2779c91284899a26b4bb1af41e7033aa889df10
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 bc728b0..0d5ab55 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);