aboutsummaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
authorDoug Zongker2011-11-01 13:00:20 -0500
committerDoug Zongker2011-11-04 16:09:48 -0500
commit32a0a47a596509792fde8cdbf8b4b0705708b2be (patch)
tree55406d412c0a355dc4bdcc3fc0f2136a68af77d3 /ui.h
parentdaefc1d442fb421606680feb9aeb59c133f4c427 (diff)
downloadplatform-bootable-recovery-32a0a47a596509792fde8cdbf8b4b0705708b2be.tar.gz
platform-bootable-recovery-32a0a47a596509792fde8cdbf8b4b0705708b2be.tar.xz
platform-bootable-recovery-32a0a47a596509792fde8cdbf8b4b0705708b2be.zip
move key processing to RecoveryUI
Move the key for handling keys from ScreenRecoveryUI to RecoveryUI, so it can be used by devices without screens. Remove the UIParameters struct and replace it with some new member variables in ScreenRecoveryUI. Change-Id: I70094ecbc4acbf76ce44d5b5ec2036c36bdc3414
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h31
1 files changed, 26 insertions, 5 deletions
diff --git a/ui.h b/ui.h
index 3ca99a61..750b9933 100644
--- a/ui.h
+++ b/ui.h
@@ -17,13 +17,18 @@
17#ifndef RECOVERY_UI_H 17#ifndef RECOVERY_UI_H
18#define RECOVERY_UI_H 18#define RECOVERY_UI_H
19 19
20#include <linux/input.h>
21#include <pthread.h>
22
20// Abstract class for controlling the user interface during recovery. 23// Abstract class for controlling the user interface during recovery.
21class RecoveryUI { 24class RecoveryUI {
22 public: 25 public:
26 RecoveryUI();
27
23 virtual ~RecoveryUI() { } 28 virtual ~RecoveryUI() { }
24 29
25 // Initialize the object; called before anything else. 30 // Initialize the object; called before anything else.
26 virtual void Init() = 0; 31 virtual void Init();
27 32
28 // Set the overall recovery state ("background image"). 33 // Set the overall recovery state ("background image").
29 enum Icon { NONE, INSTALLING, ERROR }; 34 enum Icon { NONE, INSTALLING, ERROR };
@@ -57,19 +62,19 @@ class RecoveryUI {
57 // --- key handling --- 62 // --- key handling ---
58 63
59 // Wait for keypress and return it. May return -1 after timeout. 64 // Wait for keypress and return it. May return -1 after timeout.
60 virtual int WaitKey() = 0; 65 virtual int WaitKey();
61 66
62 virtual bool IsKeyPressed(int key) = 0; 67 virtual bool IsKeyPressed(int key);
63 68
64 // Erase any queued-up keys. 69 // Erase any queued-up keys.
65 virtual void FlushKeys() = 0; 70 virtual void FlushKeys();
66 71
67 // Called on each keypress, even while operations are in progress. 72 // Called on each keypress, even while operations are in progress.
68 // Return value indicates whether an immediate operation should be 73 // Return value indicates whether an immediate operation should be
69 // triggered (toggling the display, rebooting the device), or if 74 // triggered (toggling the display, rebooting the device), or if
70 // the key should be enqueued for use by the main thread. 75 // the key should be enqueued for use by the main thread.
71 enum KeyAction { ENQUEUE, TOGGLE, REBOOT }; 76 enum KeyAction { ENQUEUE, TOGGLE, REBOOT };
72 virtual KeyAction CheckKey(int key) = 0; 77 virtual KeyAction CheckKey(int key);
73 78
74 // --- menu display --- 79 // --- menu display ---
75 80
@@ -86,6 +91,22 @@ class RecoveryUI {
86 // End menu mode, resetting the text overlay so that ui_print() 91 // End menu mode, resetting the text overlay so that ui_print()
87 // statements will be displayed. 92 // statements will be displayed.
88 virtual void EndMenu() = 0; 93 virtual void EndMenu() = 0;
94
95private:
96 // Key event input queue
97 pthread_mutex_t key_queue_mutex;
98 pthread_cond_t key_queue_cond;
99 int key_queue[256], key_queue_len;
100 char key_pressed[KEY_MAX + 1]; // under key_queue_mutex
101 int key_last_down; // under key_queue_mutex
102 int rel_sum;
103
104 pthread_t input_t;
105
106 static void* input_thread(void* cookie);
107 static int input_callback(int fd, short revents, void* data);
108 void process_key(int key_code, int updown);
109 bool usb_connected();
89}; 110};
90 111
91#endif // RECOVERY_UI_H 112#endif // RECOVERY_UI_H