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

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

Issue 2350253004: Controller support for VrShell (Closed)
Patch Set: rebased + moved vr_input_manager Created 4 years, 3 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_controller_manager.cc
diff --git a/chrome/browser/android/vr_shell/vr_controller_manager.cc b/chrome/browser/android/vr_shell/vr_controller_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..97989de0d2ebd79c1b74c2ef093135a66d3c858c
--- /dev/null
+++ b/chrome/browser/android/vr_shell/vr_controller_manager.cc
@@ -0,0 +1,68 @@
+// Copyright 2016 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.
+
+#include "base/logging.h"
+#include "chrome/browser/android/vr_shell/vr_controller_manager.h"
+#include "content/public/browser/browser_thread.h"
+
+namespace vr_shell {
+
+VrControllerManager::VrControllerManager() {}
+
+VrControllerManager::~VrControllerManager() {}
+
+void VrControllerManager::SetContentViewCore(
+ content::ContentViewCore* content_cvc_ptr,
+ content::ContentViewCore* ui_cvc_ptr) {
+ vr_content_ptr = new VrInputManager(content_cvc_ptr);
+ vr_ui_ptr = new VrInputManager(ui_cvc_ptr);
+}
+
+std::unique_ptr<VrController> VrControllerManager::InitializeController(
+ gvr_context* gvr_context) {
+ return std::unique_ptr<VrController>(new VrController(gvr_context));
+}
+
+void VrControllerManager::ProcessUpdatedGesture(VrGesture gesture) {
+ if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI))
bshe 2016/09/22 23:16:49 nit: use {} if code is more than 1 line.
asimjour 2016/09/23 16:58:21 Done.
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&VrControllerManager::SendGesture, this, gesture,
+ vr_content_ptr));
+ else
+ SendGesture(gesture, vr_content_ptr);
+}
+
+void VrControllerManager::ProcessUpdatedUIGesture(VrGesture gesture) {
+ if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI))
bshe 2016/09/22 23:16:49 ditto
asimjour 2016/09/23 16:58:21 Done.
+ content::BrowserThread::PostTask(
+ content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&VrControllerManager::SendGesture, this, gesture,
+ vr_ui_ptr));
+ else
+ SendGesture(gesture, vr_ui_ptr);
+}
+
+void VrControllerManager::SendGesture(VrGesture gesture,
+ VrInputManager* vr_cvc_ptr) {
+ int64_t event_time = gesture.start_time;
+ long event_time_milliseconds = (long)(event_time / 1000000);
+
+ if (gesture.type == kGestureTypeScroll) {
+ vr_cvc_ptr->SendScrollEvent(
+ event_time_milliseconds, 0.0f, 0.0f, gesture.details.scroll.dx,
+ gesture.details.scroll.dy, gesture.details.scroll.state);
+ } else if (gesture.type == kGestureTypeButtonsChange) {
+ vr_cvc_ptr->SendClickEvent(event_time_milliseconds,
+ gesture.details.buttons.x,
+ gesture.details.buttons.y);
+ } else if (gesture.type == kGestureTypeAngularMove) {
+ vr_cvc_ptr->SendMouseMoveEvent(
+ event_time_milliseconds, gesture.details.move.x, gesture.details.move.y,
+ gesture.details.move.type);
+ }
+ return;
bshe 2016/09/22 23:16:49 nit: remove return
asimjour 2016/09/23 16:58:21 Done.
+}
+
+} // namespace vr_shell

Powered by Google App Engine
This is Rietveld 408576698