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

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

Issue 617103007: Revert of 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 MapperXInputStyleGamepad( 11 void MapperXInputStyleGamepad(const blink::WebGamepad& input,
12 const blink::WebGamepad& input, 12 blink::WebGamepad* mapped) {
13 blink::WebGamepad* mapped) {
14 *mapped = input; 13 *mapped = input;
15 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]); 14 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
16 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]); 15 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
17 mapped->buttons[kButtonBackSelect] = input.buttons[6]; 16 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
18 mapped->buttons[kButtonStart] = input.buttons[7]; 17 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
19 mapped->buttons[kButtonLeftThumbstick] = input.buttons[9]; 18 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9];
20 mapped->buttons[kButtonRightThumbstick] = input.buttons[10]; 19 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
21 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]); 20 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
22 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]); 21 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
23 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]); 22 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
24 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]); 23 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
25 mapped->buttons[kButtonMeta] = input.buttons[8]; 24 AxisPositiveAsButton(input.axes[6]);
26 mapped->axes[kAxisRightStickX] = input.axes[3]; 25 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8];
27 mapped->axes[kAxisRightStickY] = input.axes[4]; 26 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
28 mapped->buttonsLength = kNumButtons; 27 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
29 mapped->axesLength = kNumAxes; 28 mapped->buttonsLength = BUTTON_INDEX_COUNT;
29 mapped->axesLength = AXIS_INDEX_COUNT;
30 } 30 }
31 31
32 void MapperLakeviewResearch( 32 void MapperLakeviewResearch(const blink::WebGamepad& input,
33 const blink::WebGamepad& input, 33 blink::WebGamepad* mapped) {
34 blink::WebGamepad* mapped) {
35 *mapped = input; 34 *mapped = input;
36 mapped->buttons[kButtonPrimary] = input.buttons[2]; 35 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
37 mapped->buttons[kButtonTertiary] = input.buttons[3]; 36 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
38 mapped->buttons[kButtonQuaternary] = input.buttons[0]; 37 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
39 mapped->buttons[kButtonLeftShoulder] = input.buttons[6]; 38 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
40 mapped->buttons[kButtonRightShoulder] = input.buttons[7]; 39 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
41 mapped->buttons[kButtonLeftTrigger] = input.buttons[4]; 40 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
42 mapped->buttons[kButtonRightTrigger] = input.buttons[5]; 41 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
43 mapped->buttons[kButtonBackSelect] = input.buttons[9]; 42 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[9];
44 mapped->buttons[kButtonStart] = input.buttons[8]; 43 mapped->buttons[BUTTON_INDEX_START] = input.buttons[8];
45 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[5]); 44 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]);
46 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[5]); 45 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]);
47 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[4]); 46 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]);
48 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[4]); 47 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
49 mapped->buttonsLength = kNumButtons - 1; // no Meta on this device 48 AxisPositiveAsButton(input.axes[4]);
50 mapped->axesLength = kNumAxes; 49 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device
50 mapped->axesLength = AXIS_INDEX_COUNT;
51 } 51 }
52 52
53 void MapperPlaystationSixAxis( 53 void MapperPlaystationSixAxis(const blink::WebGamepad& input,
54 const blink::WebGamepad& input, 54 blink::WebGamepad* mapped) {
55 blink::WebGamepad* mapped) {
56 *mapped = input; 55 *mapped = input;
57 mapped->buttons[kButtonPrimary] = input.buttons[14]; 56 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[14];
58 mapped->buttons[kButtonSecondary] = input.buttons[13]; 57 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[13];
59 mapped->buttons[kButtonTertiary] = input.buttons[15]; 58 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[15];
60 mapped->buttons[kButtonQuaternary] = input.buttons[12]; 59 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[12];
61 mapped->buttons[kButtonLeftShoulder] = input.buttons[10]; 60 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[10];
62 mapped->buttons[kButtonRightShoulder] = input.buttons[11]; 61 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[11];
63 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[12]); 62 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[12]);
64 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[13]); 63 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[13]);
65 mapped->buttons[kButtonBackSelect] = input.buttons[0]; 64 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[0];
66 mapped->buttons[kButtonStart] = input.buttons[3]; 65 mapped->buttons[BUTTON_INDEX_START] = input.buttons[3];
67 mapped->buttons[kButtonLeftThumbstick] = input.buttons[1]; 66 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[1];
68 mapped->buttons[kButtonRightThumbstick] = input.buttons[2]; 67 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[2];
69 mapped->buttons[kButtonDpadUp] = AxisToButton(input.axes[8]); 68 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisToButton(input.axes[8]);
70 mapped->buttons[kButtonDpadDown] = AxisToButton(input.axes[10]); 69 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisToButton(input.axes[10]);
71 mapped->buttons[kButtonDpadLeft] = input.buttons[7]; 70 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = input.buttons[7];
72 mapped->buttons[kButtonDpadRight] = AxisToButton(input.axes[9]); 71 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] = AxisToButton(input.axes[9]);
73 mapped->buttons[kButtonMeta] = input.buttons[16]; 72 mapped->buttons[BUTTON_INDEX_META] = input.buttons[16];
74 73
75 mapped->buttonsLength = kNumButtons; 74 mapped->buttonsLength = BUTTON_INDEX_COUNT;
76 mapped->axesLength = kNumAxes; 75 mapped->axesLength = AXIS_INDEX_COUNT;
77 } 76 }
78 77
79 void MapperDualshock4( 78 void MapperDualshock4(const blink::WebGamepad& input,
80 const blink::WebGamepad& input, 79 blink::WebGamepad* mapped) {
81 blink::WebGamepad* mapped) {
82 enum Dualshock4Buttons { 80 enum Dualshock4Buttons {
83 kTouchpadButton = kNumButtons, 81 DUALSHOCK_BUTTON_TOUCHPAD = BUTTON_INDEX_COUNT,
84 kNumDualshock4Buttons 82 DUALSHOCK_BUTTON_COUNT
85 }; 83 };
86 84
87 *mapped = input; 85 *mapped = input;
88 mapped->buttons[kButtonPrimary] = input.buttons[1]; 86 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[1];
89 mapped->buttons[kButtonSecondary] = input.buttons[2]; 87 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[2];
90 mapped->buttons[kButtonTertiary] = input.buttons[0]; 88 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[0];
91 mapped->buttons[kButtonQuaternary] = input.buttons[3]; 89 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[3];
92 mapped->buttons[kButtonLeftShoulder] = input.buttons[4]; 90 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[4];
93 mapped->buttons[kButtonRightShoulder] = input.buttons[5]; 91 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[5];
94 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[3]); 92 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[3]);
95 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]); 93 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
96 mapped->buttons[kButtonBackSelect] = input.buttons[8]; 94 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[8];
97 mapped->buttons[kButtonStart] = input.buttons[9]; 95 mapped->buttons[BUTTON_INDEX_START] = input.buttons[9];
98 mapped->buttons[kButtonLeftThumbstick] = input.buttons[10]; 96 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[10];
99 mapped->buttons[kButtonRightThumbstick] = input.buttons[11]; 97 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[11];
100 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]); 98 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
101 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]); 99 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
102 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]); 100 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
103 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]); 101 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
104 mapped->buttons[kButtonMeta] = input.buttons[12]; 102 AxisPositiveAsButton(input.axes[6]);
105 mapped->buttons[kTouchpadButton] = input.buttons[13]; 103 mapped->buttons[BUTTON_INDEX_META] = input.buttons[12];
106 mapped->axes[kAxisRightStickY] = input.axes[5]; 104 mapped->buttons[DUALSHOCK_BUTTON_TOUCHPAD] = input.buttons[13];
105 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[5];
107 106
108 mapped->buttonsLength = kNumDualshock4Buttons; 107 mapped->buttonsLength = DUALSHOCK_BUTTON_COUNT;
109 mapped->axesLength = kNumAxes; 108 mapped->axesLength = AXIS_INDEX_COUNT;
110 } 109 }
111 110
112 void MapperXGEAR( 111 void MapperXGEAR(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
113 const blink::WebGamepad& input,
114 blink::WebGamepad* mapped) {
115 *mapped = input; 112 *mapped = input;
116 mapped->buttons[kButtonPrimary] = input.buttons[2]; 113 mapped->buttons[BUTTON_INDEX_PRIMARY] = input.buttons[2];
117 mapped->buttons[kButtonSecondary] = input.buttons[1]; 114 mapped->buttons[BUTTON_INDEX_SECONDARY] = input.buttons[1];
118 mapped->buttons[kButtonTertiary] = input.buttons[3]; 115 mapped->buttons[BUTTON_INDEX_TERTIARY] = input.buttons[3];
119 mapped->buttons[kButtonQuaternary] = input.buttons[0]; 116 mapped->buttons[BUTTON_INDEX_QUATERNARY] = input.buttons[0];
120 mapped->buttons[kButtonLeftShoulder] = input.buttons[6]; 117 mapped->buttons[BUTTON_INDEX_LEFT_SHOULDER] = input.buttons[6];
121 mapped->buttons[kButtonRightShoulder] = input.buttons[7]; 118 mapped->buttons[BUTTON_INDEX_RIGHT_SHOULDER] = input.buttons[7];
122 mapped->buttons[kButtonLeftTrigger] = input.buttons[4]; 119 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = input.buttons[4];
123 mapped->buttons[kButtonRightTrigger] = input.buttons[5]; 120 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = input.buttons[5];
124 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[5]); 121 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[5]);
125 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[5]); 122 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[5]);
126 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[4]); 123 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[4]);
127 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[4]); 124 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
128 mapped->axes[kAxisRightStickX] = input.axes[3]; 125 AxisPositiveAsButton(input.axes[4]);
129 mapped->axes[kAxisRightStickY] = input.axes[2]; 126 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
130 mapped->buttonsLength = kNumButtons - 1; // no Meta on this device 127 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[2];
131 mapped->axesLength = kNumAxes; 128 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device
129 mapped->axesLength = AXIS_INDEX_COUNT;
132 } 130 }
133 131
134 132 void MapperDragonRiseGeneric(const blink::WebGamepad& input,
135 void MapperDragonRiseGeneric( 133 blink::WebGamepad* mapped) {
136 const blink::WebGamepad& input,
137 blink::WebGamepad* mapped) {
138 *mapped = input; 134 *mapped = input;
139 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[6]); 135 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[6]);
140 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[6]); 136 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[6]);
141 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[5]); 137 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[5]);
142 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[5]); 138 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
143 mapped->axes[kAxisLeftStickX] = input.axes[0]; 139 AxisPositiveAsButton(input.axes[5]);
144 mapped->axes[kAxisLeftStickY] = input.axes[1]; 140 mapped->axes[AXIS_INDEX_LEFT_STICK_X] = input.axes[0];
145 mapped->axes[kAxisRightStickX] = input.axes[3]; 141 mapped->axes[AXIS_INDEX_LEFT_STICK_Y] = input.axes[1];
146 mapped->axes[kAxisRightStickY] = input.axes[4]; 142 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
147 mapped->buttonsLength = kNumButtons - 1; // no Meta on this device 143 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
148 mapped->axesLength = kNumAxes; 144 mapped->buttonsLength = BUTTON_INDEX_COUNT - 1; // no Meta on this device
145 mapped->axesLength = AXIS_INDEX_COUNT;
149 } 146 }
150 147
151 void MapperOnLiveWireless( 148 void MapperOnLiveWireless(const blink::WebGamepad& input,
152 const blink::WebGamepad& input, 149 blink::WebGamepad* mapped) {
153 blink::WebGamepad* mapped) {
154 *mapped = input; 150 *mapped = input;
155 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[2]); 151 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[2]);
156 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[5]); 152 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[5]);
157 mapped->buttons[kButtonBackSelect] = input.buttons[6]; 153 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = input.buttons[6];
158 mapped->buttons[kButtonStart] = input.buttons[7]; 154 mapped->buttons[BUTTON_INDEX_START] = input.buttons[7];
159 mapped->buttons[kButtonLeftThumbstick] = input.buttons[9]; 155 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[9];
160 mapped->buttons[kButtonRightThumbstick] = input.buttons[10]; 156 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[10];
161 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]); 157 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
162 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]); 158 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
163 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]); 159 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
164 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]); 160 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
165 mapped->buttons[kButtonMeta] = input.buttons[8]; 161 AxisPositiveAsButton(input.axes[6]);
166 mapped->axes[kAxisRightStickX] = input.axes[3]; 162 mapped->buttons[BUTTON_INDEX_META] = input.buttons[8];
167 mapped->axes[kAxisRightStickY] = input.axes[4]; 163 mapped->axes[AXIS_INDEX_RIGHT_STICK_X] = input.axes[3];
164 mapped->axes[AXIS_INDEX_RIGHT_STICK_Y] = input.axes[4];
168 165
169 mapped->buttonsLength = kNumButtons; 166 mapped->buttonsLength = BUTTON_INDEX_COUNT;
170 mapped->axesLength = kNumAxes; 167 mapped->axesLength = AXIS_INDEX_COUNT;
171 } 168 }
172 169
173 void MapperADT1( 170 void MapperADT1(const blink::WebGamepad& input, blink::WebGamepad* mapped) {
174 const blink::WebGamepad& input,
175 blink::WebGamepad* mapped) {
176 *mapped = input; 171 *mapped = input;
177 mapped->buttons[kButtonLeftTrigger] = AxisToButton(input.axes[5]); 172 mapped->buttons[BUTTON_INDEX_LEFT_TRIGGER] = AxisToButton(input.axes[5]);
178 mapped->buttons[kButtonRightTrigger] = AxisToButton(input.axes[4]); 173 mapped->buttons[BUTTON_INDEX_RIGHT_TRIGGER] = AxisToButton(input.axes[4]);
179 mapped->buttons[kButtonBackSelect] = NullButton(); 174 mapped->buttons[BUTTON_INDEX_BACK_SELECT] = NullButton();
180 mapped->buttons[kButtonStart] = NullButton(); 175 mapped->buttons[BUTTON_INDEX_START] = NullButton();
181 mapped->buttons[kButtonLeftThumbstick] = input.buttons[7]; 176 mapped->buttons[BUTTON_INDEX_LEFT_THUMBSTICK] = input.buttons[7];
182 mapped->buttons[kButtonRightThumbstick] = input.buttons[8]; 177 mapped->buttons[BUTTON_INDEX_RIGHT_THUMBSTICK] = input.buttons[8];
183 mapped->buttons[kButtonDpadUp] = AxisNegativeAsButton(input.axes[7]); 178 mapped->buttons[BUTTON_INDEX_DPAD_UP] = AxisNegativeAsButton(input.axes[7]);
184 mapped->buttons[kButtonDpadDown] = AxisPositiveAsButton(input.axes[7]); 179 mapped->buttons[BUTTON_INDEX_DPAD_DOWN] = AxisPositiveAsButton(input.axes[7]);
185 mapped->buttons[kButtonDpadLeft] = AxisNegativeAsButton(input.axes[6]); 180 mapped->buttons[BUTTON_INDEX_DPAD_LEFT] = AxisNegativeAsButton(input.axes[6]);
186 mapped->buttons[kButtonDpadRight] = AxisPositiveAsButton(input.axes[6]); 181 mapped->buttons[BUTTON_INDEX_DPAD_RIGHT] =
187 mapped->buttons[kButtonMeta] = input.buttons[6]; 182 AxisPositiveAsButton(input.axes[6]);
183 mapped->buttons[BUTTON_INDEX_META] = input.buttons[6];
188 184
189 mapped->buttonsLength = kNumButtons; 185 mapped->buttonsLength = BUTTON_INDEX_COUNT;
190 mapped->axesLength = kNumAxes; 186 mapped->axesLength = AXIS_INDEX_COUNT;
191 } 187 }
192 188
193 struct MappingData { 189 struct MappingData {
194 const char* const vendor_id; 190 const char* const vendor_id;
195 const char* const product_id; 191 const char* const product_id;
196 GamepadStandardMappingFunction function; 192 GamepadStandardMappingFunction function;
197 } AvailableMappings[] = { 193 } AvailableMappings[] = {
198 // http://www.linux-usb.org/usb.ids 194 // http://www.linux-usb.org/usb.ids
199 { "0079", "0006", MapperDragonRiseGeneric }, // DragonRise Generic USB 195 {"0079", "0006", MapperDragonRiseGeneric}, // DragonRise Generic USB
200 { "045e", "028e", MapperXInputStyleGamepad }, // Xbox 360 Controller 196 {"045e", "028e", MapperXInputStyleGamepad}, // Xbox 360 Controller
201 { "045e", "028f", MapperXInputStyleGamepad }, // Xbox 360 Wireless Controller 197 {"045e",
202 { "046d", "c21d", MapperXInputStyleGamepad }, // Logitech F310 198 "028f",
203 { "046d", "c21e", MapperXInputStyleGamepad }, // Logitech F510 199 MapperXInputStyleGamepad}, // Xbox 360 Wireless Controller
204 { "046d", "c21f", MapperXInputStyleGamepad }, // Logitech F710 200 {"046d", "c21d", MapperXInputStyleGamepad}, // Logitech F310
205 { "054c", "0268", MapperPlaystationSixAxis }, // Playstation SIXAXIS 201 {"046d", "c21e", MapperXInputStyleGamepad}, // Logitech F510
206 { "054c", "05c4", MapperDualshock4 }, // Playstation Dualshock 4 202 {"046d", "c21f", MapperXInputStyleGamepad}, // Logitech F710
207 { "0925", "0005", MapperLakeviewResearch }, // SmartJoy PLUS Adapter 203 {"054c", "0268", MapperPlaystationSixAxis}, // Playstation SIXAXIS
208 { "0925", "8866", MapperLakeviewResearch }, // WiseGroup MP-8866 204 {"054c", "05c4", MapperDualshock4}, // Playstation Dualshock 4
209 { "0e8f", "0003", MapperXGEAR }, // XFXforce XGEAR PS2 Controller 205 {"0925", "0005", MapperLakeviewResearch}, // SmartJoy PLUS Adapter
210 { "2378", "1008", MapperOnLiveWireless }, // OnLive Controller (Bluetooth) 206 {"0925", "8866", MapperLakeviewResearch}, // WiseGroup MP-8866
211 { "2378", "100a", MapperOnLiveWireless }, // OnLive Controller (Wired) 207 {"0e8f", "0003", MapperXGEAR}, // XFXforce XGEAR PS2 Controller
212 { "18d1", "2c40", MapperADT1 }, // ADT-1 Controller 208 {"2378", "1008", MapperOnLiveWireless}, // OnLive Controller (Bluetooth)
209 {"2378", "100a", MapperOnLiveWireless}, // OnLive Controller (Wired)
210 {"18d1", "2c40", MapperADT1}, // ADT-1 Controller
213 }; 211 };
214 212
215 } // namespace 213 } // namespace
216 214
217 GamepadStandardMappingFunction GetGamepadStandardMappingFunction( 215 GamepadStandardMappingFunction GetGamepadStandardMappingFunction(
218 const base::StringPiece& vendor_id, 216 const base::StringPiece& vendor_id,
219 const base::StringPiece& product_id) { 217 const base::StringPiece& product_id) {
220 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) { 218 for (size_t i = 0; i < arraysize(AvailableMappings); ++i) {
221 MappingData& item = AvailableMappings[i]; 219 MappingData& item = AvailableMappings[i];
222 if (vendor_id == item.vendor_id && product_id == item.product_id) 220 if (vendor_id == item.vendor_id && product_id == item.product_id)
223 return item.function; 221 return item.function;
224 } 222 }
225 return NULL; 223 return NULL;
226 } 224 }
227 225
228 } // namespace content 226 } // 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