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

Side by Side Diff: device/vr/android/gvr/gvr_gamepad_data_fetcher.cc

Issue 2377763003: Revert "Updated to GVR 1.0 SDK" (Closed)
Patch Set: 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
« no previous file with comments | « device/vr/android/gvr/gvr_gamepad_data_fetcher.h ('k') | third_party/gvr-android-sdk/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h" 5 #include "device/vr/android/gvr/gvr_gamepad_data_fetcher.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 8
9 #include "device/vr/android/gvr/gvr_delegate.h" 9 #include "device/vr/android/gvr/gvr_delegate.h"
10 #include "third_party/WebKit/public/platform/WebGamepads.h" 10 #include "third_party/WebKit/public/platform/WebGamepads.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 GvrGamepadDataFetcher::GvrGamepadDataFetcher(GvrDelegate* delegate, 47 GvrGamepadDataFetcher::GvrGamepadDataFetcher(GvrDelegate* delegate,
48 unsigned int display_id) 48 unsigned int display_id)
49 : display_id_(display_id) { 49 : display_id_(display_id) {
50 gvr::GvrApi* gvr_api = delegate->gvr_api(); 50 gvr::GvrApi* gvr_api = delegate->gvr_api();
51 controller_api_.reset(new gvr::ControllerApi()); 51 controller_api_.reset(new gvr::ControllerApi());
52 int32_t options = gvr::ControllerApi::DefaultOptions(); 52 int32_t options = gvr::ControllerApi::DefaultOptions();
53 options |= GVR_CONTROLLER_ENABLE_GYRO; 53 options |= GVR_CONTROLLER_ENABLE_GYRO;
54 bool success = controller_api_->Init(options, gvr_api->GetContext()); 54 bool success = controller_api_->Init(options, gvr_api->GetContext());
55 if (!success) 55 if (!success)
56 controller_api_.reset(nullptr); 56 controller_api_.reset(nullptr);
57
58 user_prefs_.reset(new gvr::UserPrefs(gvr_api->GetUserPrefs().cobj()));
59 } 57 }
60 58
61 GvrGamepadDataFetcher::~GvrGamepadDataFetcher() {} 59 GvrGamepadDataFetcher::~GvrGamepadDataFetcher() {}
62 60
63 GamepadSource GvrGamepadDataFetcher::source() { 61 GamepadSource GvrGamepadDataFetcher::source() {
64 return GAMEPAD_SOURCE_GVR; 62 return GAMEPAD_SOURCE_GVR;
65 } 63 }
66 64
67 void GvrGamepadDataFetcher::OnAddedToProvider() { 65 void GvrGamepadDataFetcher::OnAddedToProvider() {
68 PauseHint(false); 66 PauseHint(false);
(...skipping 20 matching lines...) Expand all
89 pad.axesLength = 2; 87 pad.axesLength = 2;
90 88
91 pad.displayId = display_id_; 89 pad.displayId = display_id_;
92 } 90 }
93 91
94 controller_state_.Update(*controller_api_); 92 controller_state_.Update(*controller_api_);
95 93
96 pad.timestamp = controller_state_.GetLastOrientationTimestamp(); 94 pad.timestamp = controller_state_.GetLastOrientationTimestamp();
97 95
98 // TODO: Query from API if avaialable. 96 // TODO: Query from API if avaialable.
99 gvr::ControllerHandedness handedness = user_prefs_->GetControllerHandedness(); 97 pad.hand = GamepadHandRight;
100 pad.hand = (handedness == GVR_CONTROLLER_RIGHT_HANDED) ? GamepadHandRight
101 : GamepadHandLeft;
102 98
103 if (controller_state_.IsTouching()) { 99 if (controller_state_.IsTouching()) {
104 gvr_vec2f touch_position = controller_state_.GetTouchPos(); 100 gvr_vec2f touch_position = controller_state_.GetTouchPos();
105 pad.axes[0] = (touch_position.x * 2.0f) - 1.0f; 101 pad.axes[0] = (touch_position.x * 2.0f) - 1.0f;
106 pad.axes[1] = (touch_position.y * 2.0f) - 1.0f; 102 pad.axes[1] = (touch_position.y * 2.0f) - 1.0f;
107 } else { 103 } else {
108 pad.axes[0] = 0.0f; 104 pad.axes[0] = 0.0f;
109 pad.axes[1] = 0.0f; 105 pad.axes[1] = 0.0f;
110 } 106 }
111 107
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 return; 139 return;
144 140
145 if (paused) { 141 if (paused) {
146 controller_api_->Pause(); 142 controller_api_->Pause();
147 } else { 143 } else {
148 controller_api_->Resume(); 144 controller_api_->Resume();
149 } 145 }
150 } 146 }
151 147
152 } // namespace device 148 } // namespace device
OLDNEW
« no previous file with comments | « device/vr/android/gvr/gvr_gamepad_data_fetcher.h ('k') | third_party/gvr-android-sdk/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698