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

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: Earcons through manager and delegate 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/timer/timer.h" 8 #include "base/timer/timer.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "ui/chromeos/ui_chromeos_export.h" 10 #include "ui/chromeos/ui_chromeos_export.h"
(...skipping 21 matching lines...) Expand all
32 public: 32 public:
33 virtual ~TouchExplorationControllerDelegate() {} 33 virtual ~TouchExplorationControllerDelegate() {}
34 34
35 // This function should be called whenever the delegate wants to play a sound 35 // This function should be called whenever the delegate wants to play a sound
36 // when the volume adjusts. 36 // when the volume adjusts.
37 virtual void PlayVolumeAdjustSound() = 0; 37 virtual void PlayVolumeAdjustSound() = 0;
38 38
39 // Takes an int from 0.0 to 100.0 that indicates the percent the volume 39 // Takes an int from 0.0 to 100.0 that indicates the percent the volume
40 // should be set to. 40 // should be set to.
41 virtual void SetOutputLevel(int volume) = 0; 41 virtual void SetOutputLevel(int volume) = 0;
42
43 // This function should be called whenever the delegate should play an earcon.
dmazzoni 2014/07/28 05:32:44 Update this comment; now the function is just for
lisayin 2014/07/28 16:28:54 Done.
44 // In the future a parameter can be passed to indicate what sound should be
45 // played.
46 virtual void PlayCornerPassthroughEarcon() = 0;
42 }; 47 };
43 48
44 // TouchExplorationController is used in tandem with "Spoken Feedback" to 49 // TouchExplorationController is used in tandem with "Spoken Feedback" to
45 // make the touch UI accessible. Gestures performed in the middle of the screen 50 // make the touch UI accessible. Gestures performed in the middle of the screen
46 // are mapped to accessiblity key shortcuts while gestures performed on the edge 51 // are mapped to accessiblity key shortcuts while gestures performed on the edge
47 // of the screen can change settings. 52 // of the screen can change settings.
48 // 53 //
49 // ** Short version ** 54 // ** Short version **
50 // 55 //
51 // At a high-level, single-finger events are used for accessibility - 56 // At a high-level, single-finger events are used for accessibility -
52 // exploring the screen gets turned into mouse moves (which can then be 57 // exploring the screen gets turned into mouse moves (which can then be
53 // spoken by an accessibility service running), a single tap while the user 58 // spoken by an accessibility service running), a single tap while the user
54 // is in touch exploration or a double-tap simulates a click, and gestures 59 // is in touch exploration or a double-tap simulates a click, and gestures
55 // can be used to send high-level accessibility commands. For example, a swipe 60 // can be used to send high-level accessibility commands. For example, a swipe
56 // right would correspond to the keyboard short cut shift+search+right. 61 // right would correspond to the keyboard short cut shift+search+right.
57 // When two or more fingers are pressed initially, from then on the events 62 // When two or more fingers are pressed initially, from then on the events
58 // are passed through, but with the initial finger removed - so if you swipe 63 // are passed through, but with the initial finger removed - so if you swipe
59 // down with two fingers, the running app will see a one-finger swipe. Slide 64 // down with two fingers, the running app will see a one-finger swipe. If the
65 // user holds down the corner of the screen until an earcon sounds, all
66 // subsequent fingers will also be passed through in a similar manner. Slide
60 // gestures performed on the edge of the screen can change settings 67 // gestures performed on the edge of the screen can change settings
61 // continuously. For example, sliding a finger along the right side of the 68 // continuously. For example, sliding a finger along the right side of the
62 // screen will change the volume. 69 // screen will change the volume.
63 // 70 //
64 // ** Long version ** 71 // ** Long version **
65 // 72 //
66 // Here are the details of the implementation: 73 // Here are the details of the implementation:
67 // 74 //
68 // 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.
69 // 76 //
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 ui::EventRewriteStatus InSingleTapPressed( 165 ui::EventRewriteStatus InSingleTapPressed(
159 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 166 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
160 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased( 167 ui::EventRewriteStatus InSingleTapOrTouchExploreReleased(
161 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 168 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
162 ui::EventRewriteStatus InDoubleTapPressed( 169 ui::EventRewriteStatus InDoubleTapPressed(
163 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 170 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
164 ui::EventRewriteStatus InTouchExploration( 171 ui::EventRewriteStatus InTouchExploration(
165 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 172 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
166 ui::EventRewriteStatus InTwoToOneFinger( 173 ui::EventRewriteStatus InTwoToOneFinger(
167 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 174 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
175 ui::EventRewriteStatus InCornerPassthrough(
176 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
168 ui::EventRewriteStatus InPassthrough( 177 ui::EventRewriteStatus InPassthrough(
169 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 178 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
170 ui::EventRewriteStatus InGestureInProgress( 179 ui::EventRewriteStatus InGestureInProgress(
171 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 180 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
172 ui::EventRewriteStatus InTouchExploreSecondPress( 181 ui::EventRewriteStatus InTouchExploreSecondPress(
173 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 182 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
174 ui::EventRewriteStatus InWaitForRelease( 183 ui::EventRewriteStatus InWaitForRelease(
175 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 184 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
176 ui::EventRewriteStatus InSlideGesture( 185 ui::EventRewriteStatus InSlideGesture(
177 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event); 186 const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event);
178 187
179 // This timer is started every time we get the first press event, and 188 // This timer is started every time we get the first press event and the
180 // it fires after the double-click timeout elapses (300 ms by default). 189 // finger is not in the corner of the screen.
190 // It fires after the double-click timeout elapses (300 ms by default).
181 // If the user taps and releases within 300 ms and doesn't press again, 191 // If the user taps and releases within 300 ms and doesn't press again,
182 // we treat that as a single mouse move (touch exploration) event. 192 // we treat that as a single mouse move (touch exploration) event. If the user
193 // completes a swipe gesture within 300 ms, then the gesture is processed.
183 void OnTapTimerFired(); 194 void OnTapTimerFired();
184 195
196 // This timer is started every timer we get the first press event and the
197 // finger is in the corner of the screen.
198 // It fires after the long_press timeout elapses (500 ms by default). If the
199 // user is still in the corner by the time this timre fires, all subsequent
200 // fingers added on the screen will be passed through.
201 void OnLongPressTimerFired();
202
185 // Dispatch a new event outside of the event rewriting flow. 203 // Dispatch a new event outside of the event rewriting flow.
186 void DispatchEvent(ui::Event* event); 204 void DispatchEvent(ui::Event* event);
187 205
188 // Overridden from GestureProviderAuraClient. 206 // Overridden from GestureProviderAuraClient.
189 // 207 //
190 // The gesture provider keeps track of all the touch events after 208 // The gesture provider keeps track of all the touch events after
191 // the user moves fast enough to trigger a gesture. After the user 209 // the user moves fast enough to trigger a gesture. After the user
192 // completes their gesture, this method will decide what keyboard 210 // completes their gesture, this method will decide what keyboard
193 // input their gesture corresponded to. 211 // input their gesture corresponded to.
194 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE; 212 virtual void OnGestureEvent(ui::GestureEvent* gesture) OVERRIDE;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 // touch explore. Any fingers pressed past the first two are ignored. 296 // touch explore. Any fingers pressed past the first two are ignored.
279 TOUCH_EXPLORE_SECOND_PRESS, 297 TOUCH_EXPLORE_SECOND_PRESS,
280 298
281 // The user placed two fingers down within the grace period. 299 // The user placed two fingers down within the grace period.
282 // We're now in two to one finger mode until one of the fingers is 300 // We're now in two to one finger mode until one of the fingers is
283 // lifted. The first finger is ignored and the events for the second 301 // lifted. The first finger is ignored and the events for the second
284 // finger are passed throuugh. If either finger is released, nothing 302 // finger are passed throuugh. If either finger is released, nothing
285 // happens until all fingers are up. 303 // happens until all fingers are up.
286 TWO_TO_ONE_FINGER, 304 TWO_TO_ONE_FINGER,
287 305
306 // If the user has pressed and held down the left corner past long press,
307 // then as long as they are holding the corner, all subsequent fingers
308 // registered will be in passthrough.
309 CORNER_PASSTHROUGH,
310
288 // If the user is in TWO_TO_ONE_FINGER with two fingers down and presses 311 // If the user is in TWO_TO_ONE_FINGER with two fingers down and presses
289 // a third finger, every finger and touch event is passed through until 312 // a third finger, every finger and touch event is passed through until
290 // all fingers are released. 313 // all fingers are released.
291 PASSTHROUGH, 314 PASSTHROUGH,
292 315
293 // If the user lifted a finger in TWO_TO_ONE_FINGER, they must release 316 // If the user lifted a finger in TWO_TO_ONE_FINGER, they must release
294 // all fingers before completing any more actions. This state is 317 // all fingers before completing any more actions. This state is
295 // generally useful for developing new features, because it creates a 318 // generally useful for developing new features, because it creates a
296 // simple way to handle a dead end in user flow. 319 // simple way to handle a dead end in user flow.
297 WAIT_FOR_RELEASE, 320 WAIT_FOR_RELEASE,
298 321
299 // 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
300 // including corners, then the resulting movements will be interpreted as 323 // including corners, then the resulting movements will be interpreted as
301 // slide gestures. 324 // slide gestures.
302 SLIDE_GESTURE, 325 SLIDE_GESTURE,
303 }; 326 };
304 327
305 enum ScreenLocation { 328 enum ScreenLocation {
306 // Hot "edges" of the screen are each represented by a respective bit. 329 // Hot "edges" of the screen are each represented by a respective bit.
307 NO_EDGE = 0, 330 NO_EDGE = 0,
308 RIGHT_EDGE = 1 << 0, 331 RIGHT_EDGE = 1 << 0,
309 TOP_EDGE = 1 << 1, 332 TOP_EDGE = 1 << 1,
310 LEFT_EDGE = 1 << 2, 333 LEFT_EDGE = 1 << 2,
311 BOTTOM_EDGE = 1 << 3, 334 BOTTOM_EDGE = 1 << 3,
335 BOTTOM_LEFT_CORNER = LEFT_EDGE | BOTTOM_EDGE,
336 BOTTOM_RIGHT_CORNER = RIGHT_EDGE | BOTTOM_EDGE,
312 }; 337 };
313 338
314 // Given a point, if it is within the given bounds of an edge, returns the 339 // Given a point, if it is within the given bounds of an edge, returns the
315 // edge. If it is within the given bounds of two edges, returns an int with 340 // edge. If it is within the given bounds of two edges, returns an int with
316 // both bits that represent the respective edges turned on. Otherwise returns 341 // both bits that represent the respective edges turned on. Otherwise returns
317 // SCREEN_CENTER. 342 // SCREEN_CENTER.
318 int FindEdgesWithinBounds(gfx::Point point, float bounds); 343 int FindEdgesWithinBounds(gfx::Point point, float bounds);
319 344
320 void VlogState(const char* function_name); 345 void VlogState(const char* function_name);
321 346
(...skipping 26 matching lines...) Expand all
348 373
349 // The last synthesized mouse move event. When the user double-taps, 374 // The last synthesized mouse move event. When the user double-taps,
350 // we send the passed-through tap to the location of this event. 375 // we send the passed-through tap to the location of this event.
351 scoped_ptr<ui::TouchEvent> last_touch_exploration_; 376 scoped_ptr<ui::TouchEvent> last_touch_exploration_;
352 377
353 // The last event from the finger that is being passed through in 378 // The last event from the finger that is being passed through in
354 // TWO_TO_ONE_FINGER. When the user lifts a finger during two to one, 379 // TWO_TO_ONE_FINGER. When the user lifts a finger during two to one,
355 // the location and id of the touch release is from here. 380 // the location and id of the touch release is from here.
356 scoped_ptr<ui::TouchEvent> last_two_to_one_; 381 scoped_ptr<ui::TouchEvent> last_two_to_one_;
357 382
358 // A timer to fire the mouse move event after the double-tap delay. 383 // A timer that fires after a long press delay.
384 base::OneShotTimer<TouchExplorationController> long_press_timer_;
385
386 // A timer that fires after a double tap delay.
359 base::OneShotTimer<TouchExplorationController> tap_timer_; 387 base::OneShotTimer<TouchExplorationController> tap_timer_;
360 388
361 // A timer to fire an indicating sound when sliding to change volume. 389 // A timer to fire an indicating sound when sliding to change volume.
362 base::RepeatingTimer<TouchExplorationController> sound_timer_; 390 base::RepeatingTimer<TouchExplorationController> sound_timer_;
363 391
364 // For testing only, an event handler to use for generated events 392 // For testing only, an event handler to use for generated events
365 // outside of the normal event rewriting flow. 393 // outside of the normal event rewriting flow.
366 ui::EventHandler* event_handler_for_testing_; 394 ui::EventHandler* event_handler_for_testing_;
367 395
368 // A default gesture detector config, so we can share the same 396 // A default gesture detector config, so we can share the same
369 // timeout and pixel slop constants. 397 // timeout and pixel slop constants.
370 ui::GestureDetector::Config gesture_detector_config_; 398 ui::GestureDetector::Config gesture_detector_config_;
371 399
372 // Gesture Handler to interpret the touch events. 400 // Gesture Handler to interpret the touch events.
373 ui::GestureProviderAura gesture_provider_; 401 ui::GestureProviderAura gesture_provider_;
374 402
375 // The previous state entered. 403 // The previous state entered.
376 State prev_state_; 404 State prev_state_;
377 405
378 // A copy of the previous event passed. 406 // A copy of the previous event passed.
379 scoped_ptr<ui::TouchEvent> prev_event_; 407 scoped_ptr<ui::TouchEvent> prev_event_;
380 408
381 // This toggles whether VLOGS are turned on or not. 409 // This toggles whether VLOGS are turned on or not.
382 bool VLOG_on_; 410 bool VLOG_on_;
383 411
412 // Indicates if a finger is in the lower left corner waiting for the timer to
413 // run out.
414 bool waiting_for_corner_passthrough_;
415
384 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController); 416 DISALLOW_COPY_AND_ASSIGN(TouchExplorationController);
385 }; 417 };
386 418
387 } // namespace ui 419 } // namespace ui
388 420
389 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_ 421 #endif // UI_CHROMEOS_TOUCH_EXPLORATION_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698