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