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

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.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_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index fa661b91ab0d9c2e56d4aac07beda06bd65507fe..ca90fe68f937a004c4cdd9d7a032132aac53a863 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/android/vr_shell/vr_shell_delegate.h"
#include "chrome/browser/android/vr_shell/vr_shell_renderer.h"
#include "device/vr/android/gvr/gvr_device.h"
+#include "device/vr/android/gvr/gvr_gamepad_data_provider.h"
#include "third_party/WebKit/public/platform/WebInputEvent.h"
#include "third_party/WebKit/public/platform/WebMouseEvent.h"
#include "ui/gl/android/scoped_java_surface.h"
@@ -472,9 +473,15 @@ void VrShellGl::InitializeRenderer() {
FROM_HERE, base::Bind(&VrShell::GvrDelegateReady, weak_vr_shell_));
}
-void VrShellGl::UpdateController(const gvr::Vec3f& forward_vector) {
+void VrShellGl::UpdateController() {
controller_->UpdateState();
+ device::GvrGamepadData pad = controller_->GetGamepadData();
+ main_thread_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&VrShell::GamepadDataUpdate, weak_vr_shell_, pad));
+}
+
+void VrShellGl::HandleControllerInput(const gvr::Vec3f& forward_vector) {
if (web_vr_mode_) {
// Process screen touch events for Cardboard button compatibility.
// Also send tap events for controller "touchpad click" events.
@@ -489,6 +496,7 @@ void VrShellGl::UpdateController(const gvr::Vec3f& forward_vector) {
gesture->x = 0;
gesture->y = 0;
SendGesture(InputTarget::CONTENT, std::move(gesture));
+ DVLOG(1) << __FUNCTION__ << ": sent CLICK gesture";
}
return;
@@ -815,7 +823,7 @@ void VrShellGl::DrawFrame(int16_t frame_index) {
{
TRACE_EVENT0("gpu", "VrShellGl::UpdateController");
- UpdateController(GetForwardVector(head_pose));
+ HandleControllerInput(GetForwardVector(head_pose));
}
// Finish drawing in the primary buffer, and draw the headlocked buffer
@@ -1201,6 +1209,10 @@ void VrShellGl::OnVSync() {
task_runner_->PostDelayedTask(FROM_HERE, vsync_task_.callback(),
target - now);
+ // Get controller data now so that it's ready for both WebVR's
+ // gamepad API input and VrShell's own processing.
+ UpdateController();
+
base::TimeDelta time = intervals * vsync_interval_;
if (!callback_.is_null()) {
SendVSync(time, base::ResetAndReturn(&callback_));

Powered by Google App Engine
This is Rietveld 408576698