diff options
| -rw-r--r-- | services/inputflinger/InputReader.cpp | 4 | ||||
| -rw-r--r-- | services/inputflinger/tests/InputReader_test.cpp | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp index e398a84391..76ea889dc5 100644 --- a/services/inputflinger/InputReader.cpp +++ b/services/inputflinger/InputReader.cpp @@ -3705,11 +3705,13 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) { // Pressure factors. mPressureScale = 0; + float pressureMax = 1.0; if (mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_PHYSICAL || mCalibration.pressureCalibration == Calibration::PRESSURE_CALIBRATION_AMPLITUDE) { if (mCalibration.havePressureScale) { mPressureScale = mCalibration.pressureScale; + pressureMax = mPressureScale * mRawPointerAxes.pressure.maxValue; } else if (mRawPointerAxes.pressure.valid && mRawPointerAxes.pressure.maxValue != 0) { mPressureScale = 1.0f / mRawPointerAxes.pressure.maxValue; @@ -3719,7 +3721,7 @@ void TouchInputMapper::configureSurface(nsecs_t when, bool* outResetNeeded) { mOrientedRanges.pressure.axis = AMOTION_EVENT_AXIS_PRESSURE; mOrientedRanges.pressure.source = mSource; mOrientedRanges.pressure.min = 0; - mOrientedRanges.pressure.max = 1.0; + mOrientedRanges.pressure.max = pressureMax; mOrientedRanges.pressure.flat = 0; mOrientedRanges.pressure.fuzz = 0; mOrientedRanges.pressure.resolution = 0; diff --git a/services/inputflinger/tests/InputReader_test.cpp b/services/inputflinger/tests/InputReader_test.cpp index 0344eadad6..63c92d1dc7 100644 --- a/services/inputflinger/tests/InputReader_test.cpp +++ b/services/inputflinger/tests/InputReader_test.cpp @@ -2954,8 +2954,8 @@ const int32_t TouchInputMapperTest::RAW_TOUCH_MIN = 0; const int32_t TouchInputMapperTest::RAW_TOUCH_MAX = 31; const int32_t TouchInputMapperTest::RAW_TOOL_MIN = 0; const int32_t TouchInputMapperTest::RAW_TOOL_MAX = 15; -const int32_t TouchInputMapperTest::RAW_PRESSURE_MIN = RAW_TOUCH_MIN; -const int32_t TouchInputMapperTest::RAW_PRESSURE_MAX = RAW_TOUCH_MAX; +const int32_t TouchInputMapperTest::RAW_PRESSURE_MIN = 0; +const int32_t TouchInputMapperTest::RAW_PRESSURE_MAX = 255; const int32_t TouchInputMapperTest::RAW_ORIENTATION_MIN = -7; const int32_t TouchInputMapperTest::RAW_ORIENTATION_MAX = 7; const int32_t TouchInputMapperTest::RAW_DISTANCE_MIN = 0; @@ -5316,6 +5316,12 @@ TEST_F(MultiTouchInputMapperTest, Process_PressureAxis_AmplitudeCalibration) { addConfigurationProperty("touch.pressure.scale", "0.01"); addMapperAndConfigure(mapper); + InputDeviceInfo info; + mapper->populateDeviceInfo(&info); + ASSERT_NO_FATAL_FAILURE(assertMotionRange(info, + AINPUT_MOTION_RANGE_PRESSURE, AINPUT_SOURCE_TOUCHSCREEN, + 0.0f, RAW_PRESSURE_MAX * 0.01, 0.0f, 0.0f)); + // These calculations are based on the input device calibration documentation. int32_t rawX = 100; int32_t rawY = 200; |