Chromium Code Reviews| OLD | NEW |
|---|---|
| (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(gvr_context_* gvr_context) {} | |
|
bshe
2016/09/21 15:18:41
is gvr_context neccessary? it doesn't look like it
asimjour
2016/09/22 14:48:36
Done.
| |
| 12 | |
| 13 VrControllerManager::~VrControllerManager() {} | |
| 14 | |
| 15 void VrControllerManager::OnResume() { | |
| 16 VLOG(1) << "Controller-Resume"; | |
|
mthiesse
2016/09/21 17:27:47
Is there a debug only logging path? Might make sen
asimjour
2016/09/22 14:48:36
removed unnecessary logs
| |
| 17 if (vr_controller_) | |
| 18 vr_controller_->OnResume(); | |
| 19 } | |
| 20 | |
| 21 void VrControllerManager::SetContentViewCore( | |
| 22 content::ContentViewCore* content_content_view_core_ptr, | |
|
mthiesse
2016/09/21 17:27:47
People don't seem to like the content_content_ nam
asimjour
2016/09/22 14:48:36
Done.
| |
| 23 content::ContentViewCore* ui_content_view_core_ptr) { | |
| 24 vr_content_ptr = content::VrContentViewCore::FromContentViewCore( | |
| 25 content_content_view_core_ptr); | |
| 26 vr_ui_ptr = | |
| 27 content::VrContentViewCore::FromContentViewCore(ui_content_view_core_ptr); | |
| 28 } | |
| 29 | |
| 30 void VrControllerManager::OnPause() { | |
| 31 VLOG(1) << "Controller-Pause"; | |
| 32 if (vr_controller_) | |
| 33 vr_controller_->OnPause(); | |
| 34 } | |
| 35 | |
| 36 void VrControllerManager::Initialize(gvr_context_* gvr_context) { | |
| 37 vr_controller_.reset(new VrController(gvr_context)); | |
| 38 vr_controller_->Initialize(gvr_context); | |
| 39 } | |
| 40 | |
| 41 VrGesture VrControllerManager::Update() { | |
| 42 if (!vr_controller_) | |
| 43 return VrGesture(); | |
| 44 vr_controller_->UpdateState(); | |
| 45 VrGesture gesture = vr_controller_->DetectGesture(); | |
| 46 return gesture; | |
| 47 } | |
| 48 | |
| 49 void VrControllerManager::ProcessUpdatedGesture(VrGesture gesture) { | |
|
mthiesse
2016/09/21 17:27:47
Why not pass the CVC pointer in here, and not stor
asimjour
2016/09/22 14:48:36
If we pass the vr_cvc pointer vr_shell need to kno
| |
| 50 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | |
|
mthiesse
2016/09/21 17:27:47
You should probably either check that you're not a
asimjour
2016/09/22 14:48:36
Done.
| |
| 51 base::Bind(&VrControllerManager::SendGesture, | |
| 52 this, gesture, vr_content_ptr)); | |
| 53 } | |
| 54 | |
| 55 void VrControllerManager::ProcessUpdatedUIGesture(VrGesture gesture) { | |
| 56 content::BrowserThread::PostTask( | |
| 57 content::BrowserThread::UI, FROM_HERE, | |
| 58 base::Bind(&VrControllerManager::SendGesture, this, gesture, vr_ui_ptr)); | |
| 59 } | |
| 60 | |
| 61 void VrControllerManager::SendGesture( | |
| 62 VrGesture gesture, | |
| 63 content::VrContentViewCore* content_view_core_ptr) { | |
| 64 int64_t event_time = gesture.start_time; | |
| 65 long event_time_milliseconds = (long)(event_time / 1000000); | |
| 66 | |
| 67 if (gesture.type == kGestureTypeScroll) { | |
| 68 content_view_core_ptr->SendScrollEvent( | |
| 69 event_time_milliseconds, 0.0f, 0.0f, gesture.details.scroll.dx, | |
| 70 gesture.details.scroll.dy, gesture.details.scroll.state); | |
| 71 } else if (gesture.type == kGestureTypeButtonsChange) { | |
| 72 content_view_core_ptr->SendClickEvent(event_time_milliseconds, | |
| 73 gesture.details.buttons.x, | |
| 74 gesture.details.buttons.y); | |
| 75 } else if (gesture.type == kGestureTypeAngularMove) { | |
| 76 content_view_core_ptr->SendMouseMoveEvent( | |
| 77 event_time_milliseconds, gesture.details.move.x, gesture.details.move.y, | |
| 78 gesture.details.move.type); | |
| 79 } | |
| 80 return; | |
| 81 } | |
| 82 | |
| 83 bool VrControllerManager::IsTouching() { | |
| 84 return vr_controller_->IsTouching(); | |
| 85 } | |
| 86 | |
| 87 float VrControllerManager::TouchPosX() { | |
| 88 return vr_controller_->TouchPosX(); | |
| 89 } | |
| 90 | |
| 91 float VrControllerManager::TouchPosY() { | |
| 92 return vr_controller_->TouchPosY(); | |
| 93 } | |
| 94 | |
| 95 const gvr_quatf VrControllerManager::Orientation() { | |
|
mthiesse
2016/09/21 17:27:47
nit: gvr::Quatf
asimjour
2016/09/22 14:48:36
Done.
| |
| 96 gvr_quatf orientation = { | |
| 97 vr_controller_->Orientation().qx, vr_controller_->Orientation().qy, | |
|
mthiesse
2016/09/21 17:27:47
This feels wrong. vr_controller_->Orientation() co
asimjour
2016/09/22 14:48:36
fixed
| |
| 98 vr_controller_->Orientation().qz, vr_controller_->Orientation().qw}; | |
| 99 return orientation; | |
| 100 } | |
| 101 | |
| 102 bool VrControllerManager::IsTouchDown() { | |
| 103 return vr_controller_->IsTouchDown(); | |
| 104 } | |
| 105 | |
| 106 bool VrControllerManager::IsTouchUp() { | |
| 107 return vr_controller_->IsTouchUp(); | |
| 108 } | |
| 109 | |
| 110 bool VrControllerManager::ButtonDown(const int32_t button) { | |
| 111 return vr_controller_->ButtonDown(button); | |
| 112 } | |
| 113 | |
| 114 bool VrControllerManager::ButtonUp(const int32_t button) { | |
| 115 return vr_controller_->ButtonUp(button); | |
| 116 } | |
| 117 | |
| 118 bool VrControllerManager::IsConnected() { | |
| 119 return vr_controller_->IsConnected(); | |
| 120 } | |
| 121 | |
| 122 } // namespace vr_shell | |
| OLD | NEW |