Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8529745b authored by Jeff Brown's avatar Jeff Brown
Browse files

Joystick tweaks. (DO NOT MERGE)

Ensure that the joystick can always reach -1.0, 0.0 and 1.0 positions
even when noise filtering is applied.  (Bug: 3514510)

Add support for a few more standard axes.

Add additional mapping modes for axes.
Some axes are inverted from standard interpretation
or are actually intended to be split into two distict axes
such as left/right trigger controls or accelerator/brake.

Add key layout file for a G25 racing wheel and XBox 360 controller
to tweak behavior.  They work fine without them but the axis mappings
are not ideal.

Change-Id: I0fddd90309af4dc14d35f34fe99ed6e521c0b7c7
parent 54bb9869
Loading
Loading
Loading
Loading
+55 −0
Original line number Diff line number Diff line
@@ -218115,6 +218115,28 @@
 visibility="public"
>
</field>
<field name="AXIS_BRAKE"
 type="int"
 transient="false"
 volatile="false"
 value="23"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_GAS"
 type="int"
 transient="false"
 volatile="false"
 value="22"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_GENERIC_1"
 type="int"
 transient="false"
@@ -218368,6 +218390,17 @@
 visibility="public"
>
</field>
<field name="AXIS_RUDDER"
 type="int"
 transient="false"
 volatile="false"
 value="20"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_RX"
 type="int"
 transient="false"
@@ -218412,6 +218445,17 @@
 visibility="public"
>
</field>
<field name="AXIS_THROTTLE"
 type="int"
 transient="false"
 volatile="false"
 value="19"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_TOOL_MAJOR"
 type="int"
 transient="false"
@@ -218467,6 +218511,17 @@
 visibility="public"
>
</field>
<field name="AXIS_WHEEL"
 type="int"
 transient="false"
 volatile="false"
 value="21"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_X"
 type="int"
 transient="false"
