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

Side by Side Diff: device/vr/android/gvr/cardboard_gamepad_data_provider.h

Issue 2879973002: Expose Gamepad API instance for Cardboard button (Closed)
Patch Set: fix crash in tests Created 3 years, 7 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
OLDNEW
(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_CARDBOARD_GAMEPAD_DATA_PROVIDER_H
6 #define DEVICE_VR_ANDROID_CARDBOARD_GAMEPAD_DATA_PROVIDER_H
7
8 #include "device/vr/vr_types.h"
9
10 namespace device {
11
12 class CardboardGamepadDataFetcher;
13
14 // Filled in by vr_shell and consumed by CardboardGamepadDataFetcher.
15 struct CardboardGamepadData {
16 int64_t timestamp;
17 bool is_screen_touching;
18 };
19
20 // This class exposes Cardboard controller (screen touch) data to the gamepad
21 // API. Data is reported by VrShell, which implements the
22 // CardboardGamepadDataProvider interface.
23 //
24 // More specifically, here's the lifecycle, assuming VrShell
25 // implements GvrGamepadDataProvider:
26 //
27 // - VrShell creates CardboardGamepadDataFetcherFactory during initialization if
28 // a cardboard is in use, or when WebVR presentation starts.
29 //
30 // - CardboardGamepadDataFetcherFactory creates CardboardGamepadDataFetcher.
31 //
32 // - CardboardGamepadDataFetcher registers itself with VrShell via
33 // VrShell::RegisterCardboardGamepadDataFetcher.
34 //
35 // - While presenting, VrShell::OnTouch calls
36 // CardboardGamepadDataFetcher->SetGamepadData to push button state,
37 // CardboardGamepadDataFetcher::GetGamepadData returns this when polled.
38 //
39 // - VrShell starts executing its destructor or WebVR presentation ends.
40 //
41 // - VrShell destructor unregisters CardboardGamepadDataFetcherFactory.
42 //
43 // - CardboardGamepadDataFetcherFactory destructor destroys
44 // CardboardGamepadDataFetcher.
45 //
46 class CardboardGamepadDataProvider {
47 public:
48 // Called by the gamepad data fetcher constructor to register itself
49 // for receiving data via SetGamepadData. The fetcher must remain
50 // alive while the provider is calling SetGamepadData on it.
51 virtual void RegisterCardboardGamepadDataFetcher(
52 CardboardGamepadDataFetcher*) = 0;
53 };
54
55 } // namespace device
56 #endif // DEVICE_VR_ANDROID_CARDBOARD_GAMEPAD_DATA_PROVIDER_H
OLDNEW
« no previous file with comments | « device/vr/android/gvr/cardboard_gamepad_data_fetcher.cc ('k') | device/vr/android/gvr/gvr_gamepad_data_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698