| 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 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ |
| 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ | 6 #define CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chrome/browser/android/vr_shell/vr_controller_model.h" | 12 #include "chrome/browser/android/vr_shell/vr_controller_model.h" |
| 13 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" | 13 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" |
| 14 #include "device/vr/vr_types.h" | 14 #include "device/vr/vr_types.h" |
| 15 #include "third_party/WebKit/public/platform/WebGestureEvent.h" | 15 #include "third_party/WebKit/public/platform/WebGestureEvent.h" |
| 16 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 16 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 17 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" | 17 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
| 18 | 18 |
| 19 using blink::WebGestureEvent; | 19 using blink::WebGestureEvent; |
| 20 using blink::WebInputEvent; | 20 using blink::WebInputEvent; |
| 21 | 21 |
| 22 namespace gvr { | 22 namespace gvr { |
| 23 class ControllerState; | 23 class ControllerState; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace vr_shell { | 26 namespace vr_shell { |
| 27 | 27 |
| 28 class ElbowModel; |
| 29 |
| 30 // Angle (radians) the beam down from the controller axis, for wrist comfort. |
| 31 constexpr float kErgoAngleOffset = 0.26f; |
| 32 |
| 28 class VrController { | 33 class VrController { |
| 29 public: | 34 public: |
| 30 // Controller API entry point. | 35 // Controller API entry point. |
| 31 explicit VrController(gvr_context* gvr_context); | 36 explicit VrController(gvr_context* gvr_context); |
| 32 ~VrController(); | 37 ~VrController(); |
| 33 | 38 |
| 34 // Must be called when the Activity gets OnResume(). | 39 // Must be called when the Activity gets OnResume(). |
| 35 void OnResume(); | 40 void OnResume(); |
| 36 | 41 |
| 37 // Must be called when the Activity gets OnPause(). | 42 // Must be called when the Activity gets OnPause(). |
| 38 void OnPause(); | 43 void OnPause(); |
| 39 | 44 |
| 40 // Must be called when the GL renderer gets OnSurfaceCreated(). | 45 // Must be called when the GL renderer gets OnSurfaceCreated(). |
| 41 void Initialize(gvr_context* gvr_context); | 46 void Initialize(gvr_context* gvr_context); |
| 42 | 47 |
| 43 device::GvrGamepadData GetGamepadData(); | 48 device::GvrGamepadData GetGamepadData(); |
| 44 | 49 |
| 45 // Must be called when the GL renderer gets OnDrawFrame(). | 50 // Must be called when the GL renderer gets OnDrawFrame(). |
| 46 void UpdateState(); | 51 void UpdateState(const gfx::Vector3dF& head_direction); |
| 47 | 52 |
| 48 std::vector<std::unique_ptr<WebGestureEvent>> DetectGestures(); | 53 std::vector<std::unique_ptr<WebGestureEvent>> DetectGestures(); |
| 49 | 54 |
| 50 bool IsTouching(); | 55 bool IsTouching(); |
| 51 | 56 |
| 52 float TouchPosX(); | 57 float TouchPosX(); |
| 53 | 58 |
| 54 float TouchPosY(); | 59 float TouchPosY(); |
| 55 | 60 |
| 56 vr::Quatf Orientation() const; | 61 vr::Quatf Orientation() const; |
| 57 | |
| 58 void GetTransform(vr::Mat4f* out) const; | 62 void GetTransform(vr::Mat4f* out) const; |
| 63 float GetOpacity() const; |
| 64 gfx::Point3F GetPointerStart() const; |
| 59 | 65 |
| 60 VrControllerModel::State GetModelState() const; | 66 VrControllerModel::State GetModelState() const; |
| 61 | 67 |
| 62 bool TouchDownHappened(); | 68 bool TouchDownHappened(); |
| 63 | 69 |
| 64 bool TouchUpHappened(); | 70 bool TouchUpHappened(); |
| 65 | 71 |
| 66 bool ButtonUpHappened(gvr::ControllerButton button); | 72 bool ButtonUpHappened(gvr::ControllerButton button); |
| 67 bool ButtonDownHappened(gvr::ControllerButton button); | 73 bool ButtonDownHappened(gvr::ControllerButton button); |
| 68 bool ButtonState(gvr::ControllerButton button) const; | 74 bool ButtonState(gvr::ControllerButton button) const; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 169 |
| 164 // Displacement of the touch point from the previews to the current touch | 170 // Displacement of the touch point from the previews to the current touch |
| 165 gfx::Vector2dF displacement_; | 171 gfx::Vector2dF displacement_; |
| 166 | 172 |
| 167 int64_t last_touch_timestamp_ = 0; | 173 int64_t last_touch_timestamp_ = 0; |
| 168 int64_t last_timestamp_nanos_ = 0; | 174 int64_t last_timestamp_nanos_ = 0; |
| 169 | 175 |
| 170 // Number of consecutively extrapolated touch points | 176 // Number of consecutively extrapolated touch points |
| 171 int extrapolated_touch_ = 0; | 177 int extrapolated_touch_ = 0; |
| 172 | 178 |
| 179 std::unique_ptr<ElbowModel> elbow_model_; |
| 180 |
| 173 DISALLOW_COPY_AND_ASSIGN(VrController); | 181 DISALLOW_COPY_AND_ASSIGN(VrController); |
| 174 }; | 182 }; |
| 175 | 183 |
| 176 } // namespace vr_shell | 184 } // namespace vr_shell |
| 177 | 185 |
| 178 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ | 186 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ |
| OLD | NEW |