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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) |
| 158 return; |
157 delegate->setGamepadProvider(this); | 159 delegate->setGamepadProvider(this); |
158 } | 160 } |
159 | 161 |
160 void GamepadController::SampleGamepads(blink::WebGamepads& gamepads) { | 162 void GamepadController::SampleGamepads(blink::WebGamepads& gamepads) { |
161 memcpy(&gamepads, &gamepads_, sizeof(blink::WebGamepads)); | 163 memcpy(&gamepads, &gamepads_, sizeof(blink::WebGamepads)); |
162 } | 164 } |
163 | 165 |
164 void GamepadController::SetGamepadListener( | 166 void GamepadController::SetGamepadListener( |
165 blink::WebGamepadListener* listener) { | 167 blink::WebGamepadListener* listener) { |
166 listener_ = listener; | 168 listener_ = listener; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 238 |
237 void GamepadController::SetAxisData(int index, int axis, double data) { | 239 void GamepadController::SetAxisData(int index, int axis, double data) { |
238 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 240 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
239 return; | 241 return; |
240 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) | 242 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) |
241 return; | 243 return; |
242 gamepads_.items[index].axes[axis] = data; | 244 gamepads_.items[index].axes[axis] = data; |
243 } | 245 } |
244 | 246 |
245 } // namespace content | 247 } // namespace content |
OLD | NEW |