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

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

Issue 2795793002: Implementation of elbow model for the controller position and rotation. (Closed)
Patch Set: Rebasing. Created 3 years, 8 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 #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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void Reset(); 126 void Reset();
121 127
122 void UpdateGestureParameters(); 128 void UpdateGestureParameters();
123 129
124 // If the user is touching the touch pad and the touch point is different from 130 // If the user is touching the touch pad and the touch point is different from
125 // before, update the touch point and return true. Otherwise, return false. 131 // before, update the touch point and return true. Otherwise, return false.
126 bool UpdateCurrentTouchpoint(); 132 bool UpdateCurrentTouchpoint();
127 133
128 void UpdateOverallVelocity(); 134 void UpdateOverallVelocity();
129 135
136 float DeltaTimeSeconds();
137
130 // State of gesture detector. 138 // State of gesture detector.
131 GestureDetectorState state_; 139 GestureDetectorState state_;
132 140
133 std::unique_ptr<gvr::ControllerApi> controller_api_; 141 std::unique_ptr<gvr::ControllerApi> controller_api_;
134 142
135 // The last controller state (updated once per frame). 143 // The last controller state (updated once per frame).
136 std::unique_ptr<gvr::ControllerState> controller_state_; 144 std::unique_ptr<gvr::ControllerState> controller_state_;
137 145
138 float last_qx_; 146 float last_qx_;
139 bool pinch_started_; 147 bool pinch_started_;
(...skipping 23 matching lines...) Expand all
163 171
164 // Displacement of the touch point from the previews to the current touch 172 // Displacement of the touch point from the previews to the current touch
165 gfx::Vector2dF displacement_; 173 gfx::Vector2dF displacement_;
166 174
167 int64_t last_touch_timestamp_ = 0; 175 int64_t last_touch_timestamp_ = 0;
168 int64_t last_timestamp_nanos_ = 0; 176 int64_t last_timestamp_nanos_ = 0;
169 177
170 // Number of consecutively extrapolated touch points 178 // Number of consecutively extrapolated touch points
171 int extrapolated_touch_ = 0; 179 int extrapolated_touch_ = 0;
172 180
181 std::unique_ptr<ElbowModel> elbow_model_;
182
173 DISALLOW_COPY_AND_ASSIGN(VrController); 183 DISALLOW_COPY_AND_ASSIGN(VrController);
174 }; 184 };
175 185
176 } // namespace vr_shell 186 } // namespace vr_shell
177 187
178 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ 188 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698