summaryrefslogtreecommitdiff
path: root/include/input/Resampler.h
diff options
context:
space:
mode:
author Paul Ramirez <peramirez@google.com> 2024-08-01 17:11:58 +0000
committer Paul Ramirez <peramirez@google.com> 2024-08-19 16:29:06 +0000
commitcf1b06e7d9a0922628c6d13acd0e5d7c0eb79617 (patch)
tree4db2e1fd5eed635f2bb726aa5c4eadc4824fe12d /include/input/Resampler.h
parent00c3b29107d5fddc4634328a888de32073cdcba3 (diff)
Add multiple pointer support to LegacyResampler with tests
Added multiple pointer support to LegacyResampler and included the corresponding unit tests to ensure correctness. Bug: 297226446 Flag: EXEMPT refactor Test: TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="ResamplerTest*" Change-Id: Ib639942c31311dcdcf6d72ed33a4d4476b76fe7f
Diffstat (limited to 'include/input/Resampler.h')
-rw-r--r--include/input/Resampler.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/include/input/Resampler.h b/include/input/Resampler.h
index 5980d5d4c4..2892137ae7 100644
--- a/include/input/Resampler.h
+++ b/include/input/Resampler.h
@@ -18,6 +18,7 @@
#include <chrono>
#include <optional>
+#include <vector>
#include <input/Input.h>
#include <input/InputTransport.h>
@@ -71,7 +72,15 @@ private:
struct Sample {
std::chrono::nanoseconds eventTime;
- Pointer pointer;
+ std::vector<Pointer> pointers;
+
+ std::vector<PointerCoords> asPointerCoords() const {
+ std::vector<PointerCoords> pointersCoords;
+ for (const Pointer& pointer : pointers) {
+ pointersCoords.push_back(pointer.coords);
+ }
+ return pointersCoords;
+ }
};
/**
@@ -88,12 +97,21 @@ private:
RingBuffer<Sample> mLatestSamples{/*capacity=*/2};
/**
- * Adds up to mLatestSamples.capacity() of motionEvent's latest samples to mLatestSamples. (If
+ * Adds up to mLatestSamples.capacity() of motionEvent's latest samples to mLatestSamples. If
* motionEvent has fewer samples than mLatestSamples.capacity(), then the available samples are
- * added to mLatestSamples.)
+ * added to mLatestSamples.
*/
void updateLatestSamples(const MotionEvent& motionEvent);
+ static Sample messageToSample(const InputMessage& message);
+
+ /**
+ * Checks if auxiliary sample has the same pointer properties of target sample. That is,
+ * auxiliary pointer IDs must appear in the same order as target pointer IDs, their toolType
+ * must match and be resampleable.
+ */
+ static bool pointerPropertiesResampleable(const Sample& target, const Sample& auxiliary);
+
/**
* Checks if there are necessary conditions to interpolate. For example, interpolation cannot
* take place if samples are too far apart in time. mLatestSamples must have at least one sample
@@ -125,4 +143,4 @@ private:
inline static void addSampleToMotionEvent(const Sample& sample, MotionEvent& motionEvent);
};
-} // namespace android \ No newline at end of file
+} // namespace android