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

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

Issue 2762003002: Refactor GVR controller gamepad API integration (Closed)
Patch Set: Rebase, no changes 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "device/vr/android/gvr/gvr_gamepad_data_provider.h"
12 #include "third_party/WebKit/public/platform/WebGestureEvent.h" 13 #include "third_party/WebKit/public/platform/WebGestureEvent.h"
13 #include "third_party/WebKit/public/platform/WebInputEvent.h" 14 #include "third_party/WebKit/public/platform/WebInputEvent.h"
14 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h" 15 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/ gvr_types.h"
15 16
16 using blink::WebGestureEvent; 17 using blink::WebGestureEvent;
17 using blink::WebInputEvent; 18 using blink::WebInputEvent;
18 19
19 namespace gvr { 20 namespace gvr {
20 class ControllerState; 21 class ControllerState;
21 } 22 }
22 23
23 namespace vr_shell { 24 namespace vr_shell {
24 25
25 class VrController { 26 class VrController {
26 public: 27 public:
27 // Controller API entry point. 28 // Controller API entry point.
28 explicit VrController(gvr_context* gvr_context); 29 explicit VrController(gvr_context* gvr_context);
29 ~VrController(); 30 ~VrController();
30 31
31 // Must be called when the Activity gets OnResume(). 32 // Must be called when the Activity gets OnResume().
32 void OnResume(); 33 void OnResume();
33 34
34 // Must be called when the Activity gets OnPause(). 35 // Must be called when the Activity gets OnPause().
35 void OnPause(); 36 void OnPause();
36 37
37 // Must be called when the GL renderer gets OnSurfaceCreated(). 38 // Must be called when the GL renderer gets OnSurfaceCreated().
38 void Initialize(gvr_context* gvr_context); 39 void Initialize(gvr_context* gvr_context);
39 40
41 device::GvrGamepadData GetGamepadData();
42
40 // Must be called when the GL renderer gets OnDrawFrame(). 43 // Must be called when the GL renderer gets OnDrawFrame().
41 void UpdateState(); 44 void UpdateState();
42 45
43 std::vector<std::unique_ptr<WebGestureEvent>> DetectGestures(); 46 std::vector<std::unique_ptr<WebGestureEvent>> DetectGestures();
44 47
45 bool IsTouching(); 48 bool IsTouching();
46 49
47 float TouchPosX(); 50 float TouchPosX();
48 51
49 float TouchPosY(); 52 float TouchPosY();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 std::unique_ptr<gvr::ControllerApi> controller_api_; 126 std::unique_ptr<gvr::ControllerApi> controller_api_;
124 127
125 // The last controller state (updated once per frame). 128 // The last controller state (updated once per frame).
126 std::unique_ptr<gvr::ControllerState> controller_state_; 129 std::unique_ptr<gvr::ControllerState> controller_state_;
127 130
128 float last_qx_; 131 float last_qx_;
129 bool pinch_started_; 132 bool pinch_started_;
130 bool zoom_in_progress_ = false; 133 bool zoom_in_progress_ = false;
131 bool touch_position_changed_ = false; 134 bool touch_position_changed_ = false;
132 135
136 // Handedness from user prefs (currently only read once on initialization)
137 gvr::ControllerHandedness handedness_;
138
133 // Current touch info after the extrapolation. 139 // Current touch info after the extrapolation.
134 std::unique_ptr<TouchInfo> touch_info_; 140 std::unique_ptr<TouchInfo> touch_info_;
135 141
136 // A pointer storing the touch point from previous frame. 142 // A pointer storing the touch point from previous frame.
137 std::unique_ptr<TouchPoint> prev_touch_point_; 143 std::unique_ptr<TouchPoint> prev_touch_point_;
138 144
139 // A pointer storing the touch point from current frame. 145 // A pointer storing the touch point from current frame.
140 std::unique_ptr<TouchPoint> cur_touch_point_; 146 std::unique_ptr<TouchPoint> cur_touch_point_;
141 147
142 // Initial touch point. 148 // Initial touch point.
(...skipping 13 matching lines...) Expand all
156 162
157 // Number of consecutively extrapolated touch points 163 // Number of consecutively extrapolated touch points
158 int extrapolated_touch_ = 0; 164 int extrapolated_touch_ = 0;
159 165
160 DISALLOW_COPY_AND_ASSIGN(VrController); 166 DISALLOW_COPY_AND_ASSIGN(VrController);
161 }; 167 };
162 168
163 } // namespace vr_shell 169 } // namespace vr_shell
164 170
165 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ 171 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/vr_shell/vr_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698