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

Side by Side Diff: device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java

Issue 2081583002: Migrating majority of gamepad from content/browser/ to device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final tweaks Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package org.chromium.content.browser.input; 5 package org.chromium.device.gamepad;
6 6
7 import android.view.KeyEvent; 7 import android.view.KeyEvent;
8 import android.view.MotionEvent; 8 import android.view.MotionEvent;
9 9
10 import org.chromium.base.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
11 import org.chromium.base.annotations.JNINamespace; 11 import org.chromium.base.annotations.JNINamespace;
12 12
13 /** 13 /**
14 * Class to manage mapping information related to each supported gamepad control ler device. 14 * Class to manage mapping information related to each supported gamepad control ler device.
15 */ 15 */
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 float a = rawButtons[KeyEvent.KEYCODE_BUTTON_A]; 53 float a = rawButtons[KeyEvent.KEYCODE_BUTTON_A];
54 float b = rawButtons[KeyEvent.KEYCODE_BUTTON_B]; 54 float b = rawButtons[KeyEvent.KEYCODE_BUTTON_B];
55 float x = rawButtons[KeyEvent.KEYCODE_BUTTON_X]; 55 float x = rawButtons[KeyEvent.KEYCODE_BUTTON_X];
56 float y = rawButtons[KeyEvent.KEYCODE_BUTTON_Y]; 56 float y = rawButtons[KeyEvent.KEYCODE_BUTTON_Y];
57 mappedButtons[CanonicalButtonIndex.PRIMARY] = a; 57 mappedButtons[CanonicalButtonIndex.PRIMARY] = a;
58 mappedButtons[CanonicalButtonIndex.SECONDARY] = b; 58 mappedButtons[CanonicalButtonIndex.SECONDARY] = b;
59 mappedButtons[CanonicalButtonIndex.TERTIARY] = x; 59 mappedButtons[CanonicalButtonIndex.TERTIARY] = x;
60 mappedButtons[CanonicalButtonIndex.QUATERNARY] = y; 60 mappedButtons[CanonicalButtonIndex.QUATERNARY] = y;
61 } 61 }
62 62
63 private static void mapCommonStartSelectMetaButtons( 63 private static void mapCommonStartSelectMetaButtons(float[] mappedButtons, f loat[] rawButtons) {
64 float[] mappedButtons, float[] rawButtons) {
65 float start = rawButtons[KeyEvent.KEYCODE_BUTTON_START]; 64 float start = rawButtons[KeyEvent.KEYCODE_BUTTON_START];
66 float select = rawButtons[KeyEvent.KEYCODE_BUTTON_SELECT]; 65 float select = rawButtons[KeyEvent.KEYCODE_BUTTON_SELECT];
67 float mode = rawButtons[KeyEvent.KEYCODE_BUTTON_MODE]; 66 float mode = rawButtons[KeyEvent.KEYCODE_BUTTON_MODE];
68 mappedButtons[CanonicalButtonIndex.START] = start; 67 mappedButtons[CanonicalButtonIndex.START] = start;
69 mappedButtons[CanonicalButtonIndex.BACK_SELECT] = select; 68 mappedButtons[CanonicalButtonIndex.BACK_SELECT] = select;
70 mappedButtons[CanonicalButtonIndex.META] = mode; 69 mappedButtons[CanonicalButtonIndex.META] = mode;
71 } 70 }
72 71
73 private static void mapCommonThumbstickButtons(float[] mappedButtons, float[ ] rawButtons) { 72 private static void mapCommonThumbstickButtons(float[] mappedButtons, float[ ] rawButtons) {
74 float thumbL = rawButtons[KeyEvent.KEYCODE_BUTTON_THUMBL]; 73 float thumbL = rawButtons[KeyEvent.KEYCODE_BUTTON_THUMBL];
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 mapHatAxisToDpadButtons(mappedButtons, rawAxes); 170 mapHatAxisToDpadButtons(mappedButtons, rawAxes);
172 171
173 mapXYAxes(mappedAxes, rawAxes); 172 mapXYAxes(mappedAxes, rawAxes);
174 mapZAndRZAxesToRightStick(mappedAxes, rawAxes); 173 mapZAndRZAxesToRightStick(mappedAxes, rawAxes);
175 } 174 }
176 175
177 /** 176 /**
178 * Method for mapping Nvidia gamepad axis and button values 177 * Method for mapping Nvidia gamepad axis and button values
179 * to standard gamepad button and axes values. 178 * to standard gamepad button and axes values.
180 */ 179 */
181 private static void mapShieldGamepad(float[] mappedButtons, float[] rawButto ns, 180 private static void mapShieldGamepad(
182 float[] mappedAxes, float[] rawAxes) { 181 float[] mappedButtons, float[] rawButtons, float[] mappedAxes, float [] rawAxes) {
183 mapCommonXYABButtons(mappedButtons, rawButtons); 182 mapCommonXYABButtons(mappedButtons, rawButtons);
184 mapTriggerButtonsToTopShoulder(mappedButtons, rawButtons); 183 mapTriggerButtonsToTopShoulder(mappedButtons, rawButtons);
185 mapCommonThumbstickButtons(mappedButtons, rawButtons); 184 mapCommonThumbstickButtons(mappedButtons, rawButtons);
186 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons); 185 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons);
187 mapTriggerAxesToBottomShoulder(mappedButtons, rawAxes); 186 mapTriggerAxesToBottomShoulder(mappedButtons, rawAxes);
188 mapHatAxisToDpadButtons(mappedButtons, rawAxes); 187 mapHatAxisToDpadButtons(mappedButtons, rawAxes);
189 188
190 mapXYAxes(mappedAxes, rawAxes); 189 mapXYAxes(mappedAxes, rawAxes);
191 mapZAndRZAxesToRightStick(mappedAxes, rawAxes); 190 mapZAndRZAxesToRightStick(mappedAxes, rawAxes);
192 } 191 }
193 192
194 /** 193 /**
195 * Method for mapping Microsoft XBox 360 gamepad axis and button values 194 * Method for mapping Microsoft XBox 360 gamepad axis and button values
196 * to standard gamepad button and axes values. 195 * to standard gamepad button and axes values.
197 */ 196 */
198 private static void mapXBox360Gamepad(float[] mappedButtons, float[] rawButt ons, 197 private static void mapXBox360Gamepad(
199 float[] mappedAxes, float[] rawAxes) { 198 float[] mappedButtons, float[] rawButtons, float[] mappedAxes, float [] rawAxes) {
200 // These are actually mapped the same way in Android. 199 // These are actually mapped the same way in Android.
201 mapShieldGamepad(mappedButtons, rawButtons, mappedAxes, rawAxes); 200 mapShieldGamepad(mappedButtons, rawButtons, mappedAxes, rawAxes);
202 } 201 }
203 202
204 private static void mapPS3SixAxisGamepad(float[] mappedButtons, float[] rawB uttons, 203 private static void mapPS3SixAxisGamepad(
205 float[] mappedAxes, float[] rawAxes) { 204 float[] mappedButtons, float[] rawButtons, float[] mappedAxes, float [] rawAxes) {
206 // On PS3 X/Y has higher priority. 205 // On PS3 X/Y has higher priority.
207 float a = rawButtons[KeyEvent.KEYCODE_BUTTON_A]; 206 float a = rawButtons[KeyEvent.KEYCODE_BUTTON_A];
208 float b = rawButtons[KeyEvent.KEYCODE_BUTTON_B]; 207 float b = rawButtons[KeyEvent.KEYCODE_BUTTON_B];
209 float x = rawButtons[KeyEvent.KEYCODE_BUTTON_X]; 208 float x = rawButtons[KeyEvent.KEYCODE_BUTTON_X];
210 float y = rawButtons[KeyEvent.KEYCODE_BUTTON_Y]; 209 float y = rawButtons[KeyEvent.KEYCODE_BUTTON_Y];
211 mappedButtons[CanonicalButtonIndex.PRIMARY] = x; 210 mappedButtons[CanonicalButtonIndex.PRIMARY] = x;
212 mappedButtons[CanonicalButtonIndex.SECONDARY] = y; 211 mappedButtons[CanonicalButtonIndex.SECONDARY] = y;
213 mappedButtons[CanonicalButtonIndex.TERTIARY] = a; 212 mappedButtons[CanonicalButtonIndex.TERTIARY] = a;
214 mappedButtons[CanonicalButtonIndex.QUATERNARY] = b; 213 mappedButtons[CanonicalButtonIndex.QUATERNARY] = b;
215 214
216 mapCommonTriggerButtons(mappedButtons, rawButtons); 215 mapCommonTriggerButtons(mappedButtons, rawButtons);
217 mapCommonThumbstickButtons(mappedButtons, rawButtons); 216 mapCommonThumbstickButtons(mappedButtons, rawButtons);
218 mapCommonDpadButtons(mappedButtons, rawButtons); 217 mapCommonDpadButtons(mappedButtons, rawButtons);
219 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons); 218 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons);
220 mapTriggerAxexToShoulderButtons(mappedButtons, rawAxes); 219 mapTriggerAxexToShoulderButtons(mappedButtons, rawAxes);
221 220
222 mapXYAxes(mappedAxes, rawAxes); 221 mapXYAxes(mappedAxes, rawAxes);
223 mapZAndRZAxesToRightStick(mappedAxes, rawAxes); 222 mapZAndRZAxesToRightStick(mappedAxes, rawAxes);
224 } 223 }
225 224
226 private static void mapSamsungEIGP20Gamepad(float[] mappedButtons, float[] r awButtons, 225 private static void mapSamsungEIGP20Gamepad(
227 float[] mappedAxes, float[] rawAxes) { 226 float[] mappedButtons, float[] rawButtons, float[] mappedAxes, float [] rawAxes) {
228 mapCommonXYABButtons(mappedButtons, rawButtons); 227 mapCommonXYABButtons(mappedButtons, rawButtons);
229 mapCommonTriggerButtons(mappedButtons, rawButtons); 228 mapCommonTriggerButtons(mappedButtons, rawButtons);
230 mapCommonThumbstickButtons(mappedButtons, rawButtons); 229 mapCommonThumbstickButtons(mappedButtons, rawButtons);
231 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons); 230 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons);
232 mapHatAxisToDpadButtons(mappedButtons, rawAxes); 231 mapHatAxisToDpadButtons(mappedButtons, rawAxes);
233 232
234 mapXYAxes(mappedAxes, rawAxes); 233 mapXYAxes(mappedAxes, rawAxes);
235 mapRXAndRYAxesToRightStick(mappedAxes, rawAxes); 234 mapRXAndRYAxesToRightStick(mappedAxes, rawAxes);
236 } 235 }
237 236
238 /** 237 /**
239 * Method for mapping Unkown gamepad axis and button values 238 * Method for mapping Unkown gamepad axis and button values
240 * to standard gamepad button and axes values. 239 * to standard gamepad button and axes values.
241 */ 240 */
242 private static void mapUnknownGamepad(float[] mappedButtons, float[] rawButt ons, 241 private static void mapUnknownGamepad(
243 float[] mappedAxes, float[] rawAxes) { 242 float[] mappedButtons, float[] rawButtons, float[] mappedAxes, float [] rawAxes) {
244 mapCommonXYABButtons(mappedButtons, rawButtons); 243 mapCommonXYABButtons(mappedButtons, rawButtons);
245 mapCommonTriggerButtons(mappedButtons, rawButtons); 244 mapCommonTriggerButtons(mappedButtons, rawButtons);
246 mapCommonThumbstickButtons(mappedButtons, rawButtons); 245 mapCommonThumbstickButtons(mappedButtons, rawButtons);
247 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons); 246 mapCommonStartSelectMetaButtons(mappedButtons, rawButtons);
248 mapTriggerAxexToShoulderButtons(mappedButtons, rawAxes); 247 mapTriggerAxexToShoulderButtons(mappedButtons, rawAxes);
249 mapCommonDpadButtons(mappedButtons, rawButtons); 248 mapCommonDpadButtons(mappedButtons, rawButtons);
250 249
251 mapXYAxes(mappedAxes, rawAxes); 250 mapXYAxes(mappedAxes, rawAxes);
252 mapRXAndRYAxesToRightStick(mappedAxes, rawAxes); 251 mapRXAndRYAxesToRightStick(mappedAxes, rawAxes);
253 } 252 }
254 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698