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

Side by Side Diff: content/browser/gamepad/gamepad_standard_mappings_linux.cc

Issue 9270015: Add Mac gamepad input remapper (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unused dpad helper Created 8 years, 11 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_linux.h" 5 #include "content/browser/gamepad/gamepad_standard_mappings.h"
6 6
7 #include "content/common/gamepad_hardware_buffer.h" 7 #include "content/common/gamepad_hardware_buffer.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 namespace { 11 namespace {
12 12
13 // This defines our canonical mapping order for gamepad-like devices. If these
14 // items cannot all be satisfied, it is a case-by-case judgement as to whether
15 // it is better to leave the device unmapped, or to partially map it. In
16 // general, err towards leaving it *unmapped* so that content can handle
17 // appropriately.
18
19 enum CanonicalButtonIndex {
20 kButtonPrimary,
21 kButtonSecondary,
22 kButtonTertiary,
23 kButtonQuaternary,
24 kButtonLeftShoulder,
25 kButtonRightShoulder,
26 kButtonLeftTrigger,
27 kButtonRightTrigger,
28 kButtonBackSelect,
29 kButtonStart,
30 kButtonLeftThumbstick,
31 kButtonRightThumbstick,
32 kButtonDpadUp,
33 kButtonDpadDown,
34 kButtonDpadLeft,
35 kButtonDpadRight,
36 kButtonMeta,
37 kNumButtons
38 };
39
40 enum CanonicalAxisIndex {
41 kAxisLeftStickX,
42 kAxisLeftStickY,
43 kAxisRightStickX,
44 kAxisRightStickY,
45 kNumAxes
46 };
47
48 float AxisToButton(float input) { 13 float AxisToButton(float input) {
49 return (input + 1.f) / 2.f; 14 return (input + 1.f) / 2.f;
50 } 15 }
51 16
52 float AxisNegativeAsButton(float input) { 17 float AxisNegativeAsButton(float input) {
53 return (input < -0.5f) ? 1.f : 0.f; 18 return (input < -0.5f) ? 1.f : 0.f;
54 } 19 }
55 20
56 float AxisPositiveAsButton(float input) { 21 float AxisPositiveAsButton(float input) {
57 return (input > 0.5f) ? 1.f : 0.f; 22 return (input > 0.5f) ? 1.f : 0.f;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 { "045e", "028f", MapperXInputStyleGamepad }, // Xbox 360 Wireless Controller 100 { "045e", "028f", MapperXInputStyleGamepad }, // Xbox 360 Wireless Controller
136 { "046d", "c21d", MapperXInputStyleGamepad }, // Logitech F310 101 { "046d", "c21d", MapperXInputStyleGamepad }, // Logitech F310
137 { "046d", "c21e", MapperXInputStyleGamepad }, // Logitech F510 102 { "046d", "c21e", MapperXInputStyleGamepad }, // Logitech F510
138 { "046d", "c21f", MapperXInputStyleGamepad }, // Logitech F710 103 { "046d", "c21f", MapperXInputStyleGamepad }, // Logitech F710
139 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS 104 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS
140 { "0925", "8866", MapperMP8866 }, // WiseGroup MP-8866 105 { "0925", "8866", MapperMP8866 }, // WiseGroup MP-8866
141 }; 106 };
142 107
143 } // namespace 108 } // namespace
144 109
145 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( 110 GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
jam 2012/01/24 18:27:04 this code is now used on mac, so the file should b
146 const base::StringPiece& vendor_id, 111 const base::StringPiece& vendor_id,
147 const base::StringPiece& product_id) { 112 const base::StringPiece& product_id) {
148 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 113 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
149 MappingData& item = AvailableMappings[i]; 114 MappingData& item = AvailableMappings[i];
150 if (vendor_id == item.vendor_id && product_id == item.product_id) 115 if (vendor_id == item.vendor_id && product_id == item.product_id)
151 return item.function; 116 return item.function;
152 } 117 }
153 return NULL; 118 return NULL;
154 } 119 }
155 120
156 } // namespace content 121 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_standard_mappings_linux.h ('k') | content/browser/gamepad/gamepad_standard_mappings_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698