Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #include "chrome/browser/android/vr_shell/vr_controller.h" | 5 #include "chrome/browser/android/vr_shell/vr_controller.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 } | 195 } |
| 196 UpdateTouchInfo(); | 196 UpdateTouchInfo(); |
| 197 UpdateGestureFromTouchInfo(gesture.get()); | 197 UpdateGestureFromTouchInfo(gesture.get()); |
| 198 | 198 |
| 199 if (gesture->type == WebInputEvent::Undefined && | 199 if (gesture->type == WebInputEvent::Undefined && |
| 200 IsButtonDown(gvr::kControllerButtonClick)) { | 200 IsButtonDown(gvr::kControllerButtonClick)) { |
| 201 gesture->type = WebInputEvent::GestureTapDown; | 201 gesture->type = WebInputEvent::GestureTapDown; |
| 202 gesture->data.tapDown.width = 0; | 202 gesture->data.tapDown.width = 0; |
| 203 gesture->data.tapDown.height = 0; | 203 gesture->data.tapDown.height = 0; |
| 204 } | 204 } |
| 205 | |
| 206 if (state_ == SCROLLING && IsButtonDown(gvr::kControllerButtonClick)) | |
|
mthiesse
2016/11/28 16:06:57
nit: extract "state_ == SCROLLING && IsButtonDown(
bshe
2016/11/28 16:33:57
can this logic move to HandleScrollingState ? It p
asimjour1
2016/11/28 21:38:04
Done.
asimjour1
2016/11/28 21:38:04
This part is moved and there is no duplication any
| |
| 207 gesture->type = WebInputEvent::GestureScrollEnd; | |
| 208 | |
| 205 gesture->sourceDevice = blink::WebGestureDeviceTouchpad; | 209 gesture->sourceDevice = blink::WebGestureDeviceTouchpad; |
| 206 gesture_list.push_back(std::move(gesture)); | 210 gesture_list.push_back(std::move(gesture)); |
| 207 | 211 |
| 208 if (gesture_list.back()->type == WebInputEvent::GestureScrollEnd) { | 212 if (state_ == SCROLLING && IsButtonDown(gvr::kControllerButtonClick)) { |
| 213 std::unique_ptr<WebGestureEvent> tap_down(new WebGestureEvent()); | |
| 214 tap_down->type = WebInputEvent::GestureTapDown; | |
| 215 tap_down->timeStampSeconds = gesture_list.back()->timeStampSeconds; | |
| 216 tap_down->sourceDevice = blink::WebGestureDeviceTouchpad; | |
| 217 tap_down->data.tapDown.width = 0; | |
| 218 tap_down->data.tapDown.height = 0; | |
| 219 gesture_list.push_back(std::move(tap_down)); | |
| 220 Reset(); | |
| 221 } else if (gesture_list.back()->type == WebInputEvent::GestureScrollEnd) { | |
| 209 std::unique_ptr<WebGestureEvent> fling(new WebGestureEvent()); | 222 std::unique_ptr<WebGestureEvent> fling(new WebGestureEvent()); |
| 210 fling->timeStampSeconds = gesture_list.back()->timeStampSeconds; | 223 fling->timeStampSeconds = gesture_list.back()->timeStampSeconds; |
| 211 fling->sourceDevice = blink::WebGestureDeviceTouchpad; | 224 fling->sourceDevice = blink::WebGestureDeviceTouchpad; |
| 212 fling->type = WebInputEvent::GestureFlingStart; | 225 fling->type = WebInputEvent::GestureFlingStart; |
| 213 if (IsHorizontalGesture()) { | 226 if (IsHorizontalGesture()) { |
| 214 fling->data.flingStart.velocityX = | 227 fling->data.flingStart.velocityX = |
| 215 overall_velocity_.x * kDisplacementScaleFactor; | 228 overall_velocity_.x * kDisplacementScaleFactor; |
| 216 } else { | 229 } else { |
| 217 fling->data.flingStart.velocityY = | 230 fling->data.flingStart.velocityY = |
| 218 overall_velocity_.y * kDisplacementScaleFactor; | 231 overall_velocity_.y * kDisplacementScaleFactor; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 } | 274 } |
| 262 } | 275 } |
| 263 | 276 |
| 264 void VrController::HandleDetectingState(WebGestureEvent* gesture) { | 277 void VrController::HandleDetectingState(WebGestureEvent* gesture) { |
| 265 // User lifts up finger from touch pad. | 278 // User lifts up finger from touch pad. |
| 266 if (touch_info_->touch_up || !(touch_info_->is_touching)) { | 279 if (touch_info_->touch_up || !(touch_info_->is_touching)) { |
| 267 Reset(); | 280 Reset(); |
| 268 return; | 281 return; |
| 269 } | 282 } |
| 270 | 283 |
| 271 // Touch position is changed and the touch point moves outside of slop. | 284 // Touch position is changed and the touch point moves outside of slop. |
|
bshe
2016/11/28 16:33:57
update the comment here to include buttondown dete
asimjour1
2016/11/28 21:38:04
Done.
| |
| 272 if (UpdateCurrentTouchpoint() && touch_info_->is_touching && | 285 if (UpdateCurrentTouchpoint() && touch_info_->is_touching && |
| 273 !InSlop(touch_info_->touch_point.position)) { | 286 !InSlop(touch_info_->touch_point.position) && |
| 287 !IsButtonDown(gvr::kControllerButtonClick)) { | |
| 274 state_ = SCROLLING; | 288 state_ = SCROLLING; |
| 275 gesture->type = WebInputEvent::GestureScrollBegin; | 289 gesture->type = WebInputEvent::GestureScrollBegin; |
| 276 UpdateGesture(gesture); | 290 UpdateGesture(gesture); |
| 277 gesture->data.scrollBegin.deltaXHint = | 291 gesture->data.scrollBegin.deltaXHint = |
| 278 displacement_.x * kDisplacementScaleFactor; | 292 displacement_.x * kDisplacementScaleFactor; |
| 279 gesture->data.scrollBegin.deltaYHint = | 293 gesture->data.scrollBegin.deltaYHint = |
| 280 displacement_.y * kDisplacementScaleFactor; | 294 displacement_.y * kDisplacementScaleFactor; |
| 281 } | 295 } |
| 282 } | 296 } |
| 283 | 297 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 361 gvr::Vec2f velocity = Vector::ScalarMult(displacement, 1 / duration); | 375 gvr::Vec2f velocity = Vector::ScalarMult(displacement, 1 / duration); |
| 362 | 376 |
| 363 float weight = duration / (kRC + duration); | 377 float weight = duration / (kRC + duration); |
| 364 | 378 |
| 365 overall_velocity_ = | 379 overall_velocity_ = |
| 366 Vector::Add(Vector::ScalarMult(overall_velocity_, 1 - weight), | 380 Vector::Add(Vector::ScalarMult(overall_velocity_, 1 - weight), |
| 367 Vector::ScalarMult(velocity, weight)); | 381 Vector::ScalarMult(velocity, weight)); |
| 368 } | 382 } |
| 369 | 383 |
| 370 } // namespace vr_shell | 384 } // namespace vr_shell |
| OLD | NEW |