+86 −0
Original line number Diff line number Diff line
@@ -674,6 +674,87 @@ public final class MotionEvent extends InputEvent implements Parcelable {
     */
    public static final int AXIS_RTRIGGER = 18;

    /**
     * Constant used to identify the Throttle axis of a motion event.
     * <p>
     * <ul>
     * <li>For a joystick, reports the absolute position of the throttle control.
     * The value is normalized to a range from 0.0 (fully open) to 1.0 (fully closed).
     * </ul>
     * </p>
     *
     * @see #getAxisValue(int, int)
     * @see #getHistoricalAxisValue(int, int, int)
     * @see MotionEvent.PointerCoords#getAxisValue(int)
     * @see InputDevice#getMotionRange
     */
    public static final int AXIS_THROTTLE = 19;

    /**
     * Constant used to identify the Rudder axis of a motion event.
     * <p>
     * <ul>
     * <li>For a joystick, reports the absolute position of the rudder control.
     * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
     * </ul>
     * </p>
     *
     * @see #getAxisValue(int, int)
     * @see #getHistoricalAxisValue(int, int, int)
     * @see MotionEvent.PointerCoords#getAxisValue(int)
     * @see InputDevice#getMotionRange
     */
    public static final int AXIS_RUDDER = 20;

    /**
     * Constant used to identify the Wheel axis of a motion event.
     * <p>
     * <ul>
     * <li>For a joystick, reports the absolute position of the steering wheel control.
     * The value is normalized to a range from -1.0 (turn left) to 1.0 (turn right).
     * </ul>
     * </p>
     *
     * @see #getAxisValue(int, int)
     * @see #getHistoricalAxisValue(int, int, int)
     * @see MotionEvent.PointerCoords#getAxisValue(int)
     * @see InputDevice#getMotionRange
     */
    public static final int AXIS_WHEEL = 21;

    /**
     * Constant used to identify the Gas axis of a motion event.
     * <p>
     * <ul>
     * <li>For a joystick, reports the absolute position of the gas (accelerator) control.
     * The value is normalized to a range from 0.0 (no acceleration)
     * to 1.0 (maximum acceleration).
     * </ul>
     * </p>
     *
     * @see #getAxisValue(int, int)
     * @see #getHistoricalAxisValue(int, int, int)
     * @see MotionEvent.PointerCoords#getAxisValue(int)
     * @see InputDevice#getMotionRange
     */
    public static final int AXIS_GAS = 22;

    /**
     * Constant used to identify the Brake axis of a motion event.
     * <p>
     * <ul>
     * <li>For a joystick, reports the absolute position of the brake control.
     * The value is normalized to a range from 0.0 (no braking) to 1.0 (maximum braking).
     * </ul>
     * </p>
     *
     * @see #getAxisValue(int, int)
     * @see #getHistoricalAxisValue(int, int, int)
     * @see MotionEvent.PointerCoords#getAxisValue(int)
     * @see InputDevice#getMotionRange
     */
    public static final int AXIS_BRAKE = 23;

    /**
     * Constant used to identify the Generic 1 axis of a motion event.
     * The interpretation of a generic axis is device-specific.
@@ -877,6 +958,11 @@ public final class MotionEvent extends InputEvent implements Parcelable {
        names.append(AXIS_HAT_Y, "AXIS_HAT_Y");
        names.append(AXIS_LTRIGGER, "AXIS_LTRIGGER");
        names.append(AXIS_RTRIGGER, "AXIS_RTRIGGER");
        names.append(AXIS_THROTTLE, "AXIS_THROTTLE");
        names.append(AXIS_RUDDER, "AXIS_RUDDER");
        names.append(AXIS_WHEEL, "AXIS_WHEEL");
        names.append(AXIS_GAS, "AXIS_GAS");
        names.append(AXIS_BRAKE, "AXIS_BRAKE");
        names.append(AXIS_GENERIC_1, "AXIS_GENERIC_1");
        names.append(AXIS_GENERIC_2, "AXIS_GENERIC_2");
        names.append(AXIS_GENERIC_3, "AXIS_GENERIC_3");
+5 −1
Original line number Diff line number Diff line
@@ -409,6 +409,10 @@ axis 0x02 Z
axis 0x03 RX
axis 0x04 RY
axis 0x05 RZ
axis 0x06 THROTTLE
axis 0x07 RUDDER
axis 0x08 WHEEL
axis 0x09 GAS
axis 0x0a BRAKE
axis 0x10 HAT_X
axis 0x11 HAT_Y
 
 No newline at end of file
+46 −0
Original line number Diff line number Diff line
# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# XBox 360 USB Controller
#

key 304   BUTTON_A
key 305   BUTTON_B
key 307   BUTTON_X
key 308   BUTTON_Y
key 310   BUTTON_L1
key 311   BUTTON_R1
key 314   BUTTON_SELECT
key 315   BUTTON_START
key 316   BUTTON_MODE
key 317   BUTTON_THUMBL
key 318   BUTTON_THUMBR

# Left and right stick.
# The reported value for flat is 128 out of a range from -32767 to 32768, which is absurd.
# This confuses applications that rely on the flat value because the joystick actually
# settles in a flat range of +/- 4096 or so.
axis 0x00 X flat 4096
axis 0x01 Y flat 4096
axis 0x03 Z flat 4096
axis 0x04 RZ flat 4096

# Triggers.
axis 0x02 LTRIGGER
axis 0x05 RTRIGGER

# Hat.
axis 0x10 HAT_X
axis 0x11 HAT_Y
+53 −0
Original line number Diff line number Diff line
# Copyright (C) 2011 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

#
# Logitech G25 Racing Wheel (in Compatibility Mode)
#

# 4 way buttons above hat
key 0x121    BUTTON_A
key 0x123    BUTTON_B
key 0x120    BUTTON_X
key 0x122    BUTTON_Y

# Row of buttons under hat
key 0x12b    BUTTON_1
key 0x128    BUTTON_2
key 0x129    BUTTON_3
key 0x12a    BUTTON_4

# Gear shift positions
#   0x12a top-left gear (aliased as BUTTON_4)
#   0x12b bottom-left gear (aliased as BUTTON_1)

# Buttons on wheel
key 0x127    BUTTON_L1
key 0x126    BUTTON_R1

# Toggles under wheel
key 0x125    BUTTON_L2
key 0x124    BUTTON_R2

# Hat
axis 0x10    HAT_X
axis 0x11    HAT_Y

# Steering Wheel
axis 0x00    WHEEL

# Accelerator / Brake
#   00..7e : accelerator
#   80..ff : brake
axis 0x01    split 0x7f GAS BRAKE
Loading