Move batching logic from consumeBatchedInputEvents
Moved MotionEvent creation and batching into createBatchedMotionEvent
Bug: 297226446
Flag: EXEMPT refactor
Test: TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST
Change-Id: I7e768f28bfae641b0ab38c4addc6b14c6dd23723
diff --git a/include/input/InputConsumerNoResampling.h b/include/input/InputConsumerNoResampling.h
index c7b1970..ae8de5f 100644
--- a/include/input/InputConsumerNoResampling.h
+++ b/include/input/InputConsumerNoResampling.h
@@ -16,8 +16,8 @@
#pragma once
+#include <input/InputTransport.h>
#include <utils/Looper.h>
-#include "InputTransport.h"
namespace android {
@@ -182,6 +182,16 @@
*/
std::map<DeviceId, std::queue<InputMessage>> mBatches;
/**
+ * Creates a MotionEvent by consuming samples from the provided queue. If one message has
+ * eventTime > frameTime, all subsequent messages in the queue will be skipped. It is assumed
+ * that messages are queued in chronological order. In other words, only events that occurred
+ * prior to the requested frameTime will be consumed.
+ * @param frameTime the time up to which to consume events
+ * @param messages the queue of messages to consume from
+ */
+ std::pair<std::unique_ptr<MotionEvent>, std::optional<uint32_t>> createBatchedMotionEvent(
+ const nsecs_t frameTime, std::queue<InputMessage>& messages);
+ /**
* A map from a single sequence number to several sequence numbers. This is needed because of
* batching. When batching is enabled, a single MotionEvent will contain several samples. Each
* sample came from an individual InputMessage of Type::Motion, and therefore will have to be