| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H | 5 #ifndef DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H |
| 6 #define DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H | 6 #define DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H |
| 7 | 7 |
| 8 #include "device/vr/vr_types.h" | 8 #include "device/vr/vr_types.h" |
| 9 | 9 |
| 10 namespace device { | 10 namespace device { |
| 11 | 11 |
| 12 class GvrGamepadDataFetcher; | 12 class GvrGamepadDataFetcher; |
| 13 | 13 |
| 14 // Subset of GVR controller data needed for the gamepad API. Filled in | 14 // Subset of GVR controller data needed for the gamepad API. Filled in |
| 15 // by vr_shell's VrController and consumed by GvrGamepadDataFetcher. | 15 // by vr_shell's VrController and consumed by GvrGamepadDataFetcher. |
| 16 struct GvrGamepadData { | 16 struct GvrGamepadData { |
| 17 int64_t timestamp; | 17 int64_t timestamp; |
| 18 gfx::Vector2dF touch_pos; | 18 gfx::Vector2dF touch_pos; // Controller touch position. |
| 19 vr::Quatf orientation; | 19 vr::Quatf orientation; |
| 20 gfx::Vector3dF accel; | 20 gfx::Vector3dF accel; |
| 21 gfx::Vector3dF gyro; | 21 gfx::Vector3dF gyro; |
| 22 bool is_touching; | 22 bool is_controller_touching; |
| 23 bool controller_button_pressed; | 23 bool controller_button_pressed; |
| 24 bool right_handed; | 24 bool right_handed; |
| 25 bool is_screen_touching; // For cardboard, only the screen touch matters |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 // This class exposes GVR controller data to the gamepad API. Data is | 28 // This class exposes GVR controller data to the gamepad API. Data is |
| 28 // polled by VrShellGl, then pushed from VrShell which implements the | 29 // polled by VrShellGl, then pushed from VrShell which implements the |
| 29 // GvrGamepadDataProvider interface. | 30 // GvrGamepadDataProvider interface. |
| 30 // | 31 // |
| 31 // More specifically, here's the lifecycle, assuming VrShell | 32 // More specifically, here's the lifecycle, assuming VrShell |
| 32 // implements GvrGamepadDataProvider: | 33 // implements GvrGamepadDataProvider: |
| 33 // | 34 // |
| 34 // - VrShell creates GvrGamepadDataFetcherFactory from | 35 // - VrShell creates GvrGamepadDataFetcherFactory from |
| (...skipping 23 matching lines...) Expand all Loading... |
| 58 virtual void UpdateGamepadData(GvrGamepadData data) = 0; | 59 virtual void UpdateGamepadData(GvrGamepadData data) = 0; |
| 59 | 60 |
| 60 // Called by the gamepad data fetcher constructor to register itself | 61 // Called by the gamepad data fetcher constructor to register itself |
| 61 // for receiving data via SetGamepadData. The fetcher must remain | 62 // for receiving data via SetGamepadData. The fetcher must remain |
| 62 // alive while the provider is calling SetGamepadData on it. | 63 // alive while the provider is calling SetGamepadData on it. |
| 63 virtual void RegisterGamepadDataFetcher(GvrGamepadDataFetcher*) = 0; | 64 virtual void RegisterGamepadDataFetcher(GvrGamepadDataFetcher*) = 0; |
| 64 }; | 65 }; |
| 65 | 66 |
| 66 } // namespace device | 67 } // namespace device |
| 67 #endif // DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H | 68 #endif // DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H |
| OLD | NEW |