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