| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 GamepadController::~GamepadController() {} | 143 GamepadController::~GamepadController() {} |
| 144 | 144 |
| 145 void GamepadController::Reset() { | 145 void GamepadController::Reset() { |
| 146 memset(&gamepads_, 0, sizeof(gamepads_)); | 146 memset(&gamepads_, 0, sizeof(gamepads_)); |
| 147 } | 147 } |
| 148 | 148 |
| 149 void GamepadController::Install(WebFrame* frame) { | 149 void GamepadController::Install(WebFrame* frame) { |
| 150 GamepadControllerBindings::Install(weak_factory_.GetWeakPtr(), frame); | 150 GamepadControllerBindings::Install(weak_factory_.GetWeakPtr(), frame); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void GamepadController::SetDelegate(WebTestRunner::WebTestDelegate* delegate) { | 153 void GamepadController::SetDelegate(WebTestDelegate* delegate) { |
| 154 delegate_ = delegate; | 154 delegate_ = delegate; |
| 155 } | 155 } |
| 156 | 156 |
| 157 void GamepadController::Connect(int index) { | 157 void GamepadController::Connect(int index) { |
| 158 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 158 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
| 159 return; | 159 return; |
| 160 gamepads_.items[index].connected = true; | 160 gamepads_.items[index].connected = true; |
| 161 gamepads_.length = 0; | 161 gamepads_.length = 0; |
| 162 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { | 162 for (unsigned i = 0; i < WebGamepads::itemsLengthCap; ++i) { |
| 163 if (gamepads_.items[i].connected) | 163 if (gamepads_.items[i].connected) |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) | 237 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) |
| 238 return; | 238 return; |
| 239 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) | 239 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) |
| 240 return; | 240 return; |
| 241 gamepads_.items[index].axes[axis] = data; | 241 gamepads_.items[index].axes[axis] = data; |
| 242 if (delegate_) | 242 if (delegate_) |
| 243 delegate_->setGamepadData(gamepads_); | 243 delegate_->setGamepadData(gamepads_); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace content | 246 } // namespace content |
| OLD | NEW |