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
diff --git a/services/input/InputReader.h b/services/input/InputReader.h
index 655f0f0..e2cf08e7 100644
--- a/services/input/InputReader.h
+++ b/services/input/InputReader.h
@@ -1011,38 +1011,50 @@
 private:
     struct Axis {
         RawAbsoluteAxisInfo rawAxisInfo;
+        AxisInfo axisInfo;
 
-        int32_t axis;  // axis id
         bool explicitlyMapped; // true if the axis was explicitly assigned an axis id
 
         float scale;   // scale factor from raw to normalized values
         float offset;  // offset to add after scaling for normalization
+        float highScale;  // scale factor from raw to normalized values of high split
+        float highOffset; // offset to add after scaling for normalization of high split
 
         float min;     // normalized inclusive minimum
         float max;     // normalized inclusive maximum
         float flat;    // normalized flat region size
         float fuzz;    // normalized error tolerance
 
-        float oldValue; // previous value
-        float newValue; // most recent value
-
         float filter;  // filter out small variations of this size
+        float currentValue; // current value
+        float newValue; // most recent value
+        float highCurrentValue; // current value of high split
+        float highNewValue; // most recent value of high split
 
-        void initialize(const RawAbsoluteAxisInfo& rawAxisInfo,
-                int32_t axis, bool explicitlyMapped, float scale, float offset,
+        void initialize(const RawAbsoluteAxisInfo& rawAxisInfo, const AxisInfo& axisInfo,
+                bool explicitlyMapped, float scale, float offset,
+                float highScale, float highOffset,
                 float min, float max, float flat, float fuzz) {
             this->rawAxisInfo = rawAxisInfo;
-            this->axis = axis;
+            this->axisInfo = axisInfo;
             this->explicitlyMapped = explicitlyMapped;
             this->scale = scale;
             this->offset = offset;
+            this->highScale = highScale;
+            this->highOffset = highOffset;
             this->min = min;
             this->max = max;
             this->flat = flat;
             this->fuzz = fuzz;
             this->filter = 0;
-            this->oldValue = 0;
+            resetValue();
+        }
+
+        void resetValue() {
+            this->currentValue = 0;
             this->newValue = 0;
+            this->highCurrentValue = 0;
+            this->highNewValue = 0;
         }
     };
 
@@ -1051,9 +1063,14 @@
 
     void sync(nsecs_t when, bool force);
 
-    bool haveAxis(int32_t axis);
+    bool haveAxis(int32_t axisId);
     void pruneAxes(bool ignoreExplicitlyMappedAxes);
-    bool haveAxesChangedSignificantly();
+    bool filterAxes(bool force);
+
+    static bool hasValueChangedSignificantly(float filter,
+            float newValue, float currentValue, float min, float max);
+    static bool hasMovedNearerToValueWithinFilteredRange(float filter,
+            float newValue, float currentValue, float thresholdValue);
 
     static bool isCenteredAxis(int32_t axis);
 };