Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions services/inputflinger/InputReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static const nsecs_t TOUCH_DATA_TIMEOUT = ms2ns(20);
// data.
static const nsecs_t STYLUS_DATA_LATENCY = ms2ns(10);

static const nsecs_t STYLUS_PALM_REJECTION_TIME = ms2ns(50);
// --- Static Functions ---

template<typename T>
Expand Down Expand Up @@ -6285,6 +6286,7 @@ void TouchInputMapper::dispatchPointerStylus(nsecs_t when, uint32_t policyFlags)
mPointerSimple.currentProperties.id = 0;
mPointerSimple.currentProperties.toolType =
mCurrentCookedState.cookedPointerData.pointerProperties[index].toolType;
mLastStylusTime = when; // michael
} else {
down = false;
hovering = false;
Expand Down Expand Up @@ -6368,6 +6370,12 @@ void TouchInputMapper::dispatchPointerSimple(nsecs_t when, uint32_t policyFlags,
}
}

// michael
if (rejectPalm(when)) { // stylus is currently active
mPointerSimple.reset();
return;
}

if (mPointerSimple.down && !down) {
mPointerSimple.down = false;

Expand Down Expand Up @@ -6488,6 +6496,9 @@ void TouchInputMapper::dispatchMotion(nsecs_t when, uint32_t policyFlags, uint32
const PointerProperties* properties, const PointerCoords* coords,
const uint32_t* idToIndex, BitSet32 idBits, int32_t changedId,
float xPrecision, float yPrecision, nsecs_t downTime) {

if (rejectPalm(when)) return; // michael

PointerCoords pointerCoords[MAX_POINTERS];
PointerProperties pointerProperties[MAX_POINTERS];
uint32_t pointerCount = 0;
Expand Down Expand Up @@ -6561,6 +6572,16 @@ void TouchInputMapper::fadePointer() {
}
}

nsecs_t TouchInputMapper::mLastStylusTime = 0; //michael


// michael
bool TouchInputMapper::rejectPalm(nsecs_t when) {
return (when - mLastStylusTime < STYLUS_PALM_REJECTION_TIME) &&
mPointerSimple.currentProperties.toolType != AMOTION_EVENT_TOOL_TYPE_STYLUS &&
mPointerSimple.currentProperties.toolType != AMOTION_EVENT_TOOL_TYPE_ERASER;
}

void TouchInputMapper::cancelTouch(nsecs_t when) {
abortPointerUsage(when, 0 /*policyFlags*/);
abortTouches(when, 0 /* policyFlags*/);
Expand Down