Add fields to InputMessageBuilder
Added transformation fields to InputMessageBuilder. The purpose is to
enable motion event methods when stubbing messages in tests.
Bug: 297226446
Flag: EXEMPT refactor
Test: TEST=libinput_tests; m $TEST && $ANDROID_HOST_OUT/nativetest64/$TEST/$TEST --gtest_filter="ResamplerTest*"
Change-Id: Ic258d108d40287ef1d08751ab2f92d59e7e86f86
diff --git a/include/input/InputEventBuilders.h b/include/input/InputEventBuilders.h
index 5bd5070..1899a66 100644
--- a/include/input/InputEventBuilders.h
+++ b/include/input/InputEventBuilders.h
@@ -21,6 +21,7 @@
#include <input/Input.h>
#include <input/InputTransport.h>
#include <ui/LogicalDisplayId.h>
+#include <ui/Transform.h>
#include <utils/Timers.h> // for nsecs_t, systemTime
#include <vector>
@@ -94,16 +95,81 @@
return *this;
}
+ InputMessageBuilder& hmac(const std::array<uint8_t, 32>& hmac) {
+ mHmac = hmac;
+ return *this;
+ }
+
InputMessageBuilder& action(int32_t action) {
mAction = action;
return *this;
}
+ InputMessageBuilder& actionButton(int32_t actionButton) {
+ mActionButton = actionButton;
+ return *this;
+ }
+
+ InputMessageBuilder& flags(int32_t flags) {
+ mFlags = flags;
+ return *this;
+ }
+
+ InputMessageBuilder& metaState(int32_t metaState) {
+ mMetaState = metaState;
+ return *this;
+ }
+
+ InputMessageBuilder& buttonState(int32_t buttonState) {
+ mButtonState = buttonState;
+ return *this;
+ }
+
+ InputMessageBuilder& classification(MotionClassification classification) {
+ mClassification = classification;
+ return *this;
+ }
+
+ InputMessageBuilder& edgeFlags(int32_t edgeFlags) {
+ mEdgeFlags = edgeFlags;
+ return *this;
+ }
+
InputMessageBuilder& downTime(nsecs_t downTime) {
mDownTime = downTime;
return *this;
}
+ InputMessageBuilder& transform(const ui::Transform& transform) {
+ mTransform = transform;
+ return *this;
+ }
+
+ InputMessageBuilder& xPrecision(float xPrecision) {
+ mXPrecision = xPrecision;
+ return *this;
+ }
+
+ InputMessageBuilder& yPrecision(float yPrecision) {
+ mYPrecision = yPrecision;
+ return *this;
+ }
+
+ InputMessageBuilder& xCursorPosition(float xCursorPosition) {
+ mXCursorPosition = xCursorPosition;
+ return *this;
+ }
+
+ InputMessageBuilder& yCursorPosition(float yCursorPosition) {
+ mYCursorPosition = yCursorPosition;
+ return *this;
+ }
+
+ InputMessageBuilder& rawTransform(const ui::Transform& rawTransform) {
+ mRawTransform = rawTransform;
+ return *this;
+ }
+
InputMessageBuilder& pointer(PointerBuilder pointerBuilder) {
mPointers.push_back(pointerBuilder);
return *this;
@@ -121,8 +187,30 @@
message.body.motion.deviceId = mDeviceId;
message.body.motion.source = mSource;
message.body.motion.displayId = mDisplayId.val();
+ message.body.motion.hmac = std::move(mHmac);
message.body.motion.action = mAction;
+ message.body.motion.actionButton = mActionButton;
+ message.body.motion.flags = mFlags;
+ message.body.motion.metaState = mMetaState;
+ message.body.motion.buttonState = mButtonState;
+ message.body.motion.edgeFlags = mEdgeFlags;
message.body.motion.downTime = mDownTime;
+ message.body.motion.dsdx = mTransform.dsdx();
+ message.body.motion.dtdx = mTransform.dtdx();
+ message.body.motion.dtdy = mTransform.dtdy();
+ message.body.motion.dsdy = mTransform.dsdy();
+ message.body.motion.tx = mTransform.ty();
+ message.body.motion.ty = mTransform.tx();
+ message.body.motion.xPrecision = mXPrecision;
+ message.body.motion.yPrecision = mYPrecision;
+ message.body.motion.xCursorPosition = mXCursorPosition;
+ message.body.motion.yCursorPosition = mYCursorPosition;
+ message.body.motion.dsdxRaw = mRawTransform.dsdx();
+ message.body.motion.dtdxRaw = mRawTransform.dtdx();
+ message.body.motion.dtdyRaw = mRawTransform.dtdy();
+ message.body.motion.dsdyRaw = mRawTransform.dsdy();
+ message.body.motion.txRaw = mRawTransform.ty();
+ message.body.motion.tyRaw = mRawTransform.tx();
for (size_t i = 0; i < mPointers.size(); ++i) {
message.body.motion.pointers[i].properties = mPointers[i].buildProperties();
@@ -140,9 +228,21 @@
DeviceId mDeviceId{DEFAULT_DEVICE_ID};
int32_t mSource{AINPUT_SOURCE_TOUCHSCREEN};
ui::LogicalDisplayId mDisplayId{ui::LogicalDisplayId::DEFAULT};
+ std::array<uint8_t, 32> mHmac{INVALID_HMAC};
int32_t mAction{AMOTION_EVENT_ACTION_MOVE};
+ int32_t mActionButton{0};
+ int32_t mFlags{0};
+ int32_t mMetaState{AMETA_NONE};
+ int32_t mButtonState{0};
+ MotionClassification mClassification{MotionClassification::NONE};
+ int32_t mEdgeFlags{0};
nsecs_t mDownTime{mEventTime};
-
+ ui::Transform mTransform{};
+ float mXPrecision{1.0f};
+ float mYPrecision{1.0f};
+ float mXCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION};
+ float mYCursorPosition{AMOTION_EVENT_INVALID_CURSOR_POSITION};
+ ui::Transform mRawTransform{};
std::vector<PointerBuilder> mPointers;
};