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

Unified Diff: chrome/browser/android/vr_shell/vr_shell.cc

Issue 2762003002: Refactor GVR controller gamepad API integration (Closed)
Patch Set: Fix comment, include gvr_types only for data provider Created 3 years, 9 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: chrome/browser/android/vr_shell/vr_shell.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell.cc b/chrome/browser/android/vr_shell/vr_shell.cc
index 53dfd7eb9d2612dafdecedd7d609b6a6b0b1937b..8c64180e826d2703709415b4a154ea842a54eacb 100644
--- a/chrome/browser/android/vr_shell/vr_shell.cc
+++ b/chrome/browser/android/vr_shell/vr_shell.cc
@@ -35,6 +35,7 @@
#include "content/public/common/referrer.h"
#include "device/vr/android/gvr/gvr_device.h"
#include "device/vr/android/gvr/gvr_device_provider.h"
+#include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
#include "gpu/command_buffer/common/mailbox.h"
#include "jni/VrShellImpl_jni.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
@@ -177,6 +178,11 @@ bool RegisterVrShell(JNIEnv* env) {
}
VrShell::~VrShell() {
+ if (gamepad_source_active_) {
+ device::GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
+ device::GAMEPAD_SOURCE_GVR);
+ }
+
delegate_provider_->RemoveDelegate();
{
// The GvrLayout is, and must always be, used only on the UI thread, and the
@@ -624,6 +630,24 @@ void VrShell::ProcessContentGesture(
}
}
+void VrShell::GamepadDataUpdate(device::GvrGamepadData pad) {
+ if (!gamepad_source_active_) {
+ if (!delegate_provider_->device_provider())
+ return;
+
+ unsigned int device_id =
+ delegate_provider_->device_provider()->Device()->id();
+ device::GamepadDataFetcherManager::GetInstance()->AddFactory(
+ new device::GvrGamepadDataFetcher::Factory(this, device_id));
+ gamepad_source_active_ = true;
+ }
+ gamepad_data_ = pad;
+}
+
+device::GvrGamepadData VrShell::GamepadDataGet() {
+ return gamepad_data_;
+}
+
/* static */
device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) {
device::mojom::VRPosePtr pose = device::mojom::VRPose::New();

Powered by Google App Engine
This is Rietveld 408576698