OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.content.browser.input; |
6 | 6 |
7 import android.os.SystemClock; | 7 import android.os.SystemClock; |
8 import android.view.InputDevice; | 8 import android.view.InputDevice; |
9 import android.view.InputDevice.MotionRange; | 9 import android.view.InputDevice.MotionRange; |
10 import android.view.KeyEvent; | 10 import android.view.KeyEvent; |
(...skipping 12 matching lines...) Expand all Loading... |
23 private int mDeviceIndex; | 23 private int mDeviceIndex; |
24 // Last time the data for this gamepad was updated. | 24 // Last time the data for this gamepad was updated. |
25 private long mTimestamp; | 25 private long mTimestamp; |
26 // If this gamepad is mapped to standard gamepad? | 26 // If this gamepad is mapped to standard gamepad? |
27 private boolean mIsStandardGamepad; | 27 private boolean mIsStandardGamepad; |
28 | 28 |
29 // Array of values for all axes of the gamepad. | 29 // Array of values for all axes of the gamepad. |
30 // All axis values must be linearly normalized to the range [-1.0 .. 1.0]. | 30 // All axis values must be linearly normalized to the range [-1.0 .. 1.0]. |
31 // As appropriate, -1.0 should correspond to "up" or "left", and 1.0 | 31 // As appropriate, -1.0 should correspond to "up" or "left", and 1.0 |
32 // should correspond to "down" or "right". | 32 // should correspond to "down" or "right". |
33 private final float[] mAxisValues = new float[CanonicalAxisIndex.NUM_CANONIC
AL_AXES]; | 33 private final float[] mAxisValues = new float[CanonicalAxisIndex.COUNT]; |
34 | 34 |
35 private final float[] mButtonsValues = new float[CanonicalButtonIndex.NUM_CA
NONICAL_BUTTONS];; | 35 private final float[] mButtonsValues = new float[CanonicalButtonIndex.COUNT]
;; |
36 | 36 |
37 // When the user agent recognizes the attached inputDevice, it is recommende
d | 37 // When the user agent recognizes the attached inputDevice, it is recommende
d |
38 // that it be remapped to a canonical ordering when possible. Devices that a
re | 38 // that it be remapped to a canonical ordering when possible. Devices that a
re |
39 // not recognized should still be exposed in their raw form. Therefore we mu
st | 39 // not recognized should still be exposed in their raw form. Therefore we mu
st |
40 // pass the raw Button and raw Axis values. | 40 // pass the raw Button and raw Axis values. |
41 private final float[] mRawButtons = new float[256]; | 41 private final float[] mRawButtons = new float[256]; |
42 private final float[] mRawAxes = new float[256]; | 42 private final float[] mRawAxes = new float[256]; |
43 | 43 |
44 // An identification string for the gamepad. | 44 // An identification string for the gamepad. |
45 private String mDeviceName; | 45 private String mDeviceName; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 if (!GamepadList.isGamepadEvent(event)) return false; | 148 if (!GamepadList.isGamepadEvent(event)) return false; |
149 // Update axes values. | 149 // Update axes values. |
150 for (int i = 0; i < mAxes.length; i++) { | 150 for (int i = 0; i < mAxes.length; i++) { |
151 int axis = mAxes[i]; | 151 int axis = mAxes[i]; |
152 mRawAxes[axis] = event.getAxisValue(axis); | 152 mRawAxes[axis] = event.getAxisValue(axis); |
153 } | 153 } |
154 mTimestamp = event.getEventTime(); | 154 mTimestamp = event.getEventTime(); |
155 return true; | 155 return true; |
156 } | 156 } |
157 } | 157 } |
OLD | NEW |