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 22 matching lines...) Expand all Loading... | |
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 | 36 // This function should be called whenever the delegate wants to play a sound |
37 // when the volume adjusts. | 37 // when the volume adjusts. |
38 virtual void PlayVolumeAdjustSound() = 0; | 38 virtual void PlayVolumeAdjustSound() = 0; |
39 | 39 |
40 // Takes an int from 0.0 to 100.0 that indicates the percent the volume | 40 // Takes an int from 0.0 to 100.0 that indicates the percent the volume |
41 // should be set to. | 41 // should be set to. |
42 virtual void SetOutputLevel(int volume) = 0; | 42 virtual void SetOutputLevel(int volume) = 0; |
43 | |
44 // Silences spoken feedback. | |
45 virtual void SilenceSpokenFeedback() = 0; | |
43 }; | 46 }; |
44 | 47 |
45 // TouchExplorationController is used in tandem with "Spoken Feedback" to | 48 // TouchExplorationController is used in tandem with "Spoken Feedback" to |
46 // make the touch UI accessible. Gestures performed in the middle of the screen | 49 // make the touch UI accessible. Gestures performed in the middle of the screen |
47 // are mapped to accessiblity key shortcuts while gestures performed on the edge | 50 // are mapped to accessiblity key shortcuts while gestures performed on the edge |
48 // of the screen can change settings. | 51 // of the screen can change settings. |
49 // | 52 // |
50 // ** Short version ** | 53 // ** Short version ** |
51 // | 54 // |
52 // At a high-level, single-finger events are used for accessibility - | 55 // At a high-level, single-finger events are used for accessibility - |
53 // exploring the screen gets turned into mouse moves (which can then be | 56 // exploring the screen gets turned into mouse moves (which can then be |
54 // spoken by an accessibility service running), a single tap while the user | 57 // spoken by an accessibility service running), a single tap while the user |
55 // is in touch exploration or a double-tap simulates a click, and gestures | 58 // is in touch exploration or a double-tap simulates a click, and gestures |
56 // can be used to send high-level accessibility commands. For example, a swipe | 59 // can be used to send high-level accessibility commands. For example, a swipe |
57 // right would correspond to the keyboard short cut shift+search+right. | 60 // right would correspond to the keyboard short cut shift+search+right. |
58 // When two or more fingers are pressed initially, from then on the events | 61 // When two or more fingers are pressed initially, from then on the events |
59 // are passed through, but with the initial finger removed - so if you swipe | 62 // are passed through, but with the initial finger removed - so if you swipe |
60 // down with two fingers, the running app will see a one-finger swipe. Slide | 63 // down with two fingers, the running app will see a one-finger swipe. Slide |
61 // gestures performed on the edge of the screen can change settings | 64 // gestures performed on the edge of the screen can change settings |
62 // continuously. For example, sliding a finger along the right side of the | 65 // continuously. For example, sliding a finger along the right side of the |
63 // screen will change the volume. | 66 // screen will change the volume. When a user double taps and holds with one |
64 // When a user double taps and holds with one finger, the finger is passed | 67 // finger, the finger is passed through as if accessibility was turned off. If |
65 // through as if accessibility was turned off. | 68 // the user taps the screen with two fingers, the user can silence spoken |
69 // feedback if it is playing. | |
66 // | 70 // |
67 // ** Long version ** | 71 // ** Long version ** |
68 // | 72 // |
69 // Here are the details of the implementation: | 73 // Here are the details of the implementation: |
70 // | 74 // |
71 // When the first touch is pressed, a 300 ms grace period timer starts. | 75 // When the first touch is pressed, a 300 ms grace period timer starts. |
72 // | 76 // |
73 // If the user keeps their finger down for more than 300 ms and doesn't | 77 // If the user keeps their finger down for more than 300 ms and doesn't |
74 // perform a supported accessibility gesture in that time (e.g. swipe right), | 78 // perform a supported accessibility gesture in that time (e.g. swipe right), |
75 // they enter touch exploration mode, and all movements are translated into | 79 // they enter touch exploration mode, and all movements are translated into |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // location, and every following event is offset by the same amount. | 113 // location, and every following event is offset by the same amount. |
110 // | 114 // |
111 // If any other fingers are added or removed, they are ignored. Once the | 115 // If any other fingers are added or removed, they are ignored. Once the |
112 // passthrough finger is released, passthrough stops and the user is reset | 116 // passthrough finger is released, passthrough stops and the user is reset |
113 // to no fingers down state. | 117 // to no fingers down state. |
114 // | 118 // |
115 // If the user enters touch exploration mode, they can click without lifting | 119 // If the user enters touch exploration mode, they can click without lifting |
116 // their touch exploration finger by tapping anywhere else on the screen with | 120 // their touch exploration finger by tapping anywhere else on the screen with |
117 // a second finger, while the touch exploration finger is still pressed. | 121 // a second finger, while the touch exploration finger is still pressed. |
118 // | 122 // |
123 // Once touch exploration mode has been activated, it remains in that mode until | |
124 // all fingers have been released. | |
125 // | |
119 // If the user places a finger on the edge of the screen and moves their finger | 126 // If the user places a finger on the edge of the screen and moves their finger |
120 // past slop, a slide gesture is performed. The user can then slide one finger | 127 // past slop, a slide gesture is performed. The user can then slide one finger |
121 // along an edge of the screen and continuously control a setting. Once the user | 128 // along an edge of the screen and continuously control a setting. Once the user |
122 // enters this state, the boundaries that define an edge expand so that the user | 129 // enters this state, the boundaries that define an edge expand so that the user |
123 // can now adjust the setting within a slightly bigger width along the screen. | 130 // can now adjust the setting within a slightly bigger width along the screen. |
124 // If the user exits this area without lifting their finger, they will not be | 131 // If the user exits this area without lifting their finger, they will not be |
125 // able to perform any actions, however if they keep their finger down and | 132 // able to perform any actions, however if they keep their finger down and |
126 // return to the "hot edge," then they can still adjust the setting. In order to | 133 // return to the "hot edge," then they can still adjust the setting. In order to |
127 // perform other touch accessibility movements, the user must lift their finger. | 134 // perform other touch accessibility movements, the user must lift their finger. |
128 // If additional fingers are added while in this state, the user will transition | 135 // If additional fingers are added while in this state, the user will transition |
129 // to passthrough. | 136 // to passthrough. |
130 // | 137 // |
131 // Currently, only the right edge is mapped to control the volume. Volume | 138 // Currently, only the right edge is mapped to control the volume. Volume |
132 // control along the edge of the screen is directly proportional to where the | 139 // control along the edge of the screen is directly proportional to where the |
133 // user's finger is located on the screen. The top right corner of the screen | 140 // user's finger is located on the screen. The top right corner of the screen |
134 // automatically sets the volume to 100% and the bottome right corner of the | 141 // automatically sets the volume to 100% and the bottome right corner of the |
135 // screen automatically sets the volume to 0% once the user has moved past slop. | 142 // screen automatically sets the volume to 0% once the user has moved past slop. |
136 // | 143 // |
137 // Once touch exploration mode has been activated, | 144 // If the user taps the screen with two fingers and lifts both fingers before |
138 // it remains in that mode until all fingers have been released. | 145 // the grace period has passed, spoken feedback is silenced. |
139 // | 146 // |
140 // The caller is expected to retain ownership of instances of this class and | 147 // The caller is expected to retain ownership of instances of this class and |
141 // destroy them before |root_window| is destroyed. | 148 // destroy them before |root_window| is destroyed. |
142 class UI_CHROMEOS_EXPORT TouchExplorationController | 149 class UI_CHROMEOS_EXPORT TouchExplorationController |
143 : public ui::EventRewriter, | 150 : public ui::EventRewriter, |
144 public ui::GestureProviderAuraClient { | 151 public ui::GestureProviderAuraClient { |
145 public: | 152 public: |
146 explicit TouchExplorationController( | 153 explicit TouchExplorationController( |
147 aura::Window* root_window, | 154 aura::Window* root_window, |
148 ui::TouchExplorationControllerDelegate* delegate); | 155 ui::TouchExplorationControllerDelegate* delegate); |
(...skipping 27 matching lines...) Expand all Loading... | |
176 ui::EventRewriteStatus InOneFingerPassthrough( | 183 ui::EventRewriteStatus InOneFingerPassthrough( |
177 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 184 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
178 ui::EventRewriteStatus InGestureInProgress( | 185 ui::EventRewriteStatus InGestureInProgress( |
179 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 186 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
180 ui::EventRewriteStatus InTouchExploreSecondPress( | 187 ui::EventRewriteStatus InTouchExploreSecondPress( |
181 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 188 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
182 ui::EventRewriteStatus InWaitForOneFinger( | 189 ui::EventRewriteStatus InWaitForOneFinger( |
183 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 190 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
184 ui::EventRewriteStatus InSlideGesture( | 191 ui::EventRewriteStatus InSlideGesture( |
185 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | 192 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); |
193 ui::EventRewriteStatus InTwoFingerTap( | |
194 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); | |
186 | 195 |
187 // Returns the current time of the tick clock. | 196 // Returns the current time of the tick clock. |
188 base::TimeDelta Now(); | 197 base::TimeDelta Now(); |
189 | 198 |
190 // This timer is started every time we get the first press event, and | 199 // This timer is started every time we get the first press event, and |
191 // it fires after the double-click timeout elapses (300 ms by default). | 200 // it fires after the double-click timeout elapses (300 ms by default). |
192 // If the user taps and releases within 300 ms and doesn't press again, | 201 // If the user taps and releases within 300 ms and doesn't press again, |
193 // we treat that as a single mouse move (touch exploration) event. | 202 // we treat that as a single mouse move (touch exploration) event. |
194 void StartTapTimer(); | 203 void StartTapTimer(); |
195 void OnTapTimerFired(); | 204 void OnTapTimerFired(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 // passthrough, touch exploration, and gestures, they must release | 316 // passthrough, touch exploration, and gestures, they must release |
308 // all fingers except before completing any more actions. This state is | 317 // all fingers except before completing any more actions. This state is |
309 // generally useful for developing new features, because it creates a | 318 // generally useful for developing new features, because it creates a |
310 // simple way to handle a dead end in user flow. | 319 // simple way to handle a dead end in user flow. |
311 WAIT_FOR_ONE_FINGER, | 320 WAIT_FOR_ONE_FINGER, |
312 | 321 |
313 // If the user is within the given bounds from an edge of the screen, not | 322 // If the user is within the given bounds from an edge of the screen, not |
314 // including corners, then the resulting movements will be interpreted as | 323 // including corners, then the resulting movements will be interpreted as |
315 // slide gestures. | 324 // slide gestures. |
316 SLIDE_GESTURE, | 325 SLIDE_GESTURE, |
326 | |
327 // If the user taps the screen with two fingers and releases both fingers | |
328 // before the grace period has passed, spoken feedback will be silenced. | |
329 TWO_FINGER_TAP, | |
317 }; | 330 }; |
318 | 331 |
319 enum ScreenLocation { | 332 enum ScreenLocation { |
320 // Hot "edges" of the screen are each represented by a respective bit. | 333 // Hot "edges" of the screen are each represented by a respective bit. |
321 NO_EDGE = 0, | 334 NO_EDGE = 0, |
322 RIGHT_EDGE = 1 << 0, | 335 RIGHT_EDGE = 1 << 0, |
323 TOP_EDGE = 1 << 1, | 336 TOP_EDGE = 1 << 1, |
324 LEFT_EDGE = 1 << 2, | 337 LEFT_EDGE = 1 << 2, |
325 BOTTOM_EDGE = 1 << 3, | 338 BOTTOM_EDGE = 1 << 3, |
326 }; | 339 }; |
(...skipping 21 matching lines...) Expand all Loading... | |
348 | 361 |
349 // Map of touch ids to their last known location. | 362 // Map of touch ids to their last known location. |
350 std::map<int, gfx::PointF> touch_locations_; | 363 std::map<int, gfx::PointF> touch_locations_; |
351 | 364 |
352 // The current state. | 365 // The current state. |
353 State state_; | 366 State state_; |
354 | 367 |
355 // A copy of the event from the initial touch press. | 368 // A copy of the event from the initial touch press. |
356 scoped_ptr<ui::TouchEvent> initial_press_; | 369 scoped_ptr<ui::TouchEvent> initial_press_; |
357 | 370 |
371 // Map of touch ids to where its initial press occured relative to the screen. | |
James Cook
2014/08/08 20:07:23
occured -> occurred
lisayin
2014/08/08 20:14:05
Done.
| |
372 std::map<int, gfx::Point> initial_presses_; | |
373 | |
358 // In one finger passthrough, the touch is displaced relative to the | 374 // In one finger passthrough, the touch is displaced relative to the |
359 // last touch exploration location. | 375 // last touch exploration location. |
360 gfx::Vector2d passthrough_offset_; | 376 gfx::Vector2d passthrough_offset_; |
361 | 377 |
362 // Stores the most recent event from a finger that is currently not | 378 // Stores the most recent event from a finger that is currently not |
363 // sending events through, but might in the future (e.g. before a finger | 379 // sending events through, but might in the future (e.g. before a finger |
364 // enters double-tap-hold passthrough, we need to update its location.) | 380 // enters double-tap-hold passthrough, we need to update its location.) |
365 scoped_ptr<ui::TouchEvent> last_unused_finger_event_; | 381 scoped_ptr<ui::TouchEvent> last_unused_finger_event_; |
366 | 382 |
367 // The last synthesized mouse move event. When the user double-taps, | 383 // The last synthesized mouse move event. When the user double-taps, |
(...skipping 25 matching lines...) Expand all Loading... | |
393 // When touch_exploration_controller gets time relative to real time during | 409 // When touch_exploration_controller gets time relative to real time during |
394 // testing, this clock is set to the simulated clock and used. | 410 // testing, this clock is set to the simulated clock and used. |
395 base::TickClock* tick_clock_; | 411 base::TickClock* tick_clock_; |
396 | 412 |
397 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); | 413 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); |
398 }; | 414 }; |
399 | 415 |
400 } // namespace ui | 416 } // namespace ui |
401 | 417 |
402 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ | 418 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ |
OLD | NEW |