Set up a GestureInterpreter and feed it events
This is a minimal setup of the gestures library, in that it doesn't have
a timer provider or property provider, but it's enough to be able to
feed it events and have it report the gestures it has detected.
This CL depends on https://r.android.com/2310648 to pull in the
Android.bp file and `SetCallback` rename from upstream, and
https://r.android.com/2314880 to pull in the deprecation of screen DPI
hardware properties.
Bug: 251196347
Test: connect Apple Magic Trackpad 2, make gestures, check logcat
Change-Id: Ib40880360c3865f0a98b7a067b7efe9fd8178212
diff --git a/services/inputflinger/reader/mapper/TouchpadInputMapper.h b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
index 81a76d2..9d3a4b3 100644
--- a/services/inputflinger/reader/mapper/TouchpadInputMapper.h
+++ b/services/inputflinger/reader/mapper/TouchpadInputMapper.h
@@ -16,10 +16,17 @@
#pragma once
+#include <memory>
+
#include "EventHub.h"
#include "InputDevice.h"
#include "InputMapper.h"
#include "NotifyArgs.h"
+#include "accumulator/CursorButtonAccumulator.h"
+#include "accumulator/MultiTouchMotionAccumulator.h"
+#include "accumulator/TouchButtonAccumulator.h"
+
+#include "include/gestures.h"
namespace android {
@@ -27,8 +34,20 @@
public:
explicit TouchpadInputMapper(InputDeviceContext& deviceContext);
- virtual uint32_t getSources() const override;
- [[nodiscard]] virtual std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
+ uint32_t getSources() const override;
+ [[nodiscard]] std::list<NotifyArgs> reset(nsecs_t when) override;
+ [[nodiscard]] std::list<NotifyArgs> process(const RawEvent* rawEvent) override;
+
+private:
+ void sync(nsecs_t when);
+
+ std::unique_ptr<gestures::GestureInterpreter, void (*)(gestures::GestureInterpreter*)>
+ mGestureInterpreter;
+
+ CursorButtonAccumulator mCursorButtonAccumulator;
+ MultiTouchMotionAccumulator mMotionAccumulator;
+ TouchButtonAccumulator mTouchButtonAccumulator;
+ int32_t mMscTimestamp = 0;
};
} // namespace android