Chromium Code Reviews| 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 "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "chrome/browser/android/vr_shell/vr_gesture.h" | 9 #include "chrome/browser/android/vr_shell/vr_gesture.h" |
| 10 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr.h" | 10 #include "third_party/gvr-android-sdk/src/ndk-beta/include/vr/gvr/capi/include/g vr.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 void OnResume(); | 23 void OnResume(); |
| 24 | 24 |
| 25 // Must be called when the Activity gets OnPause(). | 25 // Must be called when the Activity gets OnPause(). |
| 26 void OnPause(); | 26 void OnPause(); |
| 27 | 27 |
| 28 // Must be called when the GL renderer gets OnSurfaceCreated(). | 28 // Must be called when the GL renderer gets OnSurfaceCreated(). |
| 29 void Initialize(gvr_context* gvr_context); | 29 void Initialize(gvr_context* gvr_context); |
| 30 | 30 |
| 31 // Must be called when the GL renderer gets OnDrawFrame(). | 31 // Must be called when the GL renderer gets OnDrawFrame(). |
| 32 void UpdateState(); | 32 void UpdateState(); |
| 33 VrGesture DetectGesture(); | 33 std::unique_ptr<VrGesture> DetectGesture(); |
| 34 | 34 |
| 35 bool IsTouching(); | 35 bool IsTouching(); |
| 36 | 36 |
| 37 float TouchPosX(); | 37 float TouchPosX(); |
| 38 | 38 |
| 39 float TouchPosY(); | 39 float TouchPosY(); |
| 40 | 40 |
| 41 const gvr::Quatf Orientation(); | 41 const gvr::Quatf Orientation(); |
| 42 | 42 |
| 43 bool IsTouchDown(); | 43 bool IsTouchDown(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 bool GetButtonLongPressFromButtonInfo(); | 81 bool GetButtonLongPressFromButtonInfo(); |
| 82 | 82 |
| 83 // Handle the waiting state. | 83 // Handle the waiting state. |
| 84 void HandleWaitingState(); | 84 void HandleWaitingState(); |
| 85 | 85 |
| 86 // Handle the detecting state. | 86 // Handle the detecting state. |
| 87 void HandleDetectingState(); | 87 void HandleDetectingState(); |
| 88 | 88 |
| 89 // Handle the scrolling state. | 89 // Handle the scrolling state. |
| 90 void HandleScrollingState(); | 90 void HandleScrollingState(); |
| 91 void Update(const gvr_controller_state* controller_state); | 91 void Update(); |
| 92 void Update(bool touch_up, | |
| 93 bool touch_down, | |
| 94 bool is_touching, | |
| 95 const gvr::Vec2f position, | |
| 96 int64_t timestamp); | |
| 97 | 92 |
| 98 // Returns true if the touch position is within the slop of the initial touch | 93 // Returns true if the touch position is within the slop of the initial touch |
| 99 // point, false otherwise. | 94 // point, false otherwise. |
| 100 bool InSlop(const gvr::Vec2f touch_position); | 95 bool InSlop(const gvr::Vec2f touch_position); |
| 101 | 96 |
| 102 void Reset(); | 97 void Reset(); |
| 103 | 98 |
| 104 size_t GetGestureListSize() { return gesture_list_.size(); } | |
| 105 | |
| 106 const VrGesture* GetGesturePtr(const size_t index); | |
| 107 | |
| 108 // Update gesture parameters, | 99 // Update gesture parameters, |
| 109 void UpdateGesture(VrGesture* gesture); | 100 void UpdateGesture(VrGesture* gesture); |
| 110 | 101 |
| 111 // If the user is touching the touch pad and the touch point is different from | 102 // If the user is touching the touch pad and the touch point is different from |
| 112 // before, update the touch point and return true. Otherwise, return false. | 103 // before, update the touch point and return true. Otherwise, return false. |
| 113 bool UpdateCurrentTouchpoint(); | 104 bool UpdateCurrentTouchpoint(); |
| 114 | 105 |
| 115 // State of gesture detector. | 106 // State of gesture detector. |
| 116 GestureDetectorState state_; | 107 GestureDetectorState state_; |
| 117 | 108 |
| 118 std::unique_ptr<gvr::ControllerApi> controller_api_; | 109 std::unique_ptr<gvr::ControllerApi> controller_api_; |
| 119 | 110 |
| 120 // The last controller state (updated once per frame). | 111 // The last controller state (updated once per frame). |
| 121 gvr::ControllerState controller_state_; | 112 gvr::ControllerState controller_state_; |
| 122 | 113 |
| 123 float last_qx_; | 114 float last_qx_; |
| 124 bool pinch_started_; | 115 bool pinch_started_; |
| 125 bool zoom_in_progress_ = false; | 116 bool zoom_in_progress_ = false; |
| 126 | 117 |
| 127 std::vector<VrGesture> gesture_list_; | 118 std::unique_ptr<VrGesture> gesture_; |
|
asimjour
2016/10/03 14:40:16
We should be able to send multiple gestures. For e
mthiesse
2016/10/03 15:39:15
Sure, but right now the API only supports returnin
| |
| 128 std::unique_ptr<TouchInfo> touch_info_; | 119 std::unique_ptr<TouchInfo> touch_info_; |
| 129 | 120 |
| 130 // A pointer storing the touch point from previous frame. | 121 // A pointer storing the touch point from previous frame. |
| 131 std::unique_ptr<TouchPoint> prev_touch_point_; | 122 std::unique_ptr<TouchPoint> prev_touch_point_; |
| 132 | 123 |
| 133 // A pointer storing the touch point from current frame. | 124 // A pointer storing the touch point from current frame. |
| 134 std::unique_ptr<TouchPoint> cur_touch_point_; | 125 std::unique_ptr<TouchPoint> cur_touch_point_; |
| 135 | 126 |
| 136 // Initial touch point. | 127 // Initial touch point. |
| 137 std::unique_ptr<TouchPoint> init_touch_point_; | 128 std::unique_ptr<TouchPoint> init_touch_point_; |
| 138 | 129 |
| 139 // Overall velocity | 130 // Overall velocity |
| 140 gvr::Vec2f overall_velocity_; | 131 gvr::Vec2f overall_velocity_; |
| 141 | 132 |
| 142 DISALLOW_COPY_AND_ASSIGN(VrController); | 133 DISALLOW_COPY_AND_ASSIGN(VrController); |
| 143 }; | 134 }; |
| 144 | 135 |
| 145 } // namespace vr_shell | 136 } // namespace vr_shell |
| 146 | 137 |
| 147 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ | 138 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ |
| OLD | NEW |