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