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

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

Issue 2494823005: Correct mappings for Xbox One S gamepad with new firmware (Closed)
Patch Set: Remove mappings for old firmware Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java
diff --git a/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java b/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java
index d917a0784424a54115ff148ffc6890b5a9044afd..1f067ec0921279cc80436432c7a38c7cf4101588 100644
--- a/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java
+++ b/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java
@@ -25,8 +25,6 @@ abstract class GamepadMappings {
static final String SAMSUNG_EI_GP20_DEVICE_NAME = "Samsung Game Pad EI-GP20";
@VisibleForTesting
static final String AMAZON_FIRE_DEVICE_NAME = "Amazon Fire Game Controller";
- @VisibleForTesting
- static final String MICROSOFT_XBOX_WIRELESS_DEVICE_NAME = "Xbox Wireless Controller";
public static GamepadMappings getMappings(String deviceName, int[] axes) {
if (deviceName.startsWith(NVIDIA_SHIELD_DEVICE_NAME_PREFIX)
@@ -38,8 +36,6 @@ abstract class GamepadMappings {
return new SamsungEIGP20GamepadMappings();
} else if (deviceName.equals(AMAZON_FIRE_DEVICE_NAME)) {
return new AmazonFireGamepadMappings();
- } else if (deviceName.equals(MICROSOFT_XBOX_WIRELESS_DEVICE_NAME)) {
- return new XboxWirelessGamepadMappings();
}
return new UnknownGamepadMappings(axes);
@@ -218,74 +214,6 @@ abstract class GamepadMappings {
}
}
- private static class XboxWirelessGamepadMappings extends GamepadMappings {
-
- private boolean mLeftTriggerActivated = false;
- private boolean mRightTriggerActivated = false;
-
- /**
- * Method for mapping Xbox One S controller (in Bluetooth mode) to
- * standard gamepad button and axes values.
- */
- @Override
- public void mapToStandardGamepad(float[] mappedAxes, float[] mappedButtons,
- float[] rawAxes, float[] rawButtons) {
- mappedButtons[CanonicalButtonIndex.PRIMARY] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_A];
- mappedButtons[CanonicalButtonIndex.SECONDARY] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_B];
- mappedButtons[CanonicalButtonIndex.TERTIARY] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_C];
- mappedButtons[CanonicalButtonIndex.QUATERNARY] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_X];
-
- mappedButtons[CanonicalButtonIndex.LEFT_SHOULDER] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_Y];
- mappedButtons[CanonicalButtonIndex.RIGHT_SHOULDER] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_Z];
-
- mappedButtons[CanonicalButtonIndex.BACK_SELECT] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_L1];
- mappedButtons[CanonicalButtonIndex.START] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_R1];
-
- mappedButtons[CanonicalButtonIndex.LEFT_THUMBSTICK] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_L2];
- mappedButtons[CanonicalButtonIndex.RIGHT_THUMBSTICK] =
- rawButtons[KeyEvent.KEYCODE_BUTTON_R2];
-
- // The left and right triggers on the Xbox One S controller
- // are exposed as AXIS_Z and AXIS_RZ respectively. However,
- // these nominally idle at -1 rather than 0, like other triggers.
- // Unfortunately, the -1 value is only reported upon the first
- // activation of each trigger axis. In order to prevent idling at
- // 0.5 before trigger activation, we only expose trigger values
- // when we've seen them report a non-zero value at least once.
- if (rawAxes[MotionEvent.AXIS_Z] != 0) {
- mLeftTriggerActivated = true;
- }
- if (rawAxes[MotionEvent.AXIS_RZ] != 0) {
- mRightTriggerActivated = true;
- }
- if (mLeftTriggerActivated) {
- mappedButtons[CanonicalButtonIndex.LEFT_TRIGGER] =
- (rawAxes[MotionEvent.AXIS_Z] + 1) / 2;
- } else {
- mappedButtons[CanonicalButtonIndex.LEFT_TRIGGER] = 0.f;
- }
- if (mRightTriggerActivated) {
- mappedButtons[CanonicalButtonIndex.RIGHT_TRIGGER] =
- (rawAxes[MotionEvent.AXIS_RZ] + 1) / 2;
- } else {
- mappedButtons[CanonicalButtonIndex.RIGHT_TRIGGER] = 0.f;
- }
-
- mapHatAxisToDpadButtons(mappedButtons, rawAxes);
- mapXYAxes(mappedAxes, rawAxes);
- mapRXAndRYAxesToRightStick(mappedAxes, rawAxes);
- }
- }
-
private static class PS3SixAxisGamepadMappings extends GamepadMappings {
/**
« no previous file with comments | « no previous file | device/gamepad/android/junit/src/org/chromium/device/gamepad/GamepadMappingsTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698