Add pointing stick device class

This is treated the same as a mouse, except that the "Device Pointing
Stick" property is set to true instead of "Device Mouse".

BUG=chromium:1114828
TEST=compile Chromium to always use the new class, check things
     basically work

Change-Id: I8f52f3807e63ea8752c6726aca81818a4eb3179f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/gestures/+/2465650
Reviewed-by: Sean O'Brien <seobrien@chromium.org>
Tested-by: Harry Cutts <hcutts@chromium.org>
Commit-Queue: Harry Cutts <hcutts@chromium.org>
diff --git a/include/gestures.h b/include/gestures.h
index 26c980f..3d44ec0 100644
--- a/include/gestures.h
+++ b/include/gestures.h
@@ -38,6 +38,7 @@
   GESTURES_DEVCLASS_MULTITOUCH_MOUSE,
   GESTURES_DEVCLASS_TOUCHPAD,
   GESTURES_DEVCLASS_TOUCHSCREEN,
+  GESTURES_DEVCLASS_POINTING_STICK,
 };
 
 stime_t StimeFromTimeval(const struct timeval*);
@@ -563,7 +564,7 @@
  private:
   void InitializeTouchpad(void);
   void InitializeTouchpad2(void);
-  void InitializeMouse(void);
+  void InitializeMouse(GestureInterpreterDeviceClass cls);
   void InitializeMultitouchMouse(void);
 
   GestureReadyFunction callback_;
diff --git a/include/scaling_filter_interpreter.h b/include/scaling_filter_interpreter.h
index 28d1346..977e1b2 100644
--- a/include/scaling_filter_interpreter.h
+++ b/include/scaling_filter_interpreter.h
@@ -68,6 +68,7 @@
   void FilterLowPressure(HardwareState* hwstate);
   void FilterZeroArea(HardwareState* hwstate);
   bool IsMouseDevice(GestureInterpreterDeviceClass devclass);
+  bool IsPointingStick(GestureInterpreterDeviceClass devclass);
   bool IsTouchpadDevice(GestureInterpreterDeviceClass devclass);
 
   float tp_x_scale_, tp_y_scale_;
@@ -122,6 +123,9 @@
   // touchpad at the same time (e.g. a multi-touch mouse).
   BoolProperty device_mouse_;
 
+  // If the device is a pointing stick (e.g. a TrackPoint).
+  BoolProperty device_pointing_stick_;
+
   // If the device is touchpad. It would be false if it is a regular mouse
   // running the CMT driver.
   BoolProperty device_touchpad_;
diff --git a/src/gestures.cc b/src/gestures.cc
index 34c54dd..8820a8a 100644
--- a/src/gestures.cc
+++ b/src/gestures.cc
@@ -592,14 +592,14 @@
   temp = NULL;
 }
 
-void GestureInterpreter::InitializeMouse(void) {
+void GestureInterpreter::InitializeMouse(GestureInterpreterDeviceClass cls) {
   Interpreter* temp = new MouseInterpreter(prop_reg_.get(), tracer_.get());
   // TODO(clchiou;chromium-os:36321): Use mouse acceleration algorithm for mice
   temp = new AccelFilterInterpreter(prop_reg_.get(), temp, tracer_.get());
   temp = new ScalingFilterInterpreter(prop_reg_.get(), temp, tracer_.get(),
-                                      GESTURES_DEVCLASS_MOUSE);
+                                      cls);
   temp = new MetricsFilterInterpreter(prop_reg_.get(), temp, tracer_.get(),
-                                      GESTURES_DEVCLASS_MOUSE);
+                                      cls);
   temp = new IntegralGestureFilterInterpreter(temp, tracer_.get());
   temp = loggingFilter_ = new LoggingFilterInterpreter(prop_reg_.get(), temp,
                                                        tracer_.get());
@@ -635,8 +635,9 @@
   if (cls == GESTURES_DEVCLASS_TOUCHPAD ||
       cls == GESTURES_DEVCLASS_TOUCHSCREEN)
     InitializeTouchpad();
-  else if (cls == GESTURES_DEVCLASS_MOUSE)
-    InitializeMouse();
+  else if (cls == GESTURES_DEVCLASS_MOUSE ||
+           cls == GESTURES_DEVCLASS_POINTING_STICK)
+    InitializeMouse(cls);
   else if (cls == GESTURES_DEVCLASS_MULTITOUCH_MOUSE)
     InitializeMultitouchMouse();
   else
diff --git a/src/metrics_filter_interpreter.cc b/src/metrics_filter_interpreter.cc
index e8ef2e7..04653dc 100644
--- a/src/metrics_filter_interpreter.cc
+++ b/src/metrics_filter_interpreter.cc
@@ -59,7 +59,8 @@
     // as well after gaining access to the UMA log.
     UpdateFingerState(*hwstate);
   } else if (devclass_ == GESTURES_DEVCLASS_MOUSE ||
-             devclass_ == GESTURES_DEVCLASS_MULTITOUCH_MOUSE) {
+             devclass_ == GESTURES_DEVCLASS_MULTITOUCH_MOUSE ||
+             devclass_ == GESTURES_DEVCLASS_POINTING_STICK) {
     UpdateMouseMovementState(*hwstate);
   }
   next_->SyncInterpret(hwstate, timeout);
diff --git a/src/scaling_filter_interpreter.cc b/src/scaling_filter_interpreter.cc
index 3b4368c..cc43066 100644
--- a/src/scaling_filter_interpreter.cc
+++ b/src/scaling_filter_interpreter.cc
@@ -40,6 +40,8 @@
           0),
       mouse_cpi_(prop_reg, "Mouse CPI", 1000.0),
       device_mouse_(prop_reg, "Device Mouse", IsMouseDevice(devclass)),
+      device_pointing_stick_(prop_reg, "Device Pointing Stick",
+                             IsPointingStick(devclass)),
       device_touchpad_(prop_reg,
                        "Device Touchpad",
                        IsTouchpadDevice(devclass)) {
@@ -101,6 +103,11 @@
           devclass == GESTURES_DEVCLASS_MULTITOUCH_MOUSE);
 }
 
+bool ScalingFilterInterpreter::IsPointingStick(
+    GestureInterpreterDeviceClass devclass) {
+  return devclass == GESTURES_DEVCLASS_POINTING_STICK;
+}
+
 bool ScalingFilterInterpreter::IsTouchpadDevice(
     GestureInterpreterDeviceClass devclass) {
   return (devclass == GESTURES_DEVCLASS_TOUCHPAD ||
@@ -111,7 +118,7 @@
 void ScalingFilterInterpreter::ScaleHardwareState(HardwareState* hwstate) {
   if (device_touchpad_.val_)
     ScaleTouchpadHardwareState(hwstate);
-  if (device_mouse_.val_)
+  if (device_mouse_.val_ || device_pointing_stick_.val_)
     ScaleMouseHardwareState(hwstate);
 }