OLD | NEW |
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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 | |
10 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" | 9 #include "device/vr/android/gvr/gvr_gamepad_data_provider.h" |
| 10 #include "device/vr/vr_types.h" |
11 #include "third_party/WebKit/public/platform/WebGamepads.h" | 11 #include "third_party/WebKit/public/platform/WebGamepads.h" |
12 | 12 |
13 namespace device { | 13 namespace device { |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 void CopyToWebUString(blink::WebUChar* dest, | 17 void CopyToWebUString(blink::WebUChar* dest, |
18 size_t dest_length, | 18 size_t dest_length, |
19 base::string16 src) { | 19 base::string16 src) { |
20 static_assert(sizeof(base::string16::value_type) == sizeof(blink::WebUChar), | 20 static_assert(sizeof(base::string16::value_type) == sizeof(blink::WebUChar), |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 pad.display_id = display_id_; | 100 pad.display_id = display_id_; |
101 | 101 |
102 pad.hand = | 102 pad.hand = |
103 provided_data.right_handed ? kGamepadHandRight : kGamepadHandLeft; | 103 provided_data.right_handed ? kGamepadHandRight : kGamepadHandLeft; |
104 } | 104 } |
105 | 105 |
106 pad.timestamp = provided_data.timestamp; | 106 pad.timestamp = provided_data.timestamp; |
107 | 107 |
108 if (provided_data.is_touching) { | 108 if (provided_data.is_touching) { |
109 gvr_vec2f touch_position = provided_data.touch_pos; | 109 gfx::Vector2dF touch_position = provided_data.touch_pos; |
110 pad.axes[0] = (touch_position.x * 2.0f) - 1.0f; | 110 pad.axes[0] = (touch_position.x() * 2.0f) - 1.0f; |
111 pad.axes[1] = (touch_position.y * 2.0f) - 1.0f; | 111 pad.axes[1] = (touch_position.y() * 2.0f) - 1.0f; |
112 } else { | 112 } else { |
113 pad.axes[0] = 0.0f; | 113 pad.axes[0] = 0.0f; |
114 pad.axes[1] = 0.0f; | 114 pad.axes[1] = 0.0f; |
115 } | 115 } |
116 | 116 |
117 pad.buttons[0].touched = provided_data.is_touching; | 117 pad.buttons[0].touched = provided_data.is_touching; |
118 pad.buttons[0].pressed = provided_data.controller_button_pressed; | 118 pad.buttons[0].pressed = provided_data.controller_button_pressed; |
119 pad.buttons[0].value = pad.buttons[0].pressed ? 1.0f : 0.0f; | 119 pad.buttons[0].value = pad.buttons[0].pressed ? 1.0f : 0.0f; |
120 | 120 |
121 pad.pose.not_null = true; | 121 pad.pose.not_null = true; |
122 pad.pose.has_orientation = true; | 122 pad.pose.has_orientation = true; |
123 pad.pose.has_position = false; | 123 pad.pose.has_position = false; |
124 | 124 |
125 gvr_quatf orientation = provided_data.orientation; | 125 vr::Quatf orientation = provided_data.orientation; |
126 pad.pose.orientation.not_null = true; | 126 pad.pose.orientation.not_null = true; |
127 pad.pose.orientation.x = orientation.qx; | 127 pad.pose.orientation.x = orientation.qx; |
128 pad.pose.orientation.y = orientation.qy; | 128 pad.pose.orientation.y = orientation.qy; |
129 pad.pose.orientation.z = orientation.qz; | 129 pad.pose.orientation.z = orientation.qz; |
130 pad.pose.orientation.w = orientation.qw; | 130 pad.pose.orientation.w = orientation.qw; |
131 | 131 |
132 gvr_vec3f accel = provided_data.accel; | 132 gfx::Vector3dF accel = provided_data.accel; |
133 pad.pose.linear_acceleration.not_null = true; | 133 pad.pose.linear_acceleration.not_null = true; |
134 pad.pose.linear_acceleration.x = accel.x; | 134 pad.pose.linear_acceleration.x = accel.x(); |
135 pad.pose.linear_acceleration.y = accel.y; | 135 pad.pose.linear_acceleration.y = accel.y(); |
136 pad.pose.linear_acceleration.z = accel.z; | 136 pad.pose.linear_acceleration.z = accel.z(); |
137 | 137 |
138 gvr_vec3f gyro = provided_data.gyro; | 138 gfx::Vector3dF gyro = provided_data.gyro; |
139 pad.pose.angular_velocity.not_null = true; | 139 pad.pose.angular_velocity.not_null = true; |
140 pad.pose.angular_velocity.x = gyro.x; | 140 pad.pose.angular_velocity.x = gyro.x(); |
141 pad.pose.angular_velocity.y = gyro.y; | 141 pad.pose.angular_velocity.y = gyro.y(); |
142 pad.pose.angular_velocity.z = gyro.z; | 142 pad.pose.angular_velocity.z = gyro.z(); |
143 } | 143 } |
144 | 144 |
145 void GvrGamepadDataFetcher::PauseHint(bool paused) {} | 145 void GvrGamepadDataFetcher::PauseHint(bool paused) {} |
146 | 146 |
147 } // namespace device | 147 } // namespace device |
OLD | NEW |