OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/shell/renderer/test_runner/gamepad_controller.h" | 5 #include "content/shell/renderer/test_runner/gamepad_controller.h" |
6 | 6 |
7 #include "content/shell/renderer/test_runner/TestInterfaces.h" | 7 #include "content/shell/renderer/test_runner/TestInterfaces.h" |
8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" | 8 #include "content/shell/renderer/test_runner/WebTestDelegate.h" |
9 #include "gin/arguments.h" | 9 #include "gin/arguments.h" |
10 #include "gin/handle.h" | 10 #include "gin/handle.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 if (controller_) | 131 if (controller_) |
132 controller_->SetAxisCount(index, axes); | 132 controller_->SetAxisCount(index, axes); |
133 } | 133 } |
134 | 134 |
135 void GamepadControllerBindings::SetAxisData(int index, int axis, double data) { | 135 void GamepadControllerBindings::SetAxisData(int index, int axis, double data) { |
136 if (controller_) | 136 if (controller_) |
137 controller_->SetAxisData(index, axis, data); | 137 controller_->SetAxisData(index, axis, data); |
138 } | 138 } |
139 | 139 |
140 GamepadController::GamepadController() | 140 GamepadController::GamepadController() |
141 : listener_(NULL), | 141 : RendererGamepadProvider(0), |
142 weak_factory_(this) { | 142 weak_factory_(this) { |
143 Reset(); | 143 Reset(); |
144 } | 144 } |
145 | 145 |
146 GamepadController::~GamepadController() {} | 146 GamepadController::~GamepadController() {} |
147 | 147 |
148 void GamepadController::Reset() { | 148 void GamepadController::Reset() { |
149 memset(&gamepads_, 0, sizeof(gamepads_)); | 149 memset(&gamepads_, 0, sizeof(gamepads_)); |
150 } | 150 } |
151 | 151 |
152 void GamepadController::Install(WebFrame* frame) { | 152 void GamepadController::Install(WebFrame* frame) { |
153 GamepadControllerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 153 GamepadControllerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
154 } | 154 } |
155 | 155 |
156 void GamepadController::SetDelegate(WebTestDelegate* delegate) { | 156 void GamepadController::SetDelegate(WebTestDelegate* delegate) { |
157 if (!delegate) | 157 if (!delegate) |
158 return; | 158 return; |
159 delegate->setGamepadProvider(this); | 159 delegate->setGamepadProvider(this); |
160 } | 160 } |
161 | 161 |
162 void GamepadController::SampleGamepads(blink::WebGamepads& gamepads) { | 162 void GamepadController::SampleGamepads(blink::WebGamepads& gamepads) { |
163 memcpy(&gamepads, &gamepads_, sizeof(blink::WebGamepads)); | 163 memcpy(&gamepads, &gamepads_, sizeof(blink::WebGamepads)); |
164 } | 164 } |
165 | 165 |
166 void GamepadController::SetGamepadListener( | 166 bool GamepadController::OnControlMessageReceived(const IPC::Message& msg) { |
167 blink::WebGamepadListener* listener) { | 167 return false; |
168 listener_ = listener; | 168 } |
| 169 |
| 170 void GamepadController::SendStartMessage() { |
| 171 } |
| 172 |
| 173 void GamepadController::SendStopMessage() { |
169 } | 174 } |
170 | 175 |
171 void GamepadController::Connect(int index) { | 176 void GamepadController::Connect(int index) { |
172 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 177 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
173 return; | 178 return; |
174 gamepads_.items[index].connected = true; | 179 gamepads_.items[index].connected = true; |
175 gamepads_.length = 0; | 180 gamepads_.length = 0; |
176 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 181 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
177 if (gamepads_.items[i].connected) | 182 if (gamepads_.items[i].connected) |
178 gamepads_.length = i + 1; | 183 gamepads_.length = i + 1; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 243 |
239 void GamepadController::SetAxisData(int index, int axis, double data) { | 244 void GamepadController::SetAxisData(int index, int axis, double data) { |
240 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 245 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
241 return; | 246 return; |
242 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) | 247 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) |
243 return; | 248 return; |
244 gamepads_.items[index].axes[axis] = data; | 249 gamepads_.items[index].axes[axis] = data; |
245 } | 250 } |
246 | 251 |
247 } // namespace content | 252 } // namespace content |
OLD | NEW |