OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 5 #ifndef UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 6 #define UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
7 | 7 |
8 #include "base/time/tick_clock.h" | 8 #include "base/time/tick_clock.h" |
9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 class GestureEvent; | 26 class GestureEvent; |
27 class GestureProviderAura; | 27 class GestureProviderAura; |
28 class TouchEvent; | 28 class TouchEvent; |
29 | 29 |
30 // A delegate to handle commands in response to detected accessibility gesture | 30 // A delegate to handle commands in response to detected accessibility gesture |
31 // events. | 31 // events. |
32 class TouchExplorationControllerDelegate { | 32 class TouchExplorationControllerDelegate { |
33 public: | 33 public: |
34 virtual ~TouchExplorationControllerDelegate() {} | 34 virtual ~TouchExplorationControllerDelegate() {} |
35 | 35 |
36 // This function should be called whenever the delegate wants to play a sound | |
37 // when the volume adjusts. | |
38 virtual void PlayVolumeAdjustSound() = 0; | |
39 | |
40 // Takes an int from 0.0 to 100.0 that indicates the percent the volume | 36 // Takes an int from 0.0 to 100.0 that indicates the percent the volume |
41 // should be set to. | 37 // should be set to. |
42 virtual void SetOutputLevel(int volume) = 0; | 38 virtual void SetOutputLevel(int volume) = 0; |
43 | 39 |
44 // Silences spoken feedback. | 40 // Silences spoken feedback. |
45 virtual void SilenceSpokenFeedback() = 0; | 41 virtual void SilenceSpokenFeedback() = 0; |
| 42 |
| 43 // This function should be called when the volume adjust earcon should be |
| 44 // played |
| 45 virtual void PlayVolumeAdjustEarcon() = 0; |
| 46 |
| 47 // This function should be called when the passthrough earcon should be |
| 48 // played. |
| 49 virtual void PlayPassthroughEarcon() = 0; |
| 50 |
| 51 // This function should be called when the exit screen earcon should be |
| 52 // played. |
| 53 virtual void PlayExitScreenEarcon() = 0; |
| 54 |
| 55 // This function should be called when the enter screen earcon should be |
| 56 // played. |
| 57 virtual void PlayEnterScreenEarcon() = 0; |
46 }; | 58 }; |
47 | 59 |
48 // TouchExplorationController is used in tandem with "Spoken Feedback" to | 60 // TouchExplorationController is used in tandem with "Spoken Feedback" to |
49 // make the touch UI accessible. Gestures performed in the middle of the screen | 61 // make the touch UI accessible. Gestures performed in the middle of the screen |
50 // are mapped to accessibility key shortcuts while gestures performed on the | 62 // are mapped to accessibility key shortcuts while gestures performed on the |
51 // edge of the screen can change settings. | 63 // edge of the screen can change settings. |
52 // | 64 // |
53 // ** Short version ** | 65 // ** Short version ** |
54 // | 66 // |
55 // At a high-level, single-finger events are used for accessibility - | 67 // At a high-level, single-finger events are used for accessibility - |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // | 147 // |
136 // Currently, only the right edge is mapped to control the volume. Volume | 148 // Currently, only the right edge is mapped to control the volume. Volume |
137 // control along the edge of the screen is directly proportional to where the | 149 // control along the edge of the screen is directly proportional to where the |
138 // user's finger is located on the screen. The top right corner of the screen | 150 // user's finger is located on the screen. The top right corner of the screen |
139 // automatically sets the volume to 100% and the bottome right corner of the | 151 // automatically sets the volume to 100% and the bottome right corner of the |
140 // screen automatically sets the volume to 0% once the user has moved past slop. | 152 // screen automatically sets the volume to 0% once the user has moved past slop. |
141 // | 153 // |
142 // If the user taps the screen with two fingers and lifts both fingers before | 154 // If the user taps the screen with two fingers and lifts both fingers before |
143 // the grace period has passed, spoken feedback is silenced. | 155 // the grace period has passed, spoken feedback is silenced. |
144 // | 156 // |
| 157 // The user can also enter passthrough by placing a finger on one of the bottom |
| 158 // corners of the screen until an earcon sounds. After the earcon sounds, the |
| 159 // user is in passthrough so all subsequent fingers placed on the screen will be |
| 160 // passed through. Once the finger in the corner has been released, the state |
| 161 // will switch to wait for one finger. |
| 162 // |
145 // The caller is expected to retain ownership of instances of this class and | 163 // The caller is expected to retain ownership of instances of this class and |
146 // destroy them before |root_window| is destroyed. | 164 // destroy them before |root_window| is destroyed. |
147 class UI_CHROMEOS_EXPORT TouchExplorationController | 165 class UI_CHROMEOS_EXPORT TouchExplorationController |
148 : public ui::EventRewriter, | 166 : public ui::EventRewriter, |
149 public ui::GestureProviderAuraClient { | 167 public ui::GestureProviderAuraClient { |
150 public: | 168 public: |
151 explicit TouchExplorationController( | 169 explicit TouchExplorationController( |
152 aura::Window* root_window, | 170 aura::Window* root_window, |
153 ui::TouchExplorationControllerDelegate* delegate); | 171 ui::TouchExplorationControllerDelegate* delegate); |
154 virtual ~TouchExplorationController(); | 172 virtual ~TouchExplorationController(); |
(...skipping 14 matching lines...) Expand all Loading... |
169 ui::EventRewriteStatus InSingleTapPressed( | 187 ui::EventRewriteStatus InSingleTapPressed( |
170 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 188 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
171 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( | 189 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( |
172 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 190 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
173 ui::EventRewriteStatus InDoubleTapPending( | 191 ui::EventRewriteStatus InDoubleTapPending( |
174 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 192 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
175 ui::EventRewriteStatus InTouchReleasePending( | 193 ui::EventRewriteStatus InTouchReleasePending( |
176 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 194 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
177 ui::EventRewriteStatus InTouchExploration( | 195 ui::EventRewriteStatus InTouchExploration( |
178 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 196 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
| 197 ui::EventRewriteStatus InCornerPassthrough( |
| 198 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
179 ui::EventRewriteStatus InOneFingerPassthrough( | 199 ui::EventRewriteStatus InOneFingerPassthrough( |
180 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 200 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
181 ui::EventRewriteStatus InGestureInProgress( | 201 ui::EventRewriteStatus InGestureInProgress( |
182 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 202 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
183 ui::EventRewriteStatus InTouchExploreSecondPress( | 203 ui::EventRewriteStatus InTouchExploreSecondPress( |
184 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 204 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
185 ui::EventRewriteStatus InWaitForNoFingers( | 205 ui::EventRewriteStatus InWaitForNoFingers( |
186 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 206 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
187 ui::EventRewriteStatus InSlideGesture( | 207 ui::EventRewriteStatus InSlideGesture( |
188 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 208 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
189 ui::EventRewriteStatus InTwoFingerTap( | 209 ui::EventRewriteStatus InTwoFingerTap( |
190 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 210 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
191 | 211 |
192 // Returns the current time of the tick clock. | 212 // Returns the current time of the tick clock. |
193 base::TimeDelta Now(); | 213 base::TimeDelta Now(); |
194 | 214 |
195 // This timer is started every time we get the first press event, and | 215 // This timer is started every time we get the first press event, and |
196 // it fires after the double-click timeout elapses (300 ms by default). | 216 // it fires after the double-click timeout elapses (300 ms by default). |
197 // If the user taps and releases within 300 ms and doesn't press again, | 217 // If the user taps and releases within 300 ms and doesn't press again, |
198 // we treat that as a single mouse move (touch exploration) event. | 218 // we treat that as a single mouse move (touch exploration) event. |
199 void StartTapTimer(); | 219 void StartTapTimer(); |
200 void OnTapTimerFired(); | 220 void OnTapTimerFired(); |
201 | 221 |
| 222 // This timer is started every timer we get the first press event and the |
| 223 // finger is in the corner of the screen. |
| 224 // It fires after the corner passthrough delay elapses. If the |
| 225 // user is still in the corner by the time this timer fires, all subsequent |
| 226 // fingers added on the screen will be passed through. |
| 227 void OnPassthroughTimerFired(); |
| 228 |
202 // Dispatch a new event outside of the event rewriting flow. | 229 // Dispatch a new event outside of the event rewriting flow. |
203 void DispatchEvent(ui::Event* event); | 230 void DispatchEvent(ui::Event* event); |
204 | 231 |
205 // Overridden from GestureProviderAuraClient. | 232 // Overridden from GestureProviderAuraClient. |
206 // | 233 // |
207 // The gesture provider keeps track of all the touch events after | 234 // The gesture provider keeps track of all the touch events after |
208 // the user moves fast enough to trigger a gesture. After the user | 235 // the user moves fast enough to trigger a gesture. After the user |
209 // completes their gesture, this method will decide what keyboard | 236 // completes their gesture, this method will decide what keyboard |
210 // input their gesture corresponded to. | 237 // input their gesture corresponded to. |
211 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE; | 238 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // releases the touch explore finger, the other finger will continue with | 332 // releases the touch explore finger, the other finger will continue with |
306 // touch explore. Any fingers pressed past the first two are ignored. | 333 // touch explore. Any fingers pressed past the first two are ignored. |
307 TOUCH_EXPLORE_SECOND_PRESS, | 334 TOUCH_EXPLORE_SECOND_PRESS, |
308 | 335 |
309 // After the user double taps and holds with a single finger, all events | 336 // After the user double taps and holds with a single finger, all events |
310 // for that finger are passed through, displaced by an offset. Adding | 337 // for that finger are passed through, displaced by an offset. Adding |
311 // extra fingers has no effect. This state is left when the user removes | 338 // extra fingers has no effect. This state is left when the user removes |
312 // all fingers. | 339 // all fingers. |
313 ONE_FINGER_PASSTHROUGH, | 340 ONE_FINGER_PASSTHROUGH, |
314 | 341 |
| 342 // If the user has pressed and held down the left corner past long press, |
| 343 // then as long as they are holding the corner, all subsequent fingers |
| 344 // registered will be in passthrough. |
| 345 CORNER_PASSTHROUGH, |
| 346 |
315 // If the user added another finger in SINGLE_TAP_PRESSED, or if the user | 347 // If the user added another finger in SINGLE_TAP_PRESSED, or if the user |
316 // has multiple fingers fingers down in any other state between | 348 // has multiple fingers fingers down in any other state between |
317 // passthrough, touch exploration, and gestures, they must release | 349 // passthrough, touch exploration, and gestures, they must release |
318 // all fingers before completing any more actions. This state is | 350 // all fingers before completing any more actions. This state is |
319 // generally useful for developing new features, because it creates a | 351 // generally useful for developing new features, because it creates a |
320 // simple way to handle a dead end in user flow. | 352 // simple way to handle a dead end in user flow. |
321 WAIT_FOR_NO_FINGERS, | 353 WAIT_FOR_NO_FINGERS, |
322 | 354 |
323 // If the user is within the given bounds from an edge of the screen, not | 355 // If the user is within the given bounds from an edge of the screen, not |
324 // including corners, then the resulting movements will be interpreted as | 356 // including corners, then the resulting movements will be interpreted as |
325 // slide gestures. | 357 // slide gestures. |
326 SLIDE_GESTURE, | 358 SLIDE_GESTURE, |
327 | 359 |
328 // If the user taps the screen with two fingers and releases both fingers | 360 // If the user taps the screen with two fingers and releases both fingers |
329 // before the grace period has passed, spoken feedback will be silenced. | 361 // before the grace period has passed, spoken feedback will be silenced. |
330 TWO_FINGER_TAP, | 362 TWO_FINGER_TAP, |
331 }; | 363 }; |
332 | 364 |
333 enum ScreenLocation { | 365 enum ScreenLocation { |
334 // Hot "edges" of the screen are each represented by a respective bit. | 366 // Hot "edges" of the screen are each represented by a respective bit. |
335 NO_EDGE = 0, | 367 NO_EDGE = 0, |
336 RIGHT_EDGE = 1 << 0, | 368 RIGHT_EDGE = 1 << 0, |
337 TOP_EDGE = 1 << 1, | 369 TOP_EDGE = 1 << 1, |
338 LEFT_EDGE = 1 << 2, | 370 LEFT_EDGE = 1 << 2, |
339 BOTTOM_EDGE = 1 << 3, | 371 BOTTOM_EDGE = 1 << 3, |
| 372 BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE, |
| 373 BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE, |
340 }; | 374 }; |
341 | 375 |
342 // Given a point, if it is within the given bounds of an edge, returns the | 376 // Given a point, if it is within the given bounds of an edge, returns the |
343 // edge. If it is within the given bounds of two edges, returns an int with | 377 // edge. If it is within the given bounds of two edges, returns an int with |
344 // both bits that represent the respective edges turned on. Otherwise returns | 378 // both bits that represent the respective edges turned on. Otherwise returns |
345 // SCREEN_CENTER. | 379 // SCREEN_CENTER. |
346 int FindEdgesWithinBounds(gfx::Point point, float bounds); | 380 int FindEdgesWithinBounds(gfx::Point point, float bounds); |
347 | 381 |
348 // Set the state and modifies any variables related to the state change. | 382 // Set the state and modifies any variables related to the state change. |
349 // (e.g. resetting the gesture provider). | 383 // (e.g. resetting the gesture provider). |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // enters double-tap-hold passthrough, we need to update its location.) | 424 // enters double-tap-hold passthrough, we need to update its location.) |
391 scoped_ptr<ui::TouchEvent> last_unused_finger_event_; | 425 scoped_ptr<ui::TouchEvent> last_unused_finger_event_; |
392 | 426 |
393 // The last synthesized mouse move event. When the user double-taps, | 427 // The last synthesized mouse move event. When the user double-taps, |
394 // we send the passed-through tap to the location of this event. | 428 // we send the passed-through tap to the location of this event. |
395 scoped_ptr<ui::TouchEvent> last_touch_exploration_; | 429 scoped_ptr<ui::TouchEvent> last_touch_exploration_; |
396 | 430 |
397 // A timer that fires after the double-tap delay. | 431 // A timer that fires after the double-tap delay. |
398 base::OneShotTimer<TouchExplorationController> tap_timer_; | 432 base::OneShotTimer<TouchExplorationController> tap_timer_; |
399 | 433 |
| 434 // A timer that fires to enter passthrough. |
| 435 base::OneShotTimer<TouchExplorationController> passthrough_timer_; |
| 436 |
400 // A timer to fire an indicating sound when sliding to change volume. | 437 // A timer to fire an indicating sound when sliding to change volume. |
401 base::RepeatingTimer<TouchExplorationController> sound_timer_; | 438 base::RepeatingTimer<TouchExplorationController> sound_timer_; |
402 | 439 |
403 // A default gesture detector config, so we can share the same | 440 // A default gesture detector config, so we can share the same |
404 // timeout and pixel slop constants. | 441 // timeout and pixel slop constants. |
405 ui::GestureDetector::Config gesture_detector_config_; | 442 ui::GestureDetector::Config gesture_detector_config_; |
406 | 443 |
407 // Gesture Handler to interpret the touch events. | 444 // Gesture Handler to interpret the touch events. |
408 scoped_ptr<ui::GestureProviderAura> gesture_provider_; | 445 scoped_ptr<ui::GestureProviderAura> gesture_provider_; |
409 | 446 |
(...skipping 16 matching lines...) Expand all Loading... |
426 std::map<int, base::Closure> right_swipe_gestures_; | 463 std::map<int, base::Closure> right_swipe_gestures_; |
427 std::map<int, base::Closure> up_swipe_gestures_; | 464 std::map<int, base::Closure> up_swipe_gestures_; |
428 std::map<int, base::Closure> down_swipe_gestures_; | 465 std::map<int, base::Closure> down_swipe_gestures_; |
429 | 466 |
430 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 467 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
431 }; | 468 }; |
432 | 469 |
433 } // namespace ui | 470 } // namespace ui |
434 | 471 |
435 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 472 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
OLD | NEW |