Chromium Code Reviews| Index: chrome/browser/android/vr_shell/vr_controller.cc |
| diff --git a/chrome/browser/android/vr_shell/vr_controller.cc b/chrome/browser/android/vr_shell/vr_controller.cc |
| index a628cb445f8e23d926fec8654bd90c7482067c0d..ac582671f4bc267739de390e7eb15c98145149bf 100644 |
| --- a/chrome/browser/android/vr_shell/vr_controller.cc |
| +++ b/chrome/browser/android/vr_shell/vr_controller.cc |
| @@ -10,7 +10,6 @@ |
| #include "base/logging.h" |
| #include "base/memory/ptr_util.h" |
| -#include "base/time/time.h" |
| #include "cc/base/math_util.h" |
| #include "chrome/browser/android/vr_shell/elbow_model.h" |
| #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| @@ -49,6 +48,8 @@ constexpr int kMaxNumOfExtrapolations = 2; |
| // Distance from the center of the controller to start rendering the laser. |
| constexpr float kLaserStartDisplacement = 0.045; |
| +constexpr float microsPerNano = 1000.0; |
|
cjgrant
2017/06/16 16:19:00
Why use a float? The types used with this are int
mthiesse
2017/06/16 17:24:11
Done.
|
| + |
| void ClampTouchpadPosition(gfx::Vector2dF* position) { |
| position->set_x(cc::MathUtil::ClampToRange(position->x(), 0.0f, 1.0f)); |
| position->set_y(cc::MathUtil::ClampToRange(position->y(), 0.0f, 1.0f)); |
| @@ -141,6 +142,21 @@ float VrController::TouchPosY() { |
| return controller_state_->GetTouchPos().y; |
| } |
| +base::TimeTicks VrController::GetLastOrientationTimestamp() const { |
| + return base::TimeTicks::FromInternalValue( |
| + controller_state_->GetLastOrientationTimestamp() / microsPerNano); |
| +} |
| + |
| +base::TimeTicks VrController::GetLastTouchTimestamp() const { |
| + return base::TimeTicks::FromInternalValue( |
| + controller_state_->GetLastTouchTimestamp() / microsPerNano); |
| +} |
| + |
| +base::TimeTicks VrController::GetLastButtonTimestamp() const { |
| + return base::TimeTicks::FromInternalValue( |
| + controller_state_->GetLastButtonTimestamp() / microsPerNano); |
| +} |
| + |
| gfx::Quaternion VrController::Orientation() const { |
| const gvr::Quatf& orientation = controller_state_->GetOrientation(); |
| return gfx::Quaternion(orientation.qx, orientation.qy, orientation.qz, |
| @@ -290,7 +306,7 @@ std::unique_ptr<GestureList> VrController::DetectGestures() { |
| void VrController::UpdateGestureFromTouchInfo(blink::WebGestureEvent* gesture) { |
| gesture->SetTimeStampSeconds( |
| - (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF()); |
| + (GetLastTouchTimestamp() - base::TimeTicks()).InSecondsF()); |
| switch (state_) { |
| // User has not put finger on touch pad. |
| case WAITING: |