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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: device/vr/android/gvr/cardboard_gamepad_data_provider.h
diff --git a/device/vr/android/gvr/cardboard_gamepad_data_provider.h b/device/vr/android/gvr/cardboard_gamepad_data_provider.h
new file mode 100644
index 0000000000000000000000000000000000000000..1b5d5e9e8aa10437ac3fb8ebcfa82a8ce627aa9a
--- /dev/null
+++ b/device/vr/android/gvr/cardboard_gamepad_data_provider.h
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef DEVICE_VR_ANDROID_CARDBOARD_GAMEPAD_DATA_PROVIDER_H
+#define DEVICE_VR_ANDROID_CARDBOARD_GAMEPAD_DATA_PROVIDER_H
+
+#include "device/vr/vr_types.h"
+
+namespace device {
+
+class CardboardGamepadDataFetcher;
+
+// Filled in by vr_shell and consumed by CardboardGamepadDataFetcher.
+struct CardboardGamepadData {
+ int64_t timestamp;
+ bool is_screen_touching;
+};
+
+// This class exposes Cardboard controller (screen touch) data to the gamepad
+// API. Data is reported by VrShell, which implements the
+// CardboardGamepadDataProvider interface.
+//
+// More specifically, here's the lifecycle, assuming VrShell
+// implements GvrGamepadDataProvider:
+//
+// - VrShell creates CardboardGamepadDataFetcherFactory during initialization if
+// a cardboard is in use, or when WebVR presentation starts.
+//
+// - CardboardGamepadDataFetcherFactory creates CardboardGamepadDataFetcher.
+//
+// - CardboardGamepadDataFetcher registers itself with VrShell via
+// VrShell::RegisterCardboardGamepadDataFetcher.
+//
+// - While presenting, VrShell::OnTouch calls
+// CardboardGamepadDataFetcher->SetGamepadData to push button state,
+// CardboardGamepadDataFetcher::GetGamepadData returns this when polled.
+//
+// - VrShell starts executing its destructor or WebVR presentation ends.
+//
+// - VrShell destructor unregisters CardboardGamepadDataFetcherFactory.
+//
+// - CardboardGamepadDataFetcherFactory destructor destroys
+// CardboardGamepadDataFetcher.
+//
+class CardboardGamepadDataProvider {
+ public:
+ // Called by the gamepad data fetcher constructor to register itself
+ // for receiving data via SetGamepadData. The fetcher must remain
+ // alive while the provider is calling SetGamepadData on it.
+ virtual void RegisterCardboardGamepadDataFetcher(
+ CardboardGamepadDataFetcher*) = 0;
+};
+
+} // namespace device
+#endif // DEVICE_VR_ANDROID_CARDBOARD_GAMEPAD_DATA_PROVIDER_H
« 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