Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: ui/chromeos/touch_exploration_controller.h

Issue 410783002: Corner Passthrough for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@side-gestures
Patch Set: Rebase off Master Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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;
39
40 // This function should be called when the volume adjust earcon should be
41 // played
42 virtual void PlayVolumeAdjustEarcon() = 0;
43
44 // This function should be called when the passthrough earcon should be
45 // played.
46 virtual void PlayPassthroughEarcon() = 0;
47
48 // This function should be called when the exit screen earcon should be
49 // played.
50 virtual void PlayExitScreenEarcon() = 0;
51
52 // This function should be called when the enter screen earcon should be
53 // played.
54 virtual void PlayEnterScreenEarcon() = 0;
43 }; 55 };
44 56
45 // TouchExplorationController is used in tandem with "Spoken Feedback" to 57 // TouchExplorationController is used in tandem with "Spoken Feedback" to
46 // make the touch UI accessible. Gestures performed in the middle of the screen 58 // 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 59 // are mapped to accessiblity key shortcuts while gestures performed on the edge
48 // of the screen can change settings. 60 // of the screen can change settings.
49 // 61 //
50 // ** Short version ** 62 // ** Short version **
51 // 63 //
52 // At a high-level, single-finger events are used for accessibility - 64 // At a high-level, single-finger events are used for accessibility -
53 // exploring the screen gets turned into mouse moves (which can then be 65 // 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 66 // 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 67 // 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 68 // 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. 69 // 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 70 // 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 71 // 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 72 // down with two fingers, the running app will see a one-finger swipe. If the
73 // user holds down the corner of the screen until an earcon sounds, all
74 // subsequent fingers will also be passed through in a similar manner. Slide
61 // gestures performed on the edge of the screen can change settings 75 // gestures performed on the edge of the screen can change settings
62 // continuously. For example, sliding a finger along the right side of the 76 // continuously. For example, sliding a finger along the right side of the
63 // screen will change the volume. 77 // screen will change the volume.
64 // When a user double taps and holds with one finger, the finger is passed 78 // When a user double taps and holds with one finger, the finger is passed
65 // through as if accessibility was turned off. 79 // through as if accessibility was turned off.
66 // 80 //
67 // ** Long version ** 81 // ** Long version **
68 // 82 //
69 // Here are the details of the implementation: 83 // Here are the details of the implementation:
70 // 84 //
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 ui::EventRewriteStatus InSingleTapPressed( 178 ui::EventRewriteStatus InSingleTapPressed(
165 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 179 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
166 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( 180 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased(
167 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 181 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
168 ui::EventRewriteStatus InDoubleTapPending( 182 ui::EventRewriteStatus InDoubleTapPending(
169 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 183 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
170 ui::EventRewriteStatus InTouchReleasePending( 184 ui::EventRewriteStatus InTouchReleasePending(
171 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 185 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
172 ui::EventRewriteStatus InTouchExploration( 186 ui::EventRewriteStatus InTouchExploration(
173 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 187 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
174 ui::EventRewriteStatus InTwoToOneFinger( 188 ui::EventRewriteStatus InCornerPassthrough(
175 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 189 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
176 ui::EventRewriteStatus InOneFingerPassthrough( 190 ui::EventRewriteStatus InOneFingerPassthrough(
177 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 191 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
178 ui::EventRewriteStatus InGestureInProgress( 192 ui::EventRewriteStatus InGestureInProgress(
179 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 193 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
180 ui::EventRewriteStatus InTouchExploreSecondPress( 194 ui::EventRewriteStatus InTouchExploreSecondPress(
181 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 195 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
182 ui::EventRewriteStatus InWaitForOneFinger( 196 ui::EventRewriteStatus InWaitForOneFinger(
183 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 197 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
184 ui::EventRewriteStatus InSlideGesture( 198 ui::EventRewriteStatus InSlideGesture(
185 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 199 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
186 200
187 // Returns the current time of the tick clock. 201 // Returns the current time of the tick clock.
188 base::TimeDelta Now(); 202 base::TimeDelta Now();
189 203
190 // This timer is started every time we get the first press event, and 204 // 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). 205 // 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, 206 // 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. 207 // we treat that as a single mouse move (touch exploration) event.
194 void StartTapTimer(); 208 void StartTapTimer();
195 void OnTapTimerFired(); 209 void OnTapTimerFired();
196 210
211 // This timer is started every timer we get the first press event and the
212 // finger is in the corner of the screen.
213 // It fires after the long_press timeout elapses (500 ms by default). If the
aboxhall 2014/08/06 18:10:45 Looks like it's 700ms now. Maybe just refer to the
lisayin 2014/08/06 20:37:35 Done.
214 // user is still in the corner by the time this timre fires, all subsequent
215 // fingers added on the screen will be passed through.
216 void OnLongPressTimerFired();
217
197 // Dispatch a new event outside of the event rewriting flow. 218 // Dispatch a new event outside of the event rewriting flow.
198 void DispatchEvent(ui::Event* event); 219 void DispatchEvent(ui::Event* event);
199 220
200 // Overridden from GestureProviderAuraClient. 221 // Overridden from GestureProviderAuraClient.
201 // 222 //
202 // The gesture provider keeps track of all the touch events after 223 // The gesture provider keeps track of all the touch events after
203 // the user moves fast enough to trigger a gesture. After the user 224 // the user moves fast enough to trigger a gesture. After the user
204 // completes their gesture, this method will decide what keyboard 225 // completes their gesture, this method will decide what keyboard
205 // input their gesture corresponded to. 226 // input their gesture corresponded to.
206 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE; 227 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 // releases the touch explore finger, the other finger will continue with 316 // releases the touch explore finger, the other finger will continue with
296 // touch explore. Any fingers pressed past the first two are ignored. 317 // touch explore. Any fingers pressed past the first two are ignored.
297 TOUCH_EXPLORE_SECOND_PRESS, 318 TOUCH_EXPLORE_SECOND_PRESS,
298 319
299 // After the user double taps and holds with a single finger, all events 320 // After the user double taps and holds with a single finger, all events
300 // for that finger are passed through, displaced by an offset. Adding 321 // for that finger are passed through, displaced by an offset. Adding
301 // extra fingers has no effect. This state is left when the user removes 322 // extra fingers has no effect. This state is left when the user removes
302 // all fingers. 323 // all fingers.
303 ONE_FINGER_PASSTHROUGH, 324 ONE_FINGER_PASSTHROUGH,
304 325
326 // If the user has pressed and held down the left corner past long press,
327 // then as long as they are holding the corner, all subsequent fingers
328 // registered will be in passthrough.
329 CORNER_PASSTHROUGH,
330
305 // If the user added another finger in SINGLE_TAP_PRESSED, or if the user 331 // If the user added another finger in SINGLE_TAP_PRESSED, or if the user
306 // has multiple fingers fingers down in any other state between 332 // has multiple fingers fingers down in any other state between
307 // passthrough, touch exploration, and gestures, they must release 333 // passthrough, touch exploration, and gestures, they must release
308 // all fingers except before completing any more actions. This state is 334 // all fingers except before completing any more actions. This state is
309 // generally useful for developing new features, because it creates a 335 // generally useful for developing new features, because it creates a
310 // simple way to handle a dead end in user flow. 336 // simple way to handle a dead end in user flow.
311 WAIT_FOR_ONE_FINGER, 337 WAIT_FOR_ONE_FINGER,
312 338
313 // If the user is within the given bounds from an edge of the screen, not 339 // 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 340 // including corners, then the resulting movements will be interpreted as
315 // slide gestures. 341 // slide gestures.
316 SLIDE_GESTURE, 342 SLIDE_GESTURE,
317 }; 343 };
318 344
319 enum ScreenLocation { 345 enum ScreenLocation {
320 // Hot "edges" of the screen are each represented by a respective bit. 346 // Hot "edges" of the screen are each represented by a respective bit.
321 NO_EDGE = 0, 347 NO_EDGE = 0,
322 RIGHT_EDGE = 1 << 0, 348 RIGHT_EDGE = 1 << 0,
323 TOP_EDGE = 1 << 1, 349 TOP_EDGE = 1 << 1,
324 LEFT_EDGE = 1 << 2, 350 LEFT_EDGE = 1 << 2,
325 BOTTOM_EDGE = 1 << 3, 351 BOTTOM_EDGE = 1 << 3,
352 BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE,
353 BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE,
326 }; 354 };
327 355
328 // Given a point, if it is within the given bounds of an edge, returns the 356 // Given a point, if it is within the given bounds of an edge, returns the
329 // edge. If it is within the given bounds of two edges, returns an int with 357 // edge. If it is within the given bounds of two edges, returns an int with
330 // both bits that represent the respective edges turned on. Otherwise returns 358 // both bits that represent the respective edges turned on. Otherwise returns
331 // SCREEN_CENTER. 359 // SCREEN_CENTER.
332 int FindEdgesWithinBounds(gfx::Point point, float bounds); 360 int FindEdgesWithinBounds(gfx::Point point, float bounds);
333 361
334 void VlogState(const char* function_name); 362 void VlogState(const char* function_name);
335 363
(...skipping 25 matching lines...) Expand all
361 389
362 // Stores the most recent event from a finger that is currently not 390 // 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 391 // 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.) 392 // enters double-tap-hold passthrough, we need to update its location.)
365 scoped_ptr<ui::TouchEvent> last_unused_finger_event_; 393 scoped_ptr<ui::TouchEvent> last_unused_finger_event_;
366 394
367 // The last synthesized mouse move event. When the user double-taps, 395 // The last synthesized mouse move event. When the user double-taps,
368 // we send the passed-through tap to the location of this event. 396 // we send the passed-through tap to the location of this event.
369 scoped_ptr<ui::TouchEvent> last_touch_exploration_; 397 scoped_ptr<ui::TouchEvent> last_touch_exploration_;
370 398
371 // A timer to fire the mouse move event after the double-tap delay. 399 // A timer that fires after the double-tap delay.
372 base::OneShotTimer<TouchExplorationController> tap_timer_; 400 base::OneShotTimer<TouchExplorationController> tap_timer_;
373 401
402 // A timer that fires after a long press delay.
403 base::OneShotTimer<TouchExplorationController> long_press_timer_;
404
374 // A timer to fire an indicating sound when sliding to change volume. 405 // A timer to fire an indicating sound when sliding to change volume.
375 base::RepeatingTimer<TouchExplorationController> sound_timer_; 406 base::RepeatingTimer<TouchExplorationController> sound_timer_;
376 407
377 // A default gesture detector config, so we can share the same 408 // A default gesture detector config, so we can share the same
378 // timeout and pixel slop constants. 409 // timeout and pixel slop constants.
379 ui::GestureDetector::Config gesture_detector_config_; 410 ui::GestureDetector::Config gesture_detector_config_;
380 411
381 // Gesture Handler to interpret the touch events. 412 // Gesture Handler to interpret the touch events.
382 ui::GestureProviderAura gesture_provider_; 413 ui::GestureProviderAura gesture_provider_;
383 414
384 // The previous state entered. 415 // The previous state entered.
385 State prev_state_; 416 State prev_state_;
386 417
387 // A copy of the previous event passed. 418 // A copy of the previous event passed.
388 scoped_ptr<ui::TouchEvent> prev_event_; 419 scoped_ptr<ui::TouchEvent> prev_event_;
389 420
390 // This toggles whether VLOGS are turned on or not. 421 // This toggles whether VLOGS are turned on or not.
391 bool VLOG_on_; 422 bool VLOG_on_;
392 423
393 // When touch_exploration_controller gets time relative to real time during 424 // When touch_exploration_controller gets time relative to real time during
394 // testing, this clock is set to the simulated clock and used. 425 // testing, this clock is set to the simulated clock and used.
395 base::TickClock* tick_clock_; 426 base::TickClock* tick_clock_;
396 427
428 // Indicates if a finger is in the lower left corner waiting for the timer to
429 // run out.
430 bool waiting_for_corner_passthrough_;
431
397 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); 432 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController);
398 }; 433 };
399 434
400 } // namespace ui 435 } // namespace ui
401 436
402 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ 437 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698