Differentiate fused and unfused external styluses

An external stylus can be "fused" with touch data if it reports
pointer-specific data independently from the touch device. The only such
data we currently support is pressure. Thus, a fused external stylus
will reports pressure data.

If a fused stylus is connected, we withold all touches for up to 72
milliseconds to wait for pressure data from the stylus. If we get
pressure data within this time, we assume that the first pointer that
went down is actually the stylus, and fuse the pressure information from
the stylus to the pointer.

If an external stylus does not report pressure, it is an "unfused"
stylus.

When such an external stylus is connected, we don't withold any touches.
We still report button presses from these styluses through the touch
device.

DD: go/android-stylus-buttons

Bug: 246394583
Test: atest inputflinger_tests
Change-Id: I3d687a10630019756170e7e5e5f5d1902eb96e36
diff --git a/services/inputflinger/reader/include/StylusState.h b/services/inputflinger/reader/include/StylusState.h
index 8d14d3c..ff15e0c 100644
--- a/services/inputflinger/reader/include/StylusState.h
+++ b/services/inputflinger/reader/include/StylusState.h
@@ -24,27 +24,19 @@
 
 struct StylusState {
     /* Time the stylus event was received. */
-    nsecs_t when;
-    /* Pressure as reported by the stylus, normalized to the range [0, 1.0]. */
-    float pressure;
+    nsecs_t when{};
+    /*
+     * Pressure as reported by the stylus if supported, normalized to the range [0, 1.0].
+     * The presence of a pressure value indicates that the stylus is able to tell whether it is
+     * touching the display.
+     */
+    std::optional<float> pressure{};
     /* The state of the stylus buttons as a bitfield (e.g. AMOTION_EVENT_BUTTON_SECONDARY). */
-    uint32_t buttons;
+    uint32_t buttons{};
     /* Which tool type the stylus is currently using (e.g. AMOTION_EVENT_TOOL_TYPE_ERASER). */
-    int32_t toolType;
+    int32_t toolType{AMOTION_EVENT_TOOL_TYPE_UNKNOWN};
 
-    void copyFrom(const StylusState& other) {
-        when = other.when;
-        pressure = other.pressure;
-        buttons = other.buttons;
-        toolType = other.toolType;
-    }
-
-    void clear() {
-        when = LLONG_MAX;
-        pressure = 0.f;
-        buttons = 0;
-        toolType = AMOTION_EVENT_TOOL_TYPE_UNKNOWN;
-    }
+    void clear() { *this = StylusState{}; }
 };
 
 } // namespace android