1 /*
2 * Copyright (C) 2022 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include "InputCommonConverter.h"
18
19 using namespace ::aidl::android::hardware::input;
20
21 namespace android {
22
getSource(uint32_t source)23 static common::Source getSource(uint32_t source) {
24 static_assert(static_cast<common::Source>(AINPUT_SOURCE_UNKNOWN) == common::Source::UNKNOWN,
25 "SOURCE_UNKNOWN mismatch");
26 static_assert(static_cast<common::Source>(AINPUT_SOURCE_KEYBOARD) == common::Source::KEYBOARD,
27 "SOURCE_KEYBOARD mismatch");
28 static_assert(static_cast<common::Source>(AINPUT_SOURCE_DPAD) == common::Source::DPAD,
29 "SOURCE_DPAD mismatch");
30 static_assert(static_cast<common::Source>(AINPUT_SOURCE_GAMEPAD) == common::Source::GAMEPAD,
31 "SOURCE_GAMEPAD mismatch");
32 static_assert(static_cast<common::Source>(AINPUT_SOURCE_TOUCHSCREEN) ==
33 common::Source::TOUCHSCREEN,
34 "SOURCE_TOUCHSCREEN mismatch");
35 static_assert(static_cast<common::Source>(AINPUT_SOURCE_MOUSE) == common::Source::MOUSE,
36 "SOURCE_MOUSE mismatch");
37 static_assert(static_cast<common::Source>(AINPUT_SOURCE_STYLUS) == common::Source::STYLUS,
38 "SOURCE_STYLUS mismatch");
39 static_assert(static_cast<common::Source>(AINPUT_SOURCE_BLUETOOTH_STYLUS) ==
40 common::Source::BLUETOOTH_STYLUS,
41 "SOURCE_BLUETOOTH_STYLUS mismatch");
42 static_assert(static_cast<common::Source>(AINPUT_SOURCE_TRACKBALL) == common::Source::TRACKBALL,
43 "SOURCE_TRACKBALL mismatch");
44 static_assert(static_cast<common::Source>(AINPUT_SOURCE_MOUSE_RELATIVE) ==
45 common::Source::MOUSE_RELATIVE,
46 "SOURCE_MOUSE_RELATIVE mismatch");
47 static_assert(static_cast<common::Source>(AINPUT_SOURCE_TOUCHPAD) == common::Source::TOUCHPAD,
48 "SOURCE_TOUCHPAD mismatch");
49 static_assert(static_cast<common::Source>(AINPUT_SOURCE_TOUCH_NAVIGATION) ==
50 common::Source::TOUCH_NAVIGATION,
51 "SOURCE_TOUCH_NAVIGATION mismatch");
52 static_assert(static_cast<common::Source>(AINPUT_SOURCE_JOYSTICK) == common::Source::JOYSTICK,
53 "SOURCE_JOYSTICK mismatch");
54 static_assert(static_cast<common::Source>(AINPUT_SOURCE_ROTARY_ENCODER) ==
55 common::Source::ROTARY_ENCODER,
56 "SOURCE_ROTARY_ENCODER mismatch");
57 static_assert(static_cast<common::Source>(AINPUT_SOURCE_HDMI) == common::Source::HDMI);
58 static_assert(static_cast<common::Source>(AINPUT_SOURCE_SENSOR) == common::Source::SENSOR);
59 static_assert(static_cast<common::Source>(AINPUT_SOURCE_ANY) == common::Source::ANY,
60 "SOURCE_ANY mismatch");
61 return static_cast<common::Source>(source);
62 }
63
getAction(int32_t actionMasked)64 static common::Action getAction(int32_t actionMasked) {
65 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_DOWN) == common::Action::DOWN,
66 "ACTION_DOWN mismatch");
67 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_UP) == common::Action::UP,
68 "ACTION_UP mismatch");
69 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_MOVE) == common::Action::MOVE,
70 "ACTION_MOVE mismatch");
71 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_CANCEL) ==
72 common::Action::CANCEL,
73 "ACTION_CANCEL mismatch");
74 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_OUTSIDE) ==
75 common::Action::OUTSIDE,
76 "ACTION_OUTSIDE mismatch");
77 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_POINTER_DOWN) ==
78 common::Action::POINTER_DOWN,
79 "ACTION_POINTER_DOWN mismatch");
80 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_POINTER_UP) ==
81 common::Action::POINTER_UP,
82 "ACTION_POINTER_UP mismatch");
83 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_HOVER_MOVE) ==
84 common::Action::HOVER_MOVE,
85 "ACTION_HOVER_MOVE mismatch");
86 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_SCROLL) ==
87 common::Action::SCROLL,
88 "ACTION_SCROLL mismatch");
89 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_HOVER_ENTER) ==
90 common::Action::HOVER_ENTER,
91 "ACTION_HOVER_ENTER mismatch");
92 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_HOVER_EXIT) ==
93 common::Action::HOVER_EXIT,
94 "ACTION_HOVER_EXIT mismatch");
95 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_BUTTON_PRESS) ==
96 common::Action::BUTTON_PRESS,
97 "ACTION_BUTTON_PRESS mismatch");
98 static_assert(static_cast<common::Action>(AMOTION_EVENT_ACTION_BUTTON_RELEASE) ==
99 common::Action::BUTTON_RELEASE,
100 "ACTION_BUTTON_RELEASE mismatch");
101 return static_cast<common::Action>(actionMasked);
102 }
103
getActionButton(int32_t actionButton)104 static common::Button getActionButton(int32_t actionButton) {
105 static_assert(static_cast<common::Button>(0) == common::Button::NONE, "BUTTON_NONE mismatch");
106 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_PRIMARY) ==
107 common::Button::PRIMARY,
108 "BUTTON_PRIMARY mismatch");
109 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_SECONDARY) ==
110 common::Button::SECONDARY,
111 "BUTTON_SECONDARY mismatch");
112 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_TERTIARY) ==
113 common::Button::TERTIARY,
114 "BUTTON_TERTIARY mismatch");
115 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_BACK) == common::Button::BACK,
116 "BUTTON_BACK mismatch");
117 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_FORWARD) ==
118 common::Button::FORWARD,
119 "BUTTON_FORWARD mismatch");
120 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_STYLUS_PRIMARY) ==
121 common::Button::STYLUS_PRIMARY,
122 "BUTTON_STYLUS_PRIMARY mismatch");
123 static_assert(static_cast<common::Button>(AMOTION_EVENT_BUTTON_STYLUS_SECONDARY) ==
124 common::Button::STYLUS_SECONDARY,
125 "BUTTON_STYLUS_SECONDARY mismatch");
126 return static_cast<common::Button>(actionButton);
127 }
128
getFlags(int32_t flags)129 static common::Flag getFlags(int32_t flags) {
130 static_assert(static_cast<common::Flag>(AMOTION_EVENT_FLAG_WINDOW_IS_OBSCURED) ==
131 common::Flag::WINDOW_IS_OBSCURED);
132 static_assert(static_cast<common::Flag>(AMOTION_EVENT_FLAG_IS_GENERATED_GESTURE) ==
133 common::Flag::IS_GENERATED_GESTURE);
134 static_assert(static_cast<common::Flag>(AMOTION_EVENT_FLAG_TAINTED) == common::Flag::TAINTED);
135 return static_cast<common::Flag>(flags);
136 }
137
getPolicyFlags(int32_t flags)138 static common::PolicyFlag getPolicyFlags(int32_t flags) {
139 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_WAKE) == common::PolicyFlag::WAKE);
140 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_VIRTUAL) ==
141 common::PolicyFlag::VIRTUAL);
142 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_FUNCTION) ==
143 common::PolicyFlag::FUNCTION);
144 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_GESTURE) ==
145 common::PolicyFlag::GESTURE);
146 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_INJECTED) ==
147 common::PolicyFlag::INJECTED);
148 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_TRUSTED) ==
149 common::PolicyFlag::TRUSTED);
150 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_FILTERED) ==
151 common::PolicyFlag::FILTERED);
152 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_DISABLE_KEY_REPEAT) ==
153 common::PolicyFlag::DISABLE_KEY_REPEAT);
154 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_INTERACTIVE) ==
155 common::PolicyFlag::INTERACTIVE);
156 static_assert(static_cast<common::PolicyFlag>(POLICY_FLAG_PASS_TO_USER) ==
157 common::PolicyFlag::PASS_TO_USER);
158 return static_cast<common::PolicyFlag>(flags);
159 }
160
getEdgeFlags(int32_t flags)161 static common::EdgeFlag getEdgeFlags(int32_t flags) {
162 static_assert(static_cast<common::EdgeFlag>(AMOTION_EVENT_EDGE_FLAG_NONE) ==
163 common::EdgeFlag::NONE);
164 static_assert(static_cast<common::EdgeFlag>(AMOTION_EVENT_EDGE_FLAG_TOP) ==
165 common::EdgeFlag::TOP);
166 static_assert(static_cast<common::EdgeFlag>(AMOTION_EVENT_EDGE_FLAG_BOTTOM) ==
167 common::EdgeFlag::BOTTOM);
168 static_assert(static_cast<common::EdgeFlag>(AMOTION_EVENT_EDGE_FLAG_LEFT) ==
169 common::EdgeFlag::LEFT);
170 static_assert(static_cast<common::EdgeFlag>(AMOTION_EVENT_EDGE_FLAG_RIGHT) ==
171 common::EdgeFlag::RIGHT);
172 return static_cast<common::EdgeFlag>(flags);
173 }
174
getMetastate(int32_t state)175 static common::Meta getMetastate(int32_t state) {
176 static_assert(static_cast<common::Meta>(AMETA_NONE) == common::Meta::NONE);
177 static_assert(static_cast<common::Meta>(AMETA_ALT_ON) == common::Meta::ALT_ON);
178 static_assert(static_cast<common::Meta>(AMETA_ALT_LEFT_ON) == common::Meta::ALT_LEFT_ON);
179 static_assert(static_cast<common::Meta>(AMETA_ALT_RIGHT_ON) == common::Meta::ALT_RIGHT_ON);
180 static_assert(static_cast<common::Meta>(AMETA_SHIFT_ON) == common::Meta::SHIFT_ON);
181 static_assert(static_cast<common::Meta>(AMETA_SHIFT_LEFT_ON) == common::Meta::SHIFT_LEFT_ON);
182 static_assert(static_cast<common::Meta>(AMETA_SHIFT_RIGHT_ON) == common::Meta::SHIFT_RIGHT_ON);
183 static_assert(static_cast<common::Meta>(AMETA_SYM_ON) == common::Meta::SYM_ON);
184 static_assert(static_cast<common::Meta>(AMETA_FUNCTION_ON) == common::Meta::FUNCTION_ON);
185 static_assert(static_cast<common::Meta>(AMETA_CTRL_ON) == common::Meta::CTRL_ON);
186 static_assert(static_cast<common::Meta>(AMETA_CTRL_LEFT_ON) == common::Meta::CTRL_LEFT_ON);
187 static_assert(static_cast<common::Meta>(AMETA_CTRL_RIGHT_ON) == common::Meta::CTRL_RIGHT_ON);
188 static_assert(static_cast<common::Meta>(AMETA_META_ON) == common::Meta::META_ON);
189 static_assert(static_cast<common::Meta>(AMETA_META_LEFT_ON) == common::Meta::META_LEFT_ON);
190 static_assert(static_cast<common::Meta>(AMETA_META_RIGHT_ON) == common::Meta::META_RIGHT_ON);
191 static_assert(static_cast<common::Meta>(AMETA_CAPS_LOCK_ON) == common::Meta::CAPS_LOCK_ON);
192 static_assert(static_cast<common::Meta>(AMETA_NUM_LOCK_ON) == common::Meta::NUM_LOCK_ON);
193 static_assert(static_cast<common::Meta>(AMETA_SCROLL_LOCK_ON) == common::Meta::SCROLL_LOCK_ON);
194 return static_cast<common::Meta>(state);
195 }
196
getButtonState(int32_t buttonState)197 static common::Button getButtonState(int32_t buttonState) {
198 // No need for static_assert here.
199 // The button values have already been asserted in getActionButton(..) above
200 return static_cast<common::Button>(buttonState);
201 }
202
getToolType(int32_t toolType)203 static common::ToolType getToolType(int32_t toolType) {
204 static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_UNKNOWN) ==
205 common::ToolType::UNKNOWN);
206 static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_FINGER) ==
207 common::ToolType::FINGER);
208 static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_STYLUS) ==
209 common::ToolType::STYLUS);
210 static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_MOUSE) ==
211 common::ToolType::MOUSE);
212 static_assert(static_cast<common::ToolType>(AMOTION_EVENT_TOOL_TYPE_ERASER) ==
213 common::ToolType::ERASER);
214 return static_cast<common::ToolType>(toolType);
215 }
216
217 // MotionEvent axes asserts
218 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_X) == common::Axis::X);
219 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_Y) == common::Axis::Y);
220 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_PRESSURE) == common::Axis::PRESSURE);
221 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_SIZE) == common::Axis::SIZE);
222 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_TOUCH_MAJOR) ==
223 common::Axis::TOUCH_MAJOR);
224 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_TOUCH_MINOR) ==
225 common::Axis::TOUCH_MINOR);
226 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_TOOL_MAJOR) == common::Axis::TOOL_MAJOR);
227 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_TOOL_MINOR) == common::Axis::TOOL_MINOR);
228 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_ORIENTATION) ==
229 common::Axis::ORIENTATION);
230 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_VSCROLL) == common::Axis::VSCROLL);
231 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_HSCROLL) == common::Axis::HSCROLL);
232 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_Z) == common::Axis::Z);
233 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RX) == common::Axis::RX);
234 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RY) == common::Axis::RY);
235 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RZ) == common::Axis::RZ);
236 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_HAT_X) == common::Axis::HAT_X);
237 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_HAT_Y) == common::Axis::HAT_Y);
238 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_LTRIGGER) == common::Axis::LTRIGGER);
239 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RTRIGGER) == common::Axis::RTRIGGER);
240 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_THROTTLE) == common::Axis::THROTTLE);
241 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RUDDER) == common::Axis::RUDDER);
242 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_WHEEL) == common::Axis::WHEEL);
243 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GAS) == common::Axis::GAS);
244 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_BRAKE) == common::Axis::BRAKE);
245 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_DISTANCE) == common::Axis::DISTANCE);
246 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_TILT) == common::Axis::TILT);
247 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_SCROLL) == common::Axis::SCROLL);
248 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RELATIVE_X) == common::Axis::RELATIVE_X);
249 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_RELATIVE_Y) == common::Axis::RELATIVE_Y);
250 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_1) == common::Axis::GENERIC_1);
251 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_2) == common::Axis::GENERIC_2);
252 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_3) == common::Axis::GENERIC_3);
253 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_4) == common::Axis::GENERIC_4);
254 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_5) == common::Axis::GENERIC_5);
255 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_6) == common::Axis::GENERIC_6);
256 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_7) == common::Axis::GENERIC_7);
257 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_8) == common::Axis::GENERIC_8);
258 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_9) == common::Axis::GENERIC_9);
259 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_10) == common::Axis::GENERIC_10);
260 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_11) == common::Axis::GENERIC_11);
261 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_12) == common::Axis::GENERIC_12);
262 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_13) == common::Axis::GENERIC_13);
263 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_14) == common::Axis::GENERIC_14);
264 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_15) == common::Axis::GENERIC_15);
265 static_assert(static_cast<common::Axis>(AMOTION_EVENT_AXIS_GENERIC_16) == common::Axis::GENERIC_16);
266
getHalVideoFrame(const TouchVideoFrame & frame)267 static common::VideoFrame getHalVideoFrame(const TouchVideoFrame& frame) {
268 common::VideoFrame out;
269 out.width = frame.getWidth();
270 out.height = frame.getHeight();
271 std::vector<char16_t> unsignedData(frame.getData().begin(), frame.getData().end());
272 out.data = unsignedData;
273 struct timeval timestamp = frame.getTimestamp();
274 out.timestamp = seconds_to_nanoseconds(timestamp.tv_sec) +
275 microseconds_to_nanoseconds(timestamp.tv_usec);
276 return out;
277 }
278
convertVideoFrames(const std::vector<TouchVideoFrame> & frames)279 static std::vector<common::VideoFrame> convertVideoFrames(
280 const std::vector<TouchVideoFrame>& frames) {
281 std::vector<common::VideoFrame> out;
282 for (const TouchVideoFrame& frame : frames) {
283 out.push_back(getHalVideoFrame(frame));
284 }
285 return out;
286 }
287
getHalPropertiesAndCoords(const NotifyMotionArgs & args,std::vector<common::PointerProperties> & outPointerProperties,std::vector<common::PointerCoords> & outPointerCoords)288 static void getHalPropertiesAndCoords(const NotifyMotionArgs& args,
289 std::vector<common::PointerProperties>& outPointerProperties,
290 std::vector<common::PointerCoords>& outPointerCoords) {
291 outPointerProperties.reserve(args.pointerCount);
292 outPointerCoords.reserve(args.pointerCount);
293 for (size_t i = 0; i < args.pointerCount; i++) {
294 common::PointerProperties properties;
295 properties.id = args.pointerProperties[i].id;
296 properties.toolType = getToolType(args.pointerProperties[i].toolType);
297 outPointerProperties.push_back(properties);
298
299 common::PointerCoords coords;
300 // OK to copy bits because we have static_assert for pointerCoords axes
301 coords.bits = args.pointerCoords[i].bits;
302 coords.values = std::vector<float>(args.pointerCoords[i].values,
303 args.pointerCoords[i].values +
304 BitSet64::count(args.pointerCoords[i].bits));
305 outPointerCoords.push_back(coords);
306 }
307 }
308
notifyMotionArgsToHalMotionEvent(const NotifyMotionArgs & args)309 common::MotionEvent notifyMotionArgsToHalMotionEvent(const NotifyMotionArgs& args) {
310 common::MotionEvent event;
311 event.deviceId = args.deviceId;
312 event.source = getSource(args.source);
313 event.displayId = args.displayId;
314 event.downTime = args.downTime;
315 event.eventTime = args.eventTime;
316 event.deviceTimestamp = 0;
317 event.action = getAction(args.action & AMOTION_EVENT_ACTION_MASK);
318 event.actionIndex = MotionEvent::getActionIndex(args.action);
319 event.actionButton = getActionButton(args.actionButton);
320 event.flags = getFlags(args.flags);
321 event.policyFlags = getPolicyFlags(args.policyFlags);
322 event.edgeFlags = getEdgeFlags(args.edgeFlags);
323 event.metaState = getMetastate(args.metaState);
324 event.buttonState = getButtonState(args.buttonState);
325 event.xPrecision = args.xPrecision;
326 event.yPrecision = args.yPrecision;
327
328 std::vector<common::PointerProperties> pointerProperties;
329 std::vector<common::PointerCoords> pointerCoords;
330 getHalPropertiesAndCoords(args, /*out*/ pointerProperties, /*out*/ pointerCoords);
331 event.pointerProperties = pointerProperties;
332 event.pointerCoords = pointerCoords;
333
334 event.frames = convertVideoFrames(args.videoFrames);
335
336 return event;
337 }
338
339 } // namespace android
340