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

Side by Side Diff: chrome/browser/android/vr_shell/vr_controller_manager.cc

Issue 2350253004: Controller support for VrShell (Closed)
Patch Set: Clean up Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "base/logging.h"
6 #include "chrome/browser/android/vr_shell/vr_controller_manager.h"
7 #include "content/public/browser/browser_thread.h"
8
9 namespace vr_shell {
10
11 VrControllerManager::VrControllerManager() {}
12
13 VrControllerManager::~VrControllerManager() {}
14
15 void VrControllerManager::SetWebContents(content::WebContents* content_wc_ptr,
16 content::WebContents* ui_wc_ptr) {
17 vr_content_ptr_ = new VrInputManager(content_wc_ptr);
18 vr_ui_ptr_ = new VrInputManager(ui_wc_ptr);
19 }
20
21 std::unique_ptr<VrController> VrControllerManager::InitializeController(
22 gvr_context* gvr_context) {
23 return std::unique_ptr<VrController>(new VrController(gvr_context));
24 }
25
26 void VrControllerManager::ProcessUpdatedContentGesture(VrGesture gesture) {
27 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
28 content::BrowserThread::PostTask(
29 content::BrowserThread::UI, FROM_HERE,
30 base::Bind(&VrControllerManager::SendGesture, this, gesture,
31 vr_content_ptr_));
32 } else {
33 SendGesture(gesture, vr_content_ptr_);
34 }
35 }
36
37 void VrControllerManager::ProcessUpdatedUIGesture(VrGesture gesture) {
38 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
39 content::BrowserThread::PostTask(
40 content::BrowserThread::UI, FROM_HERE,
41 base::Bind(&VrControllerManager::SendGesture, this, gesture,
42 vr_ui_ptr_));
43 } else {
44 SendGesture(gesture, vr_ui_ptr_);
45 }
46 }
47
48 void VrControllerManager::SendGesture(VrGesture gesture,
49 VrInputManager* vr_input_manager) {
50 int64_t event_time = gesture.start_time;
51 int64_t event_time_milliseconds = static_cast<int64_t>(event_time / 1000000);
52
53 if (gesture.type == WebInputEvent::GestureScrollBegin ||
54 gesture.type == WebInputEvent::GestureScrollUpdate ||
55 gesture.type == WebInputEvent::GestureScrollEnd) {
56 vr_input_manager->SendScrollEvent(
57 event_time_milliseconds, 0.0f, 0.0f, gesture.details.scroll.delta.x,
58 gesture.details.scroll.delta.y, gesture.type);
59 } else if (gesture.type == WebInputEvent::GestureTap) {
60 vr_input_manager->SendClickEvent(event_time_milliseconds,
61 gesture.details.buttons.pos.x,
62 gesture.details.buttons.pos.y);
63 } else if (gesture.type == WebInputEvent::MouseMove) {
64 vr_input_manager->SendMouseMoveEvent(
65 event_time_milliseconds, gesture.details.move.delta.x,
66 gesture.details.move.delta.y, gesture.details.move.type);
67 }
68 }
69
70 } // namespace vr_shell
OLDNEW
« no previous file with comments | « chrome/browser/android/vr_shell/vr_controller_manager.h ('k') | chrome/browser/android/vr_shell/vr_gesture.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698