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 0bcf10f6816befb5afa37c22ab11aa202c74688d..4405aa8819105815fa629f3e8da82e444a7cf280 100644 |
| --- a/chrome/browser/android/vr_shell/vr_controller.cc |
| +++ b/chrome/browser/android/vr_shell/vr_controller.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/logging.h" |
| #include "base/time/time.h" |
| +#include "chrome/browser/android/vr_shell/vr_math.h" |
| #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr.h" |
| #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/gvr_controller.h" |
| @@ -107,8 +108,12 @@ device::GvrGamepadData VrController::GetGamepadData() { |
| pad.timestamp = controller_state_->GetLastOrientationTimestamp(); |
| pad.touch_pos = controller_state_->GetTouchPos(); |
| pad.orientation = controller_state_->GetOrientation(); |
| - pad.accel = controller_state_->GetAccel(); |
| - pad.gyro = controller_state_->GetGyro(); |
| + |
| + // Use orientation to rotate acceleration/gyro into seated space. |
|
billorr
2017/03/27 17:33:53
nit: Accelerometer measurement or acceleration? I
klausw
2017/03/27 17:55:42
Acceleration and gravity are the same thing (blame
|
| + gvr::Mat4f pose_mat = QuatToMatrix(pad.orientation); |
| + pad.accel = MatrixVectorMul(pose_mat, controller_state_->GetAccel()); |
| + pad.gyro = MatrixVectorMul(pose_mat, controller_state_->GetGyro()); |
| + |
| pad.is_touching = controller_state_->IsTouching(); |
| pad.controller_button_pressed = |
| controller_state_->GetButtonState(GVR_CONTROLLER_BUTTON_CLICK); |
| @@ -203,9 +208,10 @@ void VrController::Initialize(gvr_context* gvr_context) { |
| int32_t options = gvr::ControllerApi::DefaultOptions(); |
| - // Enable non-default options - WebVR needs gyro, and since VrShell |
| - // implements GvrGamepadDataProvider we need this always. |
| + // Enable non-default options - WebVR needs gyro and linear acceleration, and |
| + // since VrShell implements GvrGamepadDataProvider we need this always. |
| options |= GVR_CONTROLLER_ENABLE_GYRO; |
| + options |= GVR_CONTROLLER_ENABLE_ACCEL; |
| CHECK(controller_api_->Init(options, gvr_context)); |