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

Unified Diff: ui/chromeos/touch_exploration_controller.cc

Issue 330763007: Swipe Gestures for Accessibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gesture-vlogs
Patch Set: Rebased off Master Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/chromeos/touch_exploration_controller.h ('k') | ui/chromeos/touch_exploration_controller_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/chromeos/touch_exploration_controller.cc
diff --git a/ui/chromeos/touch_exploration_controller.cc b/ui/chromeos/touch_exploration_controller.cc
index a253c828a4efcfba636b5351be792f202a2ef7c1..0e19b3a544ffa85f1c4ea17cdaec59a6326ee2f0 100644
--- a/ui/chromeos/touch_exploration_controller.cc
+++ b/ui/chromeos/touch_exploration_controller.cc
@@ -39,6 +39,7 @@ TouchExplorationController::TouchExplorationController(
initial_touch_id_passthrough_mapping_(kTouchIdUnassigned),
state_(NO_FINGERS_DOWN),
event_handler_for_testing_(NULL),
+ gesture_provider_(this),
prev_state_(NO_FINGERS_DOWN) {
CHECK(root_window);
root_window->GetHost()->GetEventSource()->AddEventRewriter(this);
@@ -127,6 +128,8 @@ ui::EventRewriteStatus TouchExplorationController::RewriteEvent(
return InDoubleTapPressed(touch_event, rewritten_event);
case TOUCH_EXPLORATION:
return InTouchExploration(touch_event, rewritten_event);
+ case GESTURE_IN_PROGRESS:
+ return InGestureInProgress(touch_event, rewritten_event);
case PASSTHROUGH_MINUS_ONE:
return InPassthroughMinusOne(touch_event, rewritten_event);
case TOUCH_EXPLORE_SECOND_PRESS:
@@ -152,6 +155,8 @@ ui::EventRewriteStatus TouchExplorationController::InNoFingersDown(
gesture_detector_config_.double_tap_timeout,
this,
&TouchExplorationController::OnTapTimerFired);
+ gesture_provider_.OnTouchEvent(event);
+ gesture_provider_.OnTouchEventAck(false);
state_ = SINGLE_TAP_PRESSED;
VLOG_STATE();
return ui::EVENT_REWRITE_DISCARD;
@@ -176,13 +181,28 @@ ui::EventRewriteStatus TouchExplorationController::InSingleTapPressed(
VLOG_STATE();
return EVENT_REWRITE_DISCARD;
} else if (type == ui::ET_TOUCH_MOVED) {
- // If the user moves far enough from the initial touch location (outside
- // the "slop" region, jump to the touch exploration mode early.
- // TODO(evy, lisayin): Add gesture recognition here instead -
- // we should probably jump to gesture mode here if the velocity is
- // high enough, and touch exploration if the velocity is lower.
- float delta = (event.location() - initial_press_->location()).Length();
- if (delta > gesture_detector_config_.touch_slop) {
+ // If the user moves fast enough from the initial touch location,
+ // start gesture detection
+ float delta_time =
+ (event.time_stamp() - initial_press_->time_stamp()).InSecondsF();
+ float delta_distance =
+ (event.location() - initial_press_->location()).Length();
+ float velocity = delta_distance / delta_time;
+ VLOG(0) << "\n Delta time: " << delta_time
+ << "\n Delta distance: " << delta_distance
+ << "\n Velocity of click: " << velocity
+ << "\n Minimum swipe velocity: "
+ << gesture_detector_config_.minimum_swipe_velocity;
+ if (velocity > gesture_detector_config_.minimum_swipe_velocity) {
+ gesture_provider_.OnTouchEvent(event);
dmazzoni 2014/06/20 16:26:54 I think you're forwarding the same event to the ge
lisayin 2014/06/20 21:34:39 Fixed.
+ gesture_provider_.OnTouchEventAck(false);
+ state_ = GESTURE_IN_PROGRESS;
+ VLOG_STATE();
+ return InGestureInProgress(event, rewritten_event);
+ }
+ // Otherwise, if the user moves far enough from the initial touch location
+ // outside the "slop" region, jump to the touch exploration mode early.
+ else if (delta_distance > gesture_detector_config_.touch_slop) {
EnterTouchToMouseMode();
state_ = TOUCH_EXPLORATION;
VLOG_STATE();
@@ -283,6 +303,26 @@ ui::EventRewriteStatus TouchExplorationController::InTouchExploration(
return ui::EVENT_REWRITE_REWRITTEN;
}
+ui::EventRewriteStatus TouchExplorationController::InGestureInProgress(
+ const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) {
+ ui::EventType type = event.type();
+ gfx::PointF location = event.location_f();
+ if (type == ui::ET_TOUCH_PRESSED) {
+ return EVENT_REWRITE_DISCARD;
+ }
+ if (type == ui::ET_TOUCH_MOVED) {
+ gesture_provider_.OnTouchEvent(event);
+ gesture_provider_.OnTouchEventAck(false);
+ }
+ if (type == ui::ET_TOUCH_RELEASED || type == ui::ET_TOUCH_CANCELLED) {
+ gesture_provider_.OnTouchEvent(event);
+ gesture_provider_.OnTouchEventAck(true);
dmazzoni 2014/06/20 16:26:54 Why true here and false otherwise?
lisayin 2014/06/20 21:34:39 To be honest, it was something that I was just try
+ if (current_touch_ids_.size() == 0)
+ ResetToNoFingersDown();
+}
+ return ui::EVENT_REWRITE_DISCARD;
+}
+
ui::EventRewriteStatus TouchExplorationController::InPassthroughMinusOne(
const ui::TouchEvent& event, scoped_ptr<ui::Event>* rewritten_event) {
ui::EventType type = event.type();
@@ -402,6 +442,34 @@ void TouchExplorationController::DispatchEvent(ui::Event* event) {
root_window_->GetHost()->dispatcher()->OnEventFromSource(event);
}
+void TouchExplorationController::OnGestureEvent(
+ ui::GestureEvent* gesture) {
+ std::string message = "\n Gesture Triggered: ";
+ switch (gesture->type()) {
+ case ET_GESTURE_SHOW_PRESS:
+ message += "ET_GESTURE_SHOW_PRESS";
+ break;
+ case ET_GESTURE_SWIPE:
+ message += "ET_GESTURE_SWIPE";
+ break;
+ case ET_GESTURE_LONG_TAP:
+ message += "ET_GESTURE_LONG_TAP";
+ break;
+ case ET_GESTURE_LONG_PRESS:
+ message += "ET_GESTURE_LONG_PRESS";
+ break;
+ case ET_GESTURE_PINCH_UPDATE:
+ message += "ET_GESTURE_PINCH_UPDATE";
+ break;
+ case ET_GESTURE_PINCH_END:
+ message += "ET_GESTURE_PINCH_END";
+ break;
+ default:
+ return;
+ }
+ VLOG(0) << message;
+}
+
scoped_ptr<ui::Event> TouchExplorationController::CreateMouseMoveEvent(
const gfx::PointF& location,
int flags) {
@@ -424,6 +492,7 @@ void TouchExplorationController::EnterTouchToMouseMode() {
}
void TouchExplorationController::ResetToNoFingersDown() {
+ gesture_provider_.GetAndResetPendingGestures();
state_ = NO_FINGERS_DOWN;
initial_touch_id_passthrough_mapping_ = kTouchIdUnassigned;
VLOG_STATE();
@@ -470,6 +539,8 @@ const char* TouchExplorationController::EnumStateToString(State state) {
return "DOUBLE_TAP_PRESSED";
case TOUCH_EXPLORATION:
return "TOUCH_EXPLORATION";
+ case GESTURE_IN_PROGRESS:
+ return "GESTURE_IN_PROGRESS";
case PASSTHROUGH_MINUS_ONE:
return "PASSTHROUGH_MINUS_ONE";
case TOUCH_EXPLORE_SECOND_PRESS:
« no previous file with comments | « ui/chromeos/touch_exploration_controller.h ('k') | ui/chromeos/touch_exploration_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698