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

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.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_gl.h ('k') | device/gamepad/gamepad_provider.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_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 9c0082ad4e0fcaa3005731f15a515ddd2e01c5d3..07c45b0fd3f3de6a30b0ffca439c0b316688e63d 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -22,6 +22,7 @@
#include "chrome/browser/android/vr_shell/vr_shell.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"
@@ -467,9 +468,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::UpdateGamepadData, weak_vr_shell_, pad));
+}
+
+void VrShellGl::HandleControllerInput(const gvr::Vec3f& forward_vector) {
if (ShouldDrawWebVr()) {
// Process screen touch events for Cardboard button compatibility.
// Also send tap events for controller "touchpad click" events.
@@ -484,6 +491,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;
@@ -810,7 +818,7 @@ void VrShellGl::DrawFrame(int16_t frame_index) {
{
TRACE_EVENT0("gpu", "VrShellGl::UpdateController");
- UpdateController(GetForwardVector(head_pose));
+ HandleControllerInput(GetForwardVector(head_pose));
}
DrawWorldElements(head_pose);
@@ -1188,6 +1196,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_));
« no previous file with comments | « chrome/browser/android/vr_shell/vr_shell_gl.h ('k') | device/gamepad/gamepad_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698