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

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

Issue 2071223002: Gamepad: Improve gamepad mapping code and unknown gamepad heuristics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing switch default case Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.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/GamepadDevice.java
diff --git a/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadDevice.java b/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadDevice.java
index 6301edc650a2b2402b7a02c1fdfd322fa402a190..f00f55820d5c0157a57eb02a54f996e110c6cb22 100644
--- a/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadDevice.java
+++ b/device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadDevice.java
@@ -35,8 +35,6 @@ class GamepadDevice {
private int mDeviceIndex;
// Last time the data for this gamepad was updated.
private long mTimestamp;
- // If this gamepad is mapped to standard gamepad?
- private boolean mIsStandardGamepad;
// Array of values for all axes of the gamepad.
// All axis values must be linearly normalized to the range [-1.0 .. 1.0].
@@ -59,6 +57,9 @@ class GamepadDevice {
// Array of axes ids.
private int[] mAxes;
+ // Mappings to canonical gamepad
+ private GamepadMappings mMappings;
+
GamepadDevice(int index, InputDevice inputDevice) {
mDeviceIndex = index;
mDeviceId = inputDevice.getId();
@@ -75,14 +76,14 @@ class GamepadDevice {
mAxes[i++] = axis;
}
}
+ mMappings = GamepadMappings.getMappings(mDeviceName, mAxes);
}
/**
* Updates the axes and buttons maping of a gamepad device to a standard gamepad format.
*/
public void updateButtonsAndAxesMapping() {
- mIsStandardGamepad = GamepadMappings.mapToStandardGamepad(
- mAxisValues, mButtonsValues, mRawAxes, mRawButtons, mDeviceName);
+ mMappings.mapToStandardGamepad(mAxisValues, mButtonsValues, mRawAxes, mRawButtons);
}
/**
@@ -96,7 +97,7 @@ class GamepadDevice {
* @return Mapping status of the gamepad device.
*/
public boolean isStandardGamepad() {
- return mIsStandardGamepad;
+ return mMappings.isStandard();
}
/**
« no previous file with comments | « no previous file | device/gamepad/android/java/src/org/chromium/device/gamepad/GamepadMappings.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698