aboutsummaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
authorTao Bao2017-07-28 02:05:40 -0500
committerTao Bao2017-08-01 20:30:48 -0500
commit5f8dd9951d986b65d98d6a9ea38003427e9e46df (patch)
tree6ca03f4b7b107ea11fa40248747a757f5c8940ab /ui.h
parent64cba55fbc5307b78b947619d84767604122995d (diff)
downloadplatform-bootable-recovery-5f8dd9951d986b65d98d6a9ea38003427e9e46df.tar.gz
platform-bootable-recovery-5f8dd9951d986b65d98d6a9ea38003427e9e46df.tar.xz
platform-bootable-recovery-5f8dd9951d986b65d98d6a9ea38003427e9e46df.zip
ui: Move the support for touch inputs into RecoveryUI.
- Added detection for EV_ABS events in minui/events.cpp, if it's allowed; - Added listening and processing touch inputs in ui.cpp; - Fixed an issue in recognizing swipe with multi-touch protocol A; - Changed the logic in RecoveryUI::ProcessKey() to be swipe-aware. It now allows turning on text mode with <power> + <swipe-up>. The last change also fixed an issue on devices with protocol A: prior to this CL, user may accidentally toggle the text mode during an OTA. Because it was considered as a single-button device, a long tap that sent BTN_TOUCH event would turn on text mode. Test: Allow detecting touch inputs. Swiping (up, down, enter) works on angler, angelfish, dorado respectively. Bug: 36169090 Change-Id: I4bc882b99114ce4ab414f8bdb8f4f7a525b8a8fd
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/ui.h b/ui.h
index 7eb04aec..5cda7af0 100644
--- a/ui.h
+++ b/ui.h
@@ -82,6 +82,12 @@ class RecoveryUI {
82 // otherwise. 82 // otherwise.
83 virtual bool HasThreeButtons(); 83 virtual bool HasThreeButtons();
84 84
85 // Returns true if it has a power key.
86 virtual bool HasPowerKey() const;
87
88 // Returns true if it supports touch inputs.
89 virtual bool HasTouchScreen() const;
90
85 // Erases any queued-up keys. 91 // Erases any queued-up keys.
86 virtual void FlushKeys(); 92 virtual void FlushKeys();
87 93
@@ -129,7 +135,14 @@ class RecoveryUI {
129 unsigned int brightness_normal_; 135 unsigned int brightness_normal_;
130 unsigned int brightness_dimmed_; 136 unsigned int brightness_dimmed_;
131 137
138 // Whether we should listen for touch inputs (default: false).
139 bool touch_screen_allowed_;
140
132 private: 141 private:
142 // The sensitivity when detecting a swipe.
143 const int kTouchLowThreshold;
144 const int kTouchHighThreshold;
145
133 // Key event input queue 146 // Key event input queue
134 pthread_mutex_t key_queue_mutex; 147 pthread_mutex_t key_queue_mutex;
135 pthread_cond_t key_queue_cond; 148 pthread_cond_t key_queue_cond;
@@ -147,6 +160,16 @@ class RecoveryUI {
147 bool has_power_key; 160 bool has_power_key;
148 bool has_up_key; 161 bool has_up_key;
149 bool has_down_key; 162 bool has_down_key;
163 bool has_touch_screen;
164
165 // Touch event related variables. See the comments in RecoveryUI::OnInputEvent().
166 int touch_slot_;
167 int touch_X_;
168 int touch_Y_;
169 int touch_start_X_;
170 int touch_start_Y_;
171 bool touch_finger_down_;
172 bool touch_swiping_;
150 173
151 struct key_timer_t { 174 struct key_timer_t {
152 RecoveryUI* ui; 175 RecoveryUI* ui;
@@ -157,6 +180,7 @@ class RecoveryUI {
157 pthread_t input_thread_; 180 pthread_t input_thread_;
158 181
159 void OnKeyDetected(int key_code); 182 void OnKeyDetected(int key_code);
183 void OnTouchDetected(int dx, int dy);
160 int OnInputEvent(int fd, uint32_t epevents); 184 int OnInputEvent(int fd, uint32_t epevents);
161 void ProcessKey(int key_code, int updown); 185 void ProcessKey(int key_code, int updown);
162 186