| 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" | |
| 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" | 15 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
| 18 | 16 |
| 19 using blink::WebGestureEvent; | 17 namespace blink { |
| 20 using blink::WebInputEvent; | 18 class WebGestureEvent; |
| 19 } |
| 21 | 20 |
| 22 namespace gvr { | 21 namespace gvr { |
| 23 class ControllerState; | 22 class ControllerState; |
| 24 } | 23 } |
| 25 | 24 |
| 26 namespace vr_shell { | 25 namespace vr_shell { |
| 27 | 26 |
| 28 class ElbowModel; | 27 class ElbowModel; |
| 29 | 28 |
| 30 // Angle (radians) the beam down from the controller axis, for wrist comfort. | 29 // Angle (radians) the beam down from the controller axis, for wrist comfort. |
| 31 constexpr float kErgoAngleOffset = 0.26f; | 30 constexpr float kErgoAngleOffset = 0.26f; |
| 32 | 31 |
| 32 using GestureList = std::vector<std::unique_ptr<blink::WebGestureEvent>>; |
| 33 |
| 33 class VrController { | 34 class VrController { |
| 34 public: | 35 public: |
| 35 // Controller API entry point. | 36 // Controller API entry point. |
| 36 explicit VrController(gvr_context* gvr_context); | 37 explicit VrController(gvr_context* gvr_context); |
| 37 ~VrController(); | 38 ~VrController(); |
| 38 | 39 |
| 39 // Must be called when the Activity gets OnResume(). | 40 // Must be called when the Activity gets OnResume(). |
| 40 void OnResume(); | 41 void OnResume(); |
| 41 | 42 |
| 42 // Must be called when the Activity gets OnPause(). | 43 // Must be called when the Activity gets OnPause(). |
| 43 void OnPause(); | 44 void OnPause(); |
| 44 | 45 |
| 45 device::GvrGamepadData GetGamepadData(); | 46 device::GvrGamepadData GetGamepadData(); |
| 46 | 47 |
| 47 // Must be called when the GL renderer gets OnDrawFrame(). | 48 // Must be called when the GL renderer gets OnDrawFrame(). |
| 48 void UpdateState(const gfx::Vector3dF& head_direction); | 49 void UpdateState(const gfx::Vector3dF& head_direction); |
| 49 | 50 |
| 50 std::vector<std::unique_ptr<WebGestureEvent>> DetectGestures(); | 51 std::unique_ptr<GestureList> DetectGestures(); |
| 51 | 52 |
| 52 bool IsTouching(); | 53 bool IsTouching(); |
| 53 | 54 |
| 54 float TouchPosX(); | 55 float TouchPosX(); |
| 55 | 56 |
| 56 float TouchPosY(); | 57 float TouchPosY(); |
| 57 | 58 |
| 58 vr::Quatf Orientation() const; | 59 vr::Quatf Orientation() const; |
| 59 void GetTransform(vr::Mat4f* out) const; | 60 void GetTransform(vr::Mat4f* out) const; |
| 60 float GetOpacity() const; | 61 float GetOpacity() const; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 }; | 93 }; |
| 93 | 94 |
| 94 struct ButtonInfo { | 95 struct ButtonInfo { |
| 95 gvr::ControllerButton button; | 96 gvr::ControllerButton button; |
| 96 bool button_up; | 97 bool button_up; |
| 97 bool button_down; | 98 bool button_down; |
| 98 bool button_state; | 99 bool button_state; |
| 99 int64_t timestamp; | 100 int64_t timestamp; |
| 100 }; | 101 }; |
| 101 | 102 |
| 102 void UpdateGestureFromTouchInfo(WebGestureEvent* gesture); | 103 void UpdateGestureFromTouchInfo(blink::WebGestureEvent* gesture); |
| 103 | 104 |
| 104 bool GetButtonLongPressFromButtonInfo(); | 105 bool GetButtonLongPressFromButtonInfo(); |
| 105 | 106 |
| 106 // Handle the waiting state. | 107 // Handle the waiting state. |
| 107 void HandleWaitingState(WebGestureEvent* gesture); | 108 void HandleWaitingState(blink::WebGestureEvent* gesture); |
| 108 | 109 |
| 109 // Handle the detecting state. | 110 // Handle the detecting state. |
| 110 void HandleDetectingState(WebGestureEvent* gesture); | 111 void HandleDetectingState(blink::WebGestureEvent* gesture); |
| 111 | 112 |
| 112 // Handle the scrolling state. | 113 // Handle the scrolling state. |
| 113 void HandleScrollingState(WebGestureEvent* gesture); | 114 void HandleScrollingState(blink::WebGestureEvent* gesture); |
| 114 void UpdateTouchInfo(); | 115 void UpdateTouchInfo(); |
| 115 | 116 |
| 116 // Returns true if the touch position is within the slop of the initial touch | 117 // Returns true if the touch position is within the slop of the initial touch |
| 117 // point, false otherwise. | 118 // point, false otherwise. |
| 118 bool InSlop(const gfx::Vector2dF touch_position); | 119 bool InSlop(const gfx::Vector2dF touch_position); |
| 119 | 120 |
| 120 // Returns true if the gesture is in horizontal direction. | 121 // Returns true if the gesture is in horizontal direction. |
| 121 bool IsHorizontalGesture(); | 122 bool IsHorizontalGesture(); |
| 122 | 123 |
| 123 void Reset(); | 124 void Reset(); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 int extrapolated_touch_ = 0; | 177 int extrapolated_touch_ = 0; |
| 177 | 178 |
| 178 std::unique_ptr<ElbowModel> elbow_model_; | 179 std::unique_ptr<ElbowModel> elbow_model_; |
| 179 | 180 |
| 180 DISALLOW_COPY_AND_ASSIGN(VrController); | 181 DISALLOW_COPY_AND_ASSIGN(VrController); |
| 181 }; | 182 }; |
| 182 | 183 |
| 183 } // namespace vr_shell | 184 } // namespace vr_shell |
| 184 | 185 |
| 185 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ | 186 #endif // CHROME_BROWSER_ANDROID_VR_SHELL_VR_CONTROLLER_H_ |
| OLD | NEW |