| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H |
| 6 #define DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H |
| 7 |
| 8 #include "third_party/gvr-android-sdk/src/libraries/headers/vr/gvr/capi/include/
gvr_types.h" |
| 9 |
| 10 namespace device { |
| 11 |
| 12 class GvrGamepadDataFetcher; |
| 13 |
| 14 // Subset of GVR controller data needed for the gamepad API. Filled in |
| 15 // by vr_shell's VrController and consumed by GvrGamepadDataFetcher. |
| 16 struct GvrGamepadData { |
| 17 int64_t timestamp; |
| 18 gvr_vec2f touch_pos; |
| 19 gvr_quatf orientation; |
| 20 gvr_vec3f accel; |
| 21 gvr_vec3f gyro; |
| 22 bool is_touching; |
| 23 bool controller_button_pressed; |
| 24 bool right_handed; |
| 25 }; |
| 26 |
| 27 // This class exposes GVR controller data to the gamepad API. Data is |
| 28 // polled by VrShellGl, then pushed from VrShell which implements the |
| 29 // GvrGamepadDataProvider interface. |
| 30 // |
| 31 // More specifically, here's the lifecycle, assuming VrShell |
| 32 // implements GvrGamepadDataProvider: |
| 33 // |
| 34 // - VrShell creates GvrGamepadDataFetcherFactory from |
| 35 // VrShell::UpdateGamepadData. |
| 36 // |
| 37 // - GvrGamepadDataFetcherFactory creates GvrGamepadDataFetcher. |
| 38 // |
| 39 // - GvrGamepadDataFetcher registers itself with VrShell via |
| 40 // VrShell::RegisterGamepadDataFetcher. |
| 41 // |
| 42 // - While presenting, VrShell::UpdateGamepadData calls |
| 43 // GvrGamepadDataFetcher->SetGamepadData to push poses, |
| 44 // GvrGamepadDataFetcher::GetGamepadData returns these when polled. |
| 45 // |
| 46 // - VrShell starts executing its destructor. |
| 47 // |
| 48 // - VrShell destructor unregisters GvrGamepadDataFetcherFactory. |
| 49 // |
| 50 // - GvrGamepadDataFetcherFactory destructor destroys GvrGamepadDataFetcher. |
| 51 // |
| 52 class GvrGamepadDataProvider { |
| 53 public: |
| 54 // Refresh current GVR controller data for use by gamepad API. The |
| 55 // implementation also lazily creates and registers the GVR |
| 56 // GamepadDataFetcherFactory with the GamepadDataFetcherManager as |
| 57 // needed. |
| 58 virtual void UpdateGamepadData(GvrGamepadData data) = 0; |
| 59 |
| 60 // Called by the gamepad data fetcher constructor to register itself |
| 61 // for receiving data via SetGamepadData. The fetcher must remain |
| 62 // alive while the provider is calling SetGamepadData on it. |
| 63 virtual void RegisterGamepadDataFetcher(GvrGamepadDataFetcher*) = 0; |
| 64 }; |
| 65 |
| 66 } // namespace device |
| 67 #endif // DEVICE_VR_ANDROID_GVR_GAMEPAD_DATA_PROVIDER_H |
| OLD | NEW |