summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashant Malani <pmalani@google.com>2016-01-11 17:08:18 -0800
committerPrashant Malani <pmalani@google.com>2016-01-11 17:37:38 -0800
commitee03865fe5fc6ffe9deda0e0870a18206027cfaf (patch)
tree77aad41f476667638b6be9b6496b2430c7ced31f
parent68fca5a1763203164a19a9aa983895242a671387 (diff)
downloadframeworks_native-ee03865fe5fc6ffe9deda0e0870a18206027cfaf.zip
frameworks_native-ee03865fe5fc6ffe9deda0e0870a18206027cfaf.tar.gz
frameworks_native-ee03865fe5fc6ffe9deda0e0870a18206027cfaf.tar.bz2
inputflinger: Add support for scaling and true value reporting
-1/+1 somewhat simplifies the values that can be generated by rotary encoders, and rules out the possibility of batching and more nuanced movement reporting. So, we modify the device configuration to allow values other than -1 and 1 to be supported. In order to give the developer a sense of what these values map to in terms of angular displacement, we also parse a resolution configuration from the devices IDC file. This will be specified as: device.res = xxxx of type float. If a value is not provided, a default res value of 0.0f is used. This patch also adds a per device scaling factor, which is used to suitably modify the values reported (as well as the resolution) to tune the input events generated and resulting UI according to the hardware. This can be specified in the IDC file as: device.scalingFactor = xxxx of type float. If a scaling factor is not provided, a default of 1.0f is used. Bug: 22836852 Bug: 18707397 Change-Id: I13686f64de1b52d3f6c97b2587ae41e52d1db6e2
-rw-r--r--services/inputflinger/InputReader.cpp15
-rw-r--r--services/inputflinger/InputReader.h1
2 files changed, 14 insertions, 2 deletions
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index 3ba38b5..8063a75 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -2751,7 +2751,18 @@ void RotaryEncoderInputMapper::populateDeviceInfo(InputDeviceInfo* info) {
InputMapper::populateDeviceInfo(info);
if (mRotaryEncoderScrollAccumulator.haveRelativeVWheel()) {
- info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f, 0.0f);
+ float res = 0.0f;
+ if (!mDevice->getConfiguration().tryGetProperty(String8("device.res"), res)) {
+ ALOGW("Rotary Encoder device configuration file didn't specify resolution!\n");
+ }
+ if (!mDevice->getConfiguration().tryGetProperty(String8("device.scalingFactor"),
+ mScalingFactor)) {
+ ALOGW("Rotary Encoder device configuration file didn't specify scaling factor,"
+ "default to 1.0!\n");
+ mScalingFactor = 1.0f;
+ }
+ info->addMotionRange(AMOTION_EVENT_AXIS_SCROLL, mSource, -1.0f, 1.0f, 0.0f, 0.0f,
+ res * mScalingFactor);
}
}
@@ -2807,7 +2818,7 @@ void RotaryEncoderInputMapper::sync(nsecs_t when) {
// Send motion event.
if (scrolled) {
int32_t metaState = mContext->getGlobalMetaState();
- pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll);
+ pointerCoords.setAxisValue(AMOTION_EVENT_AXIS_SCROLL, scroll * mScalingFactor);
NotifyMotionArgs scrollArgs(when, getDeviceId(), mSource, policyFlags,
AMOTION_EVENT_ACTION_SCROLL, 0, 0, metaState, 0,
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index 3e931fe..46d45d8 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -1247,6 +1247,7 @@ private:
CursorScrollAccumulator mRotaryEncoderScrollAccumulator;
int32_t mSource;
+ float mScalingFactor;
void sync(nsecs_t when);
};