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

Side by Side Diff: content/browser/gamepad/gamepad_standard_mappings_mac.mm

Issue 625543002: Revert of Use the new java_cpp_enum rule in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 namespace content { 7 namespace content {
8 8
9 namespace { 9 namespace {
10 10
11 void MapperXbox360Gamepad(const blink::WebGamepad& input, 11 void MapperXbox360Gamepad(
12 blink::WebGamepad* mapped) { 12 const blink::WebGamepad& input,
13 *mapped = input; 13 blink::WebGamepad* mapped) {
14 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); 14 *mapped = input;
15 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); 15 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
16 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9]; 16 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
17 mapped->buttons[BUTTON_INDEX_START] = input.buttons[8]; 17 mapped->buttons[kButtonBackSelect] = input.buttons[9];
18 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[6]; 18 mapped->buttons[kButtonStart] = input.buttons[8];
19 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[7]; 19 mapped->buttons[kButtonLeftThumbstick] = input.buttons[6];
20 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[11]; 20 mapped->buttons[kButtonRightThumbstick] = input.buttons[7];
21 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[12]; 21 mapped->buttons[kButtonDpadUp] = input.buttons[11];
22 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[13]; 22 mapped->buttons[kButtonDpadDown] = input.buttons[12];
23 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[14]; 23 mapped->buttons[kButtonDpadLeft] = input.buttons[13];
24 mapped->buttons[BUTTON_INDEX_META] = input.buttons[10]; 24 mapped->buttons[kButtonDpadRight] = input.buttons[14];
25 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; 25 mapped->buttons[kButtonMeta] = input.buttons[10];
26 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; 26 mapped->axes[kAxisRightStickX] = input.axes[3];
27 mapped->buttonsLength = BUTTON_INDEX_COUNT; 27 mapped->axes[kAxisRightStickY] = input.axes[4];
28 mapped->axesLength = AXIS_INDEX_COUNT; 28 mapped->buttonsLength = kNumButtons;
29 } 29 mapped->axesLength = kNumAxes;
30 30 }
31 void MapperPlaystationSixAxis(const blink::WebGamepad& input, 31
32 blink::WebGamepad* mapped) { 32 void MapperPlaystationSixAxis(
33 *mapped = input; 33 const blink::WebGamepad& input,
34 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14]; 34 blink::WebGamepad* mapped) {
35 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13]; 35 *mapped = input;
36 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15]; 36 mapped->buttons[kButtonPrimary] = input.buttons[14];
37 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12]; 37 mapped->buttons[kButtonSecondary] = input.buttons[13];
38 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10]; 38 mapped->buttons[kButtonTertiary] = input.buttons[15];
39 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11]; 39 mapped->buttons[kButtonQuaternary] = input.buttons[12];
40 40 mapped->buttons[kButtonLeftShoulder] = input.buttons[10];
41 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = 41 mapped->buttons[kButtonRightShoulder] = input.buttons[11];
42 ButtonFromButtonAndAxis(input.buttons[8], input.axes[14]); 42
43 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = 43 mapped->buttons[kButtonLeftTrigger] = ButtonFromButtonAndAxis(
44 ButtonFromButtonAndAxis(input.buttons[9], input.axes[15]); 44 input.buttons[8], input.axes[14]);
45 45 mapped->buttons[kButtonRightTrigger] = ButtonFromButtonAndAxis(
46 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0]; 46 input.buttons[9], input.axes[15]);
47 mapped->buttons[BUTTON_INDEX_START] = input.buttons[3]; 47
48 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1]; 48 mapped->buttons[kButtonBackSelect] = input.buttons[0];
49 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2]; 49 mapped->buttons[kButtonStart] = input.buttons[3];
50 mapped->buttons[kButtonLeftThumbstick] = input.buttons[1];
51 mapped->buttons[kButtonRightThumbstick] = input.buttons[2];
50 52
51 // The SixAxis Dpad is pressure sensative 53 // The SixAxis Dpad is pressure sensative
52 mapped->buttons[BUTTON_INDEX_DPAD_UP] = 54 mapped->buttons[kButtonDpadUp] = ButtonFromButtonAndAxis(
53 ButtonFromButtonAndAxis(input.buttons[4], input.axes[10]); 55 input.buttons[4], input.axes[10]);
54 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = 56 mapped->buttons[kButtonDpadDown] = ButtonFromButtonAndAxis(
55 ButtonFromButtonAndAxis(input.buttons[6], input.axes[12]); 57 input.buttons[6], input.axes[12]);
56 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = 58 mapped->buttons[kButtonDpadLeft] = ButtonFromButtonAndAxis(
57 ButtonFromButtonAndAxis(input.buttons[7], input.axes[13]); 59 input.buttons[7], input.axes[13]);
58 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = 60 mapped->buttons[kButtonDpadRight] = ButtonFromButtonAndAxis(
59 ButtonFromButtonAndAxis(input.buttons[5], input.axes[11]); 61 input.buttons[5], input.axes[11]);
60 62
61 mapped->buttons[BUTTON_INDEX_META] = input.buttons[16]; 63 mapped->buttons[kButtonMeta] = input.buttons[16];
62 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 64 mapped->axes[kAxisRightStickY] = input.axes[5];
63 65
64 mapped->buttonsLength = BUTTON_INDEX_COUNT; 66 mapped->buttonsLength = kNumButtons;
65 mapped->axesLength = AXIS_INDEX_COUNT; 67 mapped->axesLength = kNumAxes;
66 } 68 }
67 69
68 void MapperDualshock4(const blink::WebGamepad& input, 70 void MapperDualshock4(
69 blink::WebGamepad* mapped) { 71 const blink::WebGamepad& input,
72 blink::WebGamepad* mapped) {
70 enum Dualshock4Buttons { 73 enum Dualshock4Buttons {
71 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT, 74 kTouchpadButton = kNumButtons,
72 DUALSHOCK_BUTTON_COUNT 75 kNumDualshock4Buttons
73 }; 76 };
74 77
75 *mapped = input; 78 *mapped = input;
76 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; 79 mapped->buttons[kButtonPrimary] = input.buttons[1];
77 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; 80 mapped->buttons[kButtonSecondary] = input.buttons[2];
78 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; 81 mapped->buttons[kButtonTertiary] = input.buttons[0];
79 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3]; 82 mapped->buttons[kButtonQuaternary] = input.buttons[3];
80 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4]; 83 mapped->buttons[kButtonLeftShoulder] = input.buttons[4];
81 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5]; 84 mapped->buttons[kButtonRightShoulder] = input.buttons[5];
82 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); 85 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
83 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); 86 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
84 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8]; 87 mapped->buttons[kButtonBackSelect] = input.buttons[8];
85 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9]; 88 mapped->buttons[kButtonStart] = input.buttons[9];
86 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10]; 89 mapped->buttons[kButtonLeftThumbstick] = input.buttons[10];
87 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11]; 90 mapped->buttons[kButtonRightThumbstick] = input.buttons[11];
88 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; 91 mapped->buttons[kButtonMeta] = input.buttons[12];
89 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13]; 92 mapped->buttons[kTouchpadButton] = input.buttons[13];
90 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 93 mapped->axes[kAxisRightStickY] = input.axes[5];
91 DpadFromAxis(mapped, input.axes[9]); 94 DpadFromAxis(mapped, input.axes[9]);
92 95
93 mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT; 96 mapped->buttonsLength = kNumDualshock4Buttons;
94 mapped->axesLength = AXIS_INDEX_COUNT; 97 mapped->axesLength = kNumAxes;
95 } 98 }
96 99
97 void MapperDirectInputStyle(const blink::WebGamepad& input, 100 void MapperDirectInputStyle(
98 blink::WebGamepad* mapped) { 101 const blink::WebGamepad& input,
99 *mapped = input; 102 blink::WebGamepad* mapped) {
100 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1]; 103 *mapped = input;
101 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2]; 104 mapped->buttons[kButtonPrimary] = input.buttons[1];
102 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0]; 105 mapped->buttons[kButtonSecondary] = input.buttons[2];
103 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 106 mapped->buttons[kButtonTertiary] = input.buttons[0];
104 DpadFromAxis(mapped, input.axes[9]); 107 mapped->axes[kAxisRightStickY] = input.axes[5];
105 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ 108 DpadFromAxis(mapped, input.axes[9]);
106 mapped->axesLength = AXIS_INDEX_COUNT; 109 mapped->buttonsLength = kNumButtons - 1; /* no meta */
107 } 110 mapped->axesLength = kNumAxes;
108 111 }
109 void MapperMacallyIShock(const blink::WebGamepad& input, 112
110 blink::WebGamepad* mapped) { 113 void MapperMacallyIShock(
114 const blink::WebGamepad& input,
115 blink::WebGamepad* mapped) {
111 enum IShockButtons { 116 enum IShockButtons {
112 ISHOCK_BUTTON_C = BUTTON_INDEX_COUNT, 117 kButtonC = kNumButtons,
113 ISHOCK_BUTTON_D, 118 kButtonD,
114 ISHOCK_BUTTON_E, 119 kButtonE,
115 ISHOCK_BUTTON_COUNT, 120 kNumIShockButtons
116 }; 121 };
117 122
118 *mapped = input; 123 *mapped = input;
119 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[6]; 124 mapped->buttons[kButtonPrimary] = input.buttons[6];
120 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[5]; 125 mapped->buttons[kButtonSecondary] = input.buttons[5];
121 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[7]; 126 mapped->buttons[kButtonTertiary] = input.buttons[7];
122 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; 127 mapped->buttons[kButtonQuaternary] = input.buttons[4];
123 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[14]; 128 mapped->buttons[kButtonLeftShoulder] = input.buttons[14];
124 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[12]; 129 mapped->buttons[kButtonRightShoulder] = input.buttons[12];
125 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[15]; 130 mapped->buttons[kButtonLeftTrigger] = input.buttons[15];
126 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[13]; 131 mapped->buttons[kButtonRightTrigger] = input.buttons[13];
127 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9]; 132 mapped->buttons[kButtonBackSelect] = input.buttons[9];
128 mapped->buttons[BUTTON_INDEX_START] = input.buttons[10]; 133 mapped->buttons[kButtonStart] = input.buttons[10];
129 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[16]; 134 mapped->buttons[kButtonLeftThumbstick] = input.buttons[16];
130 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[17]; 135 mapped->buttons[kButtonRightThumbstick] = input.buttons[17];
131 mapped->buttons[BUTTON_INDEX_DPAD_UP] = input.buttons[0]; 136 mapped->buttons[kButtonDpadUp] = input.buttons[0];
132 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = input.buttons[1]; 137 mapped->buttons[kButtonDpadDown] = input.buttons[1];
133 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[2]; 138 mapped->buttons[kButtonDpadLeft] = input.buttons[2];
134 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = input.buttons[3]; 139 mapped->buttons[kButtonDpadRight] = input.buttons[3];
135 mapped->buttons[BUTTON_INDEX_META] = input.buttons[11]; 140 mapped->buttons[kButtonMeta] = input.buttons[11];
136 mapped->buttons[ISHOCK_BUTTON_C] = input.buttons[8]; 141 mapped->buttons[kButtonC] = input.buttons[8];
137 mapped->buttons[ISHOCK_BUTTON_D] = input.buttons[18]; 142 mapped->buttons[kButtonD] = input.buttons[18];
138 mapped->buttons[ISHOCK_BUTTON_E] = input.buttons[19]; 143 mapped->buttons[kButtonE] = input.buttons[19];
139 mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0]; 144 mapped->axes[kAxisLeftStickX] = input.axes[0];
140 mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1]; 145 mapped->axes[kAxisLeftStickY] = input.axes[1];
141 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = -input.axes[5]; 146 mapped->axes[kAxisRightStickX] = -input.axes[5];
142 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[6]; 147 mapped->axes[kAxisRightStickY] = input.axes[6];
143 148
144 mapped->buttonsLength = ISHOCK_BUTTON_COUNT; 149 mapped->buttonsLength = kNumIShockButtons;
145 mapped->axesLength = AXIS_INDEX_COUNT; 150 mapped->axesLength = kNumAxes;
146 } 151 }
147 152
148 void MapperXGEAR(const blink::WebGamepad& input, blink::WebGamepad* mapped) { 153 void MapperXGEAR(
149 *mapped = input; 154 const blink::WebGamepad& input,
150 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; 155 blink::WebGamepad* mapped) {
151 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 156 *mapped = input;
152 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; 157 mapped->buttons[kButtonPrimary] = input.buttons[2];
153 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; 158 mapped->buttons[kButtonTertiary] = input.buttons[3];
154 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; 159 mapped->buttons[kButtonQuaternary] = input.buttons[0];
155 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; 160 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
156 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; 161 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
157 DpadFromAxis(mapped, input.axes[9]); 162 mapped->buttons[kButtonLeftTrigger] = input.buttons[4];
158 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[5]; 163 mapped->buttons[kButtonRightTrigger] = input.buttons[5];
159 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2]; 164 DpadFromAxis(mapped, input.axes[9]);
160 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ 165 mapped->axes[kAxisRightStickX] = input.axes[5];
161 mapped->axesLength = AXIS_INDEX_COUNT; 166 mapped->axes[kAxisRightStickY] = input.axes[2];
162 } 167 mapped->buttonsLength = kNumButtons - 1; /* no meta */
163 168 mapped->axesLength = kNumAxes;
164 void MapperSmartJoyPLUS(const blink::WebGamepad& input, 169 }
165 blink::WebGamepad* mapped) { 170
166 *mapped = input; 171 void MapperSmartJoyPLUS(
167 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2]; 172 const blink::WebGamepad& input,
168 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 173 blink::WebGamepad* mapped) {
169 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0]; 174 *mapped = input;
170 mapped->buttons[BUTTON_INDEX_START] = input.buttons[8]; 175 mapped->buttons[kButtonPrimary] = input.buttons[2];
171 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9]; 176 mapped->buttons[kButtonTertiary] = input.buttons[3];
172 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; 177 mapped->buttons[kButtonQuaternary] = input.buttons[0];
173 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; 178 mapped->buttons[kButtonStart] = input.buttons[8];
174 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4]; 179 mapped->buttons[kButtonBackSelect] = input.buttons[9];
175 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5]; 180 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
176 DpadFromAxis(mapped, input.axes[9]); 181 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
177 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 182 mapped->buttons[kButtonLeftTrigger] = input.buttons[4];
178 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ 183 mapped->buttons[kButtonRightTrigger] = input.buttons[5];
179 mapped->axesLength = AXIS_INDEX_COUNT; 184 DpadFromAxis(mapped, input.axes[9]);
180 } 185 mapped->axes[kAxisRightStickY] = input.axes[5];
181 186 mapped->buttonsLength = kNumButtons - 1; /* no meta */
182 void MapperDragonRiseGeneric(const blink::WebGamepad& input, 187 mapped->axesLength = kNumAxes;
183 blink::WebGamepad* mapped) { 188 }
184 *mapped = input; 189
185 DpadFromAxis(mapped, input.axes[9]); 190 void MapperDragonRiseGeneric(
186 mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0]; 191 const blink::WebGamepad& input,
187 mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1]; 192 blink::WebGamepad* mapped) {
188 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[2]; 193 *mapped = input;
189 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 194 DpadFromAxis(mapped, input.axes[9]);
190 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; /* no meta */ 195 mapped->axes[kAxisLeftStickX] = input.axes[0];
191 mapped->axesLength = AXIS_INDEX_COUNT; 196 mapped->axes[kAxisLeftStickY] = input.axes[1];
192 } 197 mapped->axes[kAxisRightStickX] = input.axes[2];
193 198 mapped->axes[kAxisRightStickY] = input.axes[5];
194 void MapperOnLiveWireless(const blink::WebGamepad& input, 199 mapped->buttonsLength = kNumButtons - 1; /* no meta */
195 blink::WebGamepad* mapped) { 200 mapped->axesLength = kNumAxes;
196 *mapped = input; 201 }
197 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; 202
198 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; 203 void MapperOnLiveWireless(
199 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 204 const blink::WebGamepad& input,
200 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; 205 blink::WebGamepad* mapped) {
201 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; 206 *mapped = input;
202 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; 207 mapped->buttons[kButtonPrimary] = input.buttons[0];
203 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]); 208 mapped->buttons[kButtonSecondary] = input.buttons[1];
204 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]); 209 mapped->buttons[kButtonTertiary] = input.buttons[3];
205 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[10]; 210 mapped->buttons[kButtonQuaternary] = input.buttons[4];
206 mapped->buttons[BUTTON_INDEX_START] = input.buttons[11]; 211 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
207 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; 212 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
208 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; 213 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]);
209 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; 214 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]);
210 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3]; 215 mapped->buttons[kButtonBackSelect] = input.buttons[10];
211 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4]; 216 mapped->buttons[kButtonStart] = input.buttons[11];
212 DpadFromAxis(mapped, input.axes[9]); 217 mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
213 218 mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
214 mapped->buttonsLength = BUTTON_INDEX_COUNT; 219 mapped->buttons[kButtonMeta] = input.buttons[12];
215 mapped->axesLength = AXIS_INDEX_COUNT; 220 mapped->axes[kAxisRightStickX] = input.axes[3];
216 } 221 mapped->axes[kAxisRightStickY] = input.axes[4];
217 222 DpadFromAxis(mapped, input.axes[9]);
218 void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) { 223
219 *mapped = input; 224 mapped->buttonsLength = kNumButtons;
220 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[0]; 225 mapped->axesLength = kNumAxes;
221 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1]; 226 }
222 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3]; 227
223 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[4]; 228 void MapperADT1(
224 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6]; 229 const blink::WebGamepad& input,
225 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7]; 230 blink::WebGamepad* mapped) {
226 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]); 231 *mapped = input;
227 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]); 232 mapped->buttons[kButtonPrimary] = input.buttons[0];
228 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton(); 233 mapped->buttons[kButtonSecondary] = input.buttons[1];
229 mapped->buttons[BUTTON_INDEX_START] = NullButton(); 234 mapped->buttons[kButtonTertiary] = input.buttons[3];
230 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[13]; 235 mapped->buttons[kButtonQuaternary] = input.buttons[4];
231 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[14]; 236 mapped->buttons[kButtonLeftShoulder] = input.buttons[6];
232 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12]; 237 mapped->buttons[kButtonRightShoulder] = input.buttons[7];
233 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5]; 238 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]);
234 DpadFromAxis(mapped, input.axes[9]); 239 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]);
235 240 mapped->buttons[kButtonBackSelect] = NullButton();
236 mapped->buttonsLength = BUTTON_INDEX_COUNT; 241 mapped->buttons[kButtonStart] = NullButton();
237 mapped->axesLength = AXIS_INDEX_COUNT; 242 mapped->buttons[kButtonLeftThumbstick] = input.buttons[13];
243 mapped->buttons[kButtonRightThumbstick] = input.buttons[14];
244 mapped->buttons[kButtonMeta] = input.buttons[12];
245 mapped->axes[kAxisRightStickY] = input.axes[5];
246 DpadFromAxis(mapped, input.axes[9]);
247
248 mapped->buttonsLength = kNumButtons;
249 mapped->axesLength = kNumAxes;
238 } 250 }
239 251
240 struct MappingData { 252 struct MappingData {
241 const char* const vendor_id; 253 const char* const vendor_id;
242 const char* const product_id; 254 const char* const product_id;
243 GamepadStandardMappingFunction function; 255 GamepadStandardMappingFunction function;
244 } AvailableMappings[] = { 256 } AvailableMappings[] = {
245 // http://www.linux-usb.org/usb.ids 257 // http://www.linux-usb.org/usb.ids
246 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB 258 { "0079", "0006", MapperDragonRiseGeneric }, // DragonRise Generic USB
247 {"045e", "028e", MapperXbox360Gamepad}, // Xbox 360 Controller 259 { "045e", "028e", MapperXbox360Gamepad }, // Xbox 360 Controller
248 {"045e", "028f", MapperXbox360Gamepad}, // Xbox 360 Wireless Controller 260 { "045e", "028f", MapperXbox360Gamepad }, // Xbox 360 Wireless Controller
249 {"046d", "c216", MapperDirectInputStyle}, // Logitech F310, D mode 261 { "046d", "c216", MapperDirectInputStyle }, // Logitech F310, D mode
250 {"046d", "c218", MapperDirectInputStyle}, // Logitech F510, D mode 262 { "046d", "c218", MapperDirectInputStyle }, // Logitech F510, D mode
251 {"046d", "c219", MapperDirectInputStyle}, // Logitech F710, D mode 263 { "046d", "c219", MapperDirectInputStyle }, // Logitech F710, D mode
252 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS 264 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS
253 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4 265 { "054c", "05c4", MapperDualshock4 }, // Playstation Dualshock 4
254 {"0925", "0005", MapperSmartJoyPLUS}, // SmartJoy PLUS Adapter 266 { "0925", "0005", MapperSmartJoyPLUS }, // SmartJoy PLUS Adapter
255 {"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller 267 { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller
256 {"2222", "0060", MapperDirectInputStyle}, // Macally iShockX, analog mode 268 { "2222", "0060", MapperDirectInputStyle }, // Macally iShockX, analog mode
257 {"2222", "4010", MapperMacallyIShock}, // Macally iShock 269 { "2222", "4010", MapperMacallyIShock }, // Macally iShock
258 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth) 270 { "2378", "1008", MapperOnLiveWireless }, // OnLive Controller (Bluetooth)
259 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired) 271 { "2378", "100a", MapperOnLiveWireless }, // OnLive Controller (Wired)
260 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller 272 { "18d1", "2c40", MapperADT1 }, // ADT-1 Controller
261 }; 273 };
262 274
263 } // namespace 275 } // namespace
264 276
265 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( 277 GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
266 const base::StringPiece& vendor_id, 278 const base::StringPiece& vendor_id,
267 const base::StringPiece& product_id) { 279 const base::StringPiece& product_id) {
268 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 280 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
269 MappingData& item = AvailableMappings[i]; 281 MappingData& item = AvailableMappings[i];
270 if (vendor_id == item.vendor_id && product_id == item.product_id) 282 if (vendor_id == item.vendor_id && product_id == item.product_id)
271 return item.function; 283 return item.function;
272 } 284 }
273 return NULL; 285 return NULL;
274 } 286 }
275 287
276 } // namespace content 288 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/gamepad/gamepad_standard_mappings_linux.cc ('k') | content/browser/gamepad/gamepad_standard_mappings_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698