| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 } | 142 } |
| 143 | 143 |
| 144 bool VrController::ButtonDownHappened(gvr::ControllerButton button) { | 144 bool VrController::ButtonDownHappened(gvr::ControllerButton button) { |
| 145 return controller_state_->GetButtonDown(button); | 145 return controller_state_->GetButtonDown(button); |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool VrController::ButtonUpHappened(gvr::ControllerButton button) { | 148 bool VrController::ButtonUpHappened(gvr::ControllerButton button) { |
| 149 return controller_state_->GetButtonUp(button); | 149 return controller_state_->GetButtonUp(button); |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool VrController::ButtonState(gvr::ControllerButton button) { |
| 153 return controller_state_->GetButtonState(button); |
| 154 } |
| 155 |
| 152 bool VrController::IsConnected() { | 156 bool VrController::IsConnected() { |
| 153 return controller_state_->GetConnectionState() == gvr::kControllerConnected; | 157 return controller_state_->GetConnectionState() == gvr::kControllerConnected; |
| 154 } | 158 } |
| 155 | 159 |
| 156 void VrController::UpdateState() { | 160 void VrController::UpdateState() { |
| 157 const int32_t old_status = controller_state_->GetApiStatus(); | 161 const int32_t old_status = controller_state_->GetApiStatus(); |
| 158 const int32_t old_connection_state = controller_state_->GetConnectionState(); | 162 const int32_t old_connection_state = controller_state_->GetConnectionState(); |
| 159 // Read current controller state. | 163 // Read current controller state. |
| 160 controller_state_->Update(*controller_api_); | 164 controller_state_->Update(*controller_api_); |
| 161 // Print new API status and connection state, if they changed. | 165 // Print new API status and connection state, if they changed. |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 gvr::Vec2f velocity = Vector::ScalarMult(displacement, 1 / duration); | 428 gvr::Vec2f velocity = Vector::ScalarMult(displacement, 1 / duration); |
| 425 | 429 |
| 426 float weight = duration / (kRC + duration); | 430 float weight = duration / (kRC + duration); |
| 427 | 431 |
| 428 overall_velocity_ = | 432 overall_velocity_ = |
| 429 Vector::Add(Vector::ScalarMult(overall_velocity_, 1 - weight), | 433 Vector::Add(Vector::ScalarMult(overall_velocity_, 1 - weight), |
| 430 Vector::ScalarMult(velocity, weight)); | 434 Vector::ScalarMult(velocity, weight)); |
| 431 } | 435 } |
| 432 | 436 |
| 433 } // namespace vr_shell | 437 } // namespace vr_shell |
| OLD | NEW |