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

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

Issue 2762003002: Refactor GVR controller gamepad API integration (Closed)
Patch Set: Rebase, no changes 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
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_delegate.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 feb10a658c4b2e67f547e3ac0746dc3435d92d0e..edcbb68f0fe05e2c0f75e96229e281b9e33a5b32 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"
@@ -91,6 +92,7 @@ VrShell::VrShell(JNIEnv* env,
reprojected_rendering_(reprojected_rendering),
gvr_api_(gvr_api),
weak_ptr_factory_(this) {
+ DVLOG(1) << __FUNCTION__ << "=" << this;
DCHECK(g_instance == nullptr);
g_instance = this;
j_vr_shell_.Reset(env, obj);
@@ -177,6 +179,12 @@ bool RegisterVrShell(JNIEnv* env) {
}
VrShell::~VrShell() {
+ DVLOG(1) << __FUNCTION__ << "=" << this;
+ 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 +632,28 @@ void VrShell::ProcessContentGesture(
}
}
+void VrShell::UpdateGamepadData(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;
+ }
+ if (gamepad_data_fetcher_) {
+ gamepad_data_fetcher_->SetGamepadData(pad);
+ }
+}
+
+void VrShell::RegisterGamepadDataFetcher(
+ device::GvrGamepadDataFetcher* fetcher) {
+ DVLOG(1) << __FUNCTION__ << "(" << fetcher << ")";
+ gamepad_data_fetcher_ = fetcher;
+}
+
/* static */
device::mojom::VRPosePtr VrShell::VRPosePtrFromGvrPose(gvr::Mat4f head_mat) {
device::mojom::VRPosePtr pose = device::mojom::VRPose::New();
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell.h ('k') | chrome/browser/android/vr_shell/vr_shell_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698