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

Side by Side Diff: content/browser/gamepad/gamepad_standard_mappings_linux.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, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/gamepad/gamepad_standard_mappings.h" 5 #include "content/browser/gamepad/gamepad_standard_mappings.h"
6 6
7 #include "content/common/gamepad_hardware_buffer.h"
8
9 namespace content { 7 namespace content {
10 8
11 namespace { 9 namespace {
12 10
13 float AxisToButton(float input) {
14 return (input + 1.f) / 2.f;
15 }
16
17 float AxisNegativeAsButton(float input) {
18 return (input < -0.5f) ? 1.f : 0.f;
19 }
20
21 float AxisPositiveAsButton(float input) {
22 return (input > 0.5f) ? 1.f : 0.f;
23 }
24
25 void MapperXInputStyleGamepad( 11 void MapperXInputStyleGamepad(
26 const blink::WebGamepad& input, 12 const blink::WebGamepad& input,
27 blink::WebGamepad* mapped) { 13 blink::WebGamepad* mapped) {
28 *mapped = input; 14 *mapped = input;
29 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]); 15 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
30 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]); 16 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
31 mapped->buttons[kButtonBackSelect] = input.buttons[6]; 17 mapped->buttons[kButtonBackSelect] = input.buttons[6];
32 mapped->buttons[kButtonStart] = input.buttons[7]; 18 mapped->buttons[kButtonStart] = input.buttons[7];
33 mapped->buttons[kButtonLeftThumbstick] = input.buttons[9]; 19 mapped->buttons[kButtonLeftThumbstick] = input.buttons[9];
34 mapped->buttons[kButtonRightThumbstick] = input.buttons[10]; 20 mapped->buttons[kButtonRightThumbstick] = input.buttons[10];
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 const base::StringPiece& product_id) { 199 const base::StringPiece& product_id) {
214 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 200 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
215 MappingData& item = AvailableMappings[i]; 201 MappingData& item = AvailableMappings[i];
216 if (vendor_id == item.vendor_id && product_id == item.product_id) 202 if (vendor_id == item.vendor_id && product_id == item.product_id)
217 return item.function; 203 return item.function;
218 } 204 }
219 return NULL; 205 return NULL;
220 } 206 }
221 207
222 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_standard_mappings.cc ('k') | content/browser/gamepad/gamepad_standard_mappings_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698