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

Unified Diff: chrome/browser/android/vr_shell/vr_controller.cc

Issue 2775283004: Rendering Daydream controller in a fixed position. (Closed)
Patch Set: Moving code to more appropriate locations. Created 3 years, 9 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
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..b64671687be12e2dc4d8823ac6d5ef4400fd27f2 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"
@@ -40,6 +41,8 @@ constexpr float kNanoSecondsPerSecond = 1.0e9f;
constexpr int kMaxNumOfExtrapolations = 2;
+static constexpr gvr::Vec3f kControllerPosition = {0.2f, -0.5f, -0.15f};
+
class Vector {
public:
static inline void ClampTouchpadPosition(gvr::Vec2f* position) {
@@ -129,10 +132,34 @@ float VrController::TouchPosY() {
return controller_state_->GetTouchPos().y;
}
-const gvr::Quatf VrController::Orientation() {
+gvr::Quatf VrController::Orientation() const {
return controller_state_->GetOrientation();
}
+gvr::Mat4f VrController::GetTransform() const {
+ // TODO(acondor): Position and orientation needs to be obtained
+ // from an elbow model.
+ // Placing the controller in a fixed position for now.
+ gvr::Mat4f mat;
+ SetIdentityM(mat);
+ // Changing rotation point.
+ TranslateM(mat, mat, 0, 0, 0.05);
+ mat = MatrixMul(QuatToMatrix(Orientation()), mat);
+ TranslateM(mat, mat, kControllerPosition.x, kControllerPosition.y,
+ kControllerPosition.z - 0.05);
+ return mat;
+}
+
+VrControllerModel::State VrController::GetModelState() const {
+ if (ButtonState(gvr::ControllerButton::GVR_CONTROLLER_BUTTON_CLICK))
+ return VrControllerModel::TOUCHPAD;
+ if (ButtonState(gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP))
+ return VrControllerModel::APP;
+ if (ButtonState(gvr::ControllerButton::GVR_CONTROLLER_BUTTON_HOME))
+ return VrControllerModel::SYSTEM;
+ return VrControllerModel::IDLE;
+}
+
bool VrController::TouchDownHappened() {
return controller_state_->GetTouchDown();
}
@@ -149,6 +176,10 @@ bool VrController::ButtonUpHappened(gvr::ControllerButton button) {
return controller_state_->GetButtonUp(button);
}
+bool VrController::ButtonState(gvr::ControllerButton button) const {
+ return controller_state_->GetButtonState(button);
+}
+
bool VrController::IsConnected() {
return controller_state_->GetConnectionState() == gvr::kControllerConnected;
}
« no previous file with comments | « chrome/browser/android/vr_shell/vr_controller.h ('k') | chrome/browser/android/vr_shell/vr_controller_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698