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

Side by Side Diff: content/shell/renderer/test_runner/gamepad_controller.cc

Issue 165983005: Updating Gamepad API to match latest spec (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed typo in GamepadProviderTest Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « content/content_browser.gypi ('k') | ppapi/shared_impl/ppb_gamepad_shared.h » ('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 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 gamepads_.items[index].buttonsLength = buttons; 190 gamepads_.items[index].buttonsLength = buttons;
191 if (delegate_) 191 if (delegate_)
192 delegate_->setGamepadData(gamepads_); 192 delegate_->setGamepadData(gamepads_);
193 } 193 }
194 194
195 void GamepadController::SetButtonData(int index, int button, double data) { 195 void GamepadController::SetButtonData(int index, int button, double data) {
196 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) 196 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap))
197 return; 197 return;
198 if (button < 0 || button >= static_cast<int>(WebGamepad::buttonsLengthCap)) 198 if (button < 0 || button >= static_cast<int>(WebGamepad::buttonsLengthCap))
199 return; 199 return;
200 gamepads_.items[index].buttons[button] = data; 200 gamepads_.items[index].buttons[button].value = data;
201 gamepads_.items[index].buttons[button].pressed = data > 0.1f;
201 if (delegate_) 202 if (delegate_)
202 delegate_->setGamepadData(gamepads_); 203 delegate_->setGamepadData(gamepads_);
203 } 204 }
204 205
205 void GamepadController::SetAxisCount(int index, int axes) { 206 void GamepadController::SetAxisCount(int index, int axes) {
206 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) 207 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap))
207 return; 208 return;
208 if (axes < 0 || axes >= static_cast<int>(WebGamepad::axesLengthCap)) 209 if (axes < 0 || axes >= static_cast<int>(WebGamepad::axesLengthCap))
209 return; 210 return;
210 gamepads_.items[index].axesLength = axes; 211 gamepads_.items[index].axesLength = axes;
211 if (delegate_) 212 if (delegate_)
212 delegate_->setGamepadData(gamepads_); 213 delegate_->setGamepadData(gamepads_);
213 } 214 }
214 215
215 void GamepadController::SetAxisData(int index, int axis, double data) { 216 void GamepadController::SetAxisData(int index, int axis, double data) {
216 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap)) 217 if (index < 0 || index >= static_cast<int>(WebGamepads::itemsLengthCap))
217 return; 218 return;
218 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap)) 219 if (axis < 0 || axis >= static_cast<int>(WebGamepad::axesLengthCap))
219 return; 220 return;
220 gamepads_.items[index].axes[axis] = data; 221 gamepads_.items[index].axes[axis] = data;
221 if (delegate_) 222 if (delegate_)
222 delegate_->setGamepadData(gamepads_); 223 delegate_->setGamepadData(gamepads_);
223 } 224 }
224 225
225 } // namespace content 226 } // namespace content
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | ppapi/shared_impl/ppb_gamepad_shared.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698