More aggressive palm filtering on top edge
If top edge palm filtering is enabled, treat touches along the top edge
the same as side edges, with a wider palm envelope, etc.
BUG=b:67504283
TEST=deployed to device and passes touchtest suite
Change-Id: I530ceab5a5de851cfa73942d2223ba13526ea046
Reviewed-on: https://chromium-review.googlesource.com/706147
Commit-Ready: Sean O'Brien <seobrien@chromium.org>
Tested-by: Sean O'Brien <seobrien@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
diff --git a/include/palm_classifying_filter_interpreter.h b/include/palm_classifying_filter_interpreter.h
index ac504b0..0077db9 100644
--- a/include/palm_classifying_filter_interpreter.h
+++ b/include/palm_classifying_filter_interpreter.h
@@ -49,13 +49,13 @@
size_t finger_idx);
// Returns true iff fs represents a contact that may be a palm. It's a palm
- // if it's in the edge of the pad with sufficiently large pressure. The
- // pressure required depends on exactly how close to the edge the contact is.
+ // if it's in the side edge (or top edge if filter_top_edge_ is set) with
+ // sufficiently large pressure. The pressure required depends on exactly how
+ // close to the edge the contact is.
bool FingerInPalmEnvelope(const FingerState& fs);
- // Returns true iff fs represents a contact that is in the bottom area, or
- // top area if top edge filtering is enabled.
- bool FingerInFilteredHorizontalEdge(const FingerState& fs);
+ // Returns true iff fs represents a contact that is in the bottom area.
+ bool FingerInBottomArea(const FingerState& fs);
// Updates *palm_, pointing_ below.
void UpdatePalmState(const HardwareState& hwstate);
diff --git a/src/palm_classifying_filter_interpreter.cc b/src/palm_classifying_filter_interpreter.cc
index 10bc90a..98ebe61 100644
--- a/src/palm_classifying_filter_interpreter.cc
+++ b/src/palm_classifying_filter_interpreter.cc
@@ -150,13 +150,13 @@
(fs.pressure / palm_pressure_.val_) *
(palm_edge_width_.val_ - palm_edge_min_width_.val_);
return fs.position_x < limit ||
- fs.position_x > (hwprops_->right - limit);
+ fs.position_x > (hwprops_->right - limit) ||
+ (filter_top_edge_.val_ && fs.position_y < palm_edge_min_width_.val_);
}
-bool PalmClassifyingFilterInterpreter::FingerInFilteredHorizontalEdge(
+bool PalmClassifyingFilterInterpreter::FingerInBottomArea(
const FingerState& fs) {
- return fs.position_y > (hwprops_->bottom - palm_edge_min_width_.val_) ||
- (filter_top_edge_.val_ && fs.position_y < palm_edge_min_width_.val_);
+ return fs.position_y > (hwprops_->bottom - palm_edge_min_width_.val_);
}
void PalmClassifyingFilterInterpreter::UpdatePalmState(
@@ -173,7 +173,7 @@
for (short i = 0; i < hwstate.finger_cnt; i++) {
const FingerState& fs = hwstate.fingers[i];
- if (!(FingerInPalmEnvelope(fs) || FingerInFilteredHorizontalEdge(fs)))
+ if (!(FingerInPalmEnvelope(fs) || FingerInBottomArea(fs)))
fingers_not_in_edge_.insert(fs.tracking_id);
// Mark anything over the palm thresh as a palm
if (fs.pressure >= palm_pressure_.val_ ||
@@ -230,7 +230,7 @@
// If another finger is close by, let this be pointing
bool near_finger = FingerNearOtherFinger(hwstate, i);
bool on_edge = FingerInPalmEnvelope(fs) ||
- FingerInFilteredHorizontalEdge(fs);
+ FingerInBottomArea(fs);
if (!prev_pointing && (near_finger || !on_edge)) {
unsigned reason = (near_finger ? kPointCloseToFinger : 0) |
((!on_edge) ? kPointNotInEdge : 0);
@@ -265,7 +265,7 @@
}
if (DistSq(origin_fingerstates_[fs.tracking_id], fs) >
kPalmStationaryDistSq || !(FingerInPalmEnvelope(fs) ||
- FingerInFilteredHorizontalEdge(fs))) {
+ FingerInBottomArea(fs))) {
// Finger moving a lot or not in palm envelope; not a stationary palm.
non_stationary_palm_.insert(fs.tracking_id);
continue;
@@ -292,7 +292,7 @@
!SetContainsValue(was_near_other_fingers_, fs->tracking_id)) {
if (FingerInPalmEnvelope(*fs)) {
fs->flags |= GESTURES_FINGER_PALM;
- } else if (FingerInFilteredHorizontalEdge(*fs)) {
+ } else if (FingerInBottomArea(*fs)) {
fs->flags |= (GESTURES_FINGER_WARP_X | GESTURES_FINGER_WARP_Y);
}
} else if (MapContainsKey(pointing_, fs->tracking_id) &&