summaryrefslogtreecommitdiffstats
path: root/services/inputflinger
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2015-04-23 17:39:53 +0100
committerMichael Wright <michaelwr@google.com>2015-05-12 14:17:42 +0100
commit53dca3aadda499824d3d0b2bbc25a72fc1a37877 (patch)
tree0a15a5d433a0b65a5bb8946ddbccc22de4dbae3b /services/inputflinger
parent43fd19fd1a22d95ed985a0680fd8806d918f3ba7 (diff)
downloadframeworks_native-53dca3aadda499824d3d0b2bbc25a72fc1a37877.tar.gz
frameworks_native-53dca3aadda499824d3d0b2bbc25a72fc1a37877.tar.bz2
frameworks_native-53dca3aadda499824d3d0b2bbc25a72fc1a37877.zip
Use previous pressure value if the current fusion data is zero.
Occasionally we'll receive the stylus up signal (pressure = 0) before we receive the touch screen up signal. Rather than giving pointer a pressure value of 0 (which is one of the signals of hovering) or falling back to the touchscreen pressure values (which would make for an inconsistent stream), use the previous pressure value which should always be non-zero for a stream of fused data. Bug: 20449776 Change-Id: I71eb97e7c4ea53e42b0eb54fc1f8ae7f89aad9d1
Diffstat (limited to 'services/inputflinger')
-rw-r--r--services/inputflinger/InputReader.cpp18
-rw-r--r--services/inputflinger/InputReader.h4
2 files changed, 14 insertions, 8 deletions
diff --git a/services/inputflinger/InputReader.cpp b/services/inputflinger/InputReader.cpp
index c6389a9c9..28887854d 100644
--- a/services/inputflinger/InputReader.cpp
+++ b/services/inputflinger/InputReader.cpp
@@ -4076,14 +4076,20 @@ void TouchInputMapper::applyExternalStylusButtonState(nsecs_t when) {
}
void TouchInputMapper::applyExternalStylusTouchState(nsecs_t when) {
- CookedPointerData& cpd = mCurrentCookedState.cookedPointerData;
- if (mExternalStylusId != -1 && cpd.isTouching(mExternalStylusId)) {
- if (mExternalStylusState.pressure != 0.0f) {
- PointerCoords& coords = cpd.editPointerCoordsWithId(mExternalStylusId);
- coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, mExternalStylusState.pressure);
+ CookedPointerData& currentPointerData = mCurrentCookedState.cookedPointerData;
+ const CookedPointerData& lastPointerData = mLastCookedState.cookedPointerData;
+
+ if (mExternalStylusId != -1 && currentPointerData.isTouching(mExternalStylusId)) {
+ float pressure = mExternalStylusState.pressure;
+ if (pressure == 0.0f && lastPointerData.isTouching(mExternalStylusId)) {
+ const PointerCoords& coords = lastPointerData.pointerCoordsForId(mExternalStylusId);
+ pressure = coords.getAxisValue(AMOTION_EVENT_AXIS_PRESSURE);
}
+ PointerCoords& coords = currentPointerData.editPointerCoordsWithId(mExternalStylusId);
+ coords.setAxisValue(AMOTION_EVENT_AXIS_PRESSURE, pressure);
- PointerProperties& properties = cpd.editPointerPropertiesWithId(mExternalStylusId);
+ PointerProperties& properties =
+ currentPointerData.editPointerPropertiesWithId(mExternalStylusId);
if (mExternalStylusState.toolType != AMOTION_EVENT_TOOL_TYPE_UNKNOWN) {
properties.toolType = mExternalStylusState.toolType;
}
diff --git a/services/inputflinger/InputReader.h b/services/inputflinger/InputReader.h
index aadc37fb4..ae090c11c 100644
--- a/services/inputflinger/InputReader.h
+++ b/services/inputflinger/InputReader.h
@@ -881,11 +881,11 @@ struct CookedPointerData {
return pointerProperties[idToIndex[id]];
}
- inline bool isHovering(uint32_t pointerIndex) {
+ inline bool isHovering(uint32_t pointerIndex) const {
return hoveringIdBits.hasBit(pointerProperties[pointerIndex].id);
}
- inline bool isTouching(uint32_t pointerIndex) {
+ inline bool isTouching(uint32_t pointerIndex) const {
return touchingIdBits.hasBit(pointerProperties[pointerIndex].id);
}
};