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

Side by Side Diff: chrome/browser/android/vr_shell/vr_controller.cc

Issue 2879973002: Expose Gamepad API instance for Cardboard button (Closed)
Patch Set: rebase Created 3 years, 7 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 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 <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 // Use orientation to rotate acceleration/gyro into seated space. 114 // Use orientation to rotate acceleration/gyro into seated space.
115 vr::Mat4f pose_mat; 115 vr::Mat4f pose_mat;
116 vr::QuatToMatrix(pad.orientation, &pose_mat); 116 vr::QuatToMatrix(pad.orientation, &pose_mat);
117 const gvr::Vec3f& accel = controller_state_->GetAccel(); 117 const gvr::Vec3f& accel = controller_state_->GetAccel();
118 const gvr::Vec3f& gyro = controller_state_->GetGyro(); 118 const gvr::Vec3f& gyro = controller_state_->GetGyro();
119 pad.accel = 119 pad.accel =
120 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(accel.x, accel.y, accel.z)); 120 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(accel.x, accel.y, accel.z));
121 pad.gyro = 121 pad.gyro =
122 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(gyro.x, gyro.y, gyro.z)); 122 vr::MatrixVectorMul(pose_mat, gfx::Vector3dF(gyro.x, gyro.y, gyro.z));
123 123
124 pad.is_touching = controller_state_->IsTouching(); 124 pad.is_controller_touching = controller_state_->IsTouching();
125 pad.controller_button_pressed = 125 pad.controller_button_pressed =
126 controller_state_->GetButtonState(GVR_CONTROLLER_BUTTON_CLICK); 126 controller_state_->GetButtonState(GVR_CONTROLLER_BUTTON_CLICK);
127 pad.right_handed = handedness_ == GVR_CONTROLLER_RIGHT_HANDED; 127 pad.right_handed = handedness_ == GVR_CONTROLLER_RIGHT_HANDED;
128 128
129 return pad; 129 return pad;
130 } 130 }
131 131
132 bool VrController::IsTouching() { 132 bool VrController::IsTouching() {
133 return controller_state_->IsTouching(); 133 return controller_state_->IsTouching();
134 } 134 }
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 const gfx::Vector2dF& velocity = ScaleVector2d(displacement, (1 / duration)); 437 const gfx::Vector2dF& velocity = ScaleVector2d(displacement, (1 / duration));
438 438
439 float weight = duration / (kRC + duration); 439 float weight = duration / (kRC + duration);
440 440
441 overall_velocity_ = ScaleVector2d(overall_velocity_, (1 - weight)) + 441 overall_velocity_ = ScaleVector2d(overall_velocity_, (1 - weight)) +
442 ScaleVector2d(velocity, weight); 442 ScaleVector2d(velocity, weight);
443 } 443 }
444 444
445 } // namespace vr_shell 445 } // namespace vr_shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698