ScalingFilterInterpreter: Option to force touch count to match finger

This is used for the situation where a modern pad may support hover,
and thus have a finger count != touch count, which would trigger old
(T5R2) behavior. By forcing touch count to match, we avoid that issue.

BUG=chrome-os-partner:36892
TEST=Manually tested on Samus

Change-Id: I55d03dc67bc928f93ee5086df664933a81d17f72
Reviewed-on: https://chromium-review.googlesource.com/251761
Reviewed-by: Charlie Mooney <charliemooney@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Tested-by: Andrew de los Reyes <adlr@chromium.org>
Commit-Queue: Andrew de los Reyes <adlr@chromium.org>
diff --git a/include/scaling_filter_interpreter.h b/include/scaling_filter_interpreter.h
index 1c610c5..2d78749 100644
--- a/include/scaling_filter_interpreter.h
+++ b/include/scaling_filter_interpreter.h
@@ -101,6 +101,10 @@
   DoubleProperty pressure_translate_;
   DoubleProperty pressure_threshold_;
 
+  // If true, adjust touch count to match finger count when scaling
+  // input state. This can help avoid being considered a T5R2 pad.
+  BoolProperty force_touch_count_to_match_finger_count_;
+
   DoubleProperty mouse_cpi_;
 
   HardwareProperties friendly_props_;
diff --git a/src/scaling_filter_interpreter.cc b/src/scaling_filter_interpreter.cc
index 10b8de6..0578d6c 100644
--- a/src/scaling_filter_interpreter.cc
+++ b/src/scaling_filter_interpreter.cc
@@ -33,6 +33,10 @@
       pressure_scale_(prop_reg, "Pressure Calibration Slope", 1.0),
       pressure_translate_(prop_reg, "Pressure Calibration Offset", 0.0),
       pressure_threshold_(prop_reg, "Pressure Minimum Threshold", 0.0),
+      force_touch_count_to_match_finger_count_(
+          prop_reg,
+          "Force Touch Count To Match Finger Count",
+          0),
       mouse_cpi_(prop_reg, "Mouse CPI", 1000.0),
       device_mouse_(prop_reg, "Device Mouse", IsMouseDevice(devclass)),
       device_touchpad_(prop_reg,
@@ -120,6 +124,9 @@
 
 void ScalingFilterInterpreter::ScaleTouchpadHardwareState(
     HardwareState* hwstate) {
+  if (force_touch_count_to_match_finger_count_.val_)
+    hwstate->touch_cnt = hwstate->finger_cnt;
+
   if (surface_area_from_pressure_.val_) {
     // Drop the small fingers, i.e. low pressures.
     FilterLowPressure(hwstate);