1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2021-2024 Huawei Device Co., Ltd. 3c29fa5a6Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4c29fa5a6Sopenharmony_ci * you may not use this file except in compliance with the License. 5c29fa5a6Sopenharmony_ci * You may obtain a copy of the License at 6c29fa5a6Sopenharmony_ci * 7c29fa5a6Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8c29fa5a6Sopenharmony_ci * 9c29fa5a6Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10c29fa5a6Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11c29fa5a6Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12c29fa5a6Sopenharmony_ci * See the License for the specific language governing permissions and 13c29fa5a6Sopenharmony_ci * limitations under the License. 14c29fa5a6Sopenharmony_ci */ 15c29fa5a6Sopenharmony_ci 16c29fa5a6Sopenharmony_ci#include "device_base.h" 17c29fa5a6Sopenharmony_ci 18c29fa5a6Sopenharmony_cinamespace OHOS { 19c29fa5a6Sopenharmony_cinamespace MMI { 20c29fa5a6Sopenharmony_cinamespace { 21c29fa5a6Sopenharmony_ciconstexpr int32_t FIRST_FINGER { 1 }; 22c29fa5a6Sopenharmony_ciconstexpr int32_t SECOND_FINGER { 2 }; 23c29fa5a6Sopenharmony_ciconstexpr int32_t THIRD_FINGER { 3 }; 24c29fa5a6Sopenharmony_ciconstexpr int32_t FOURTH_FINGER { 4 }; 25c29fa5a6Sopenharmony_ciconstexpr int32_t FIFTH_FINGER { 5 }; 26c29fa5a6Sopenharmony_ciconstexpr int32_t EV_ABS_MISC_DEFAULT_VALUE { 15 }; 27c29fa5a6Sopenharmony_ci} // namespace 28c29fa5a6Sopenharmony_ci 29c29fa5a6Sopenharmony_civoid DeviceBase::SetTimeToLibinputEvent(InjectEvent &injectEvent) 30c29fa5a6Sopenharmony_ci{ 31c29fa5a6Sopenharmony_ci struct timeval tm; 32c29fa5a6Sopenharmony_ci gettimeofday(&tm, 0); 33c29fa5a6Sopenharmony_ci injectEvent.event.input_event_sec = tm.tv_sec; 34c29fa5a6Sopenharmony_ci injectEvent.event.input_event_usec = tm.tv_usec; 35c29fa5a6Sopenharmony_ci} 36c29fa5a6Sopenharmony_ci 37c29fa5a6Sopenharmony_civoid DeviceBase::SetSynConfigReport(InputEventArray &inputEventArray, int64_t blockTime) 38c29fa5a6Sopenharmony_ci{ 39c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 40c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 41c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_SYN; 42c29fa5a6Sopenharmony_ci injectEvent.event.code = SYN_REPORT; 43c29fa5a6Sopenharmony_ci injectEvent.event.value = SYN_CONFIG; 44c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 45c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 46c29fa5a6Sopenharmony_ci} 47c29fa5a6Sopenharmony_ci 48c29fa5a6Sopenharmony_civoid DeviceBase::SetKeyLongPressEvent(InputEventArray& inputEventArray, int64_t blockTime, int32_t code) 49c29fa5a6Sopenharmony_ci{ 50c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 51c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 52c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 53c29fa5a6Sopenharmony_ci injectEvent.event.code = static_cast<uint16_t>(code); 54c29fa5a6Sopenharmony_ci injectEvent.event.value = LONG_PRESS; 55c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 56c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 57c29fa5a6Sopenharmony_ci} 58c29fa5a6Sopenharmony_ci 59c29fa5a6Sopenharmony_civoid DeviceBase::SetSynReport(InputEventArray& inputEventArray, int64_t blockTime) 60c29fa5a6Sopenharmony_ci{ 61c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 62c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 63c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_SYN; 64c29fa5a6Sopenharmony_ci injectEvent.event.code = SYN_REPORT; 65c29fa5a6Sopenharmony_ci injectEvent.event.value = 0; 66c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 67c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 68c29fa5a6Sopenharmony_ci} 69c29fa5a6Sopenharmony_ci 70c29fa5a6Sopenharmony_civoid DeviceBase::SetKeyPressEvent(InputEventArray& inputEventArray, int64_t blockTime, uint16_t code) 71c29fa5a6Sopenharmony_ci{ 72c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 73c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 74c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 75c29fa5a6Sopenharmony_ci injectEvent.event.code = code; 76c29fa5a6Sopenharmony_ci injectEvent.event.value = 1; 77c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 78c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 79c29fa5a6Sopenharmony_ci} 80c29fa5a6Sopenharmony_ci 81c29fa5a6Sopenharmony_civoid DeviceBase::SetKeyReleaseEvent(InputEventArray& inputEventArray, int64_t blockTime, uint16_t code) 82c29fa5a6Sopenharmony_ci{ 83c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 84c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 85c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 86c29fa5a6Sopenharmony_ci injectEvent.event.code = code; 87c29fa5a6Sopenharmony_ci injectEvent.event.value = 0; 88c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 89c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 90c29fa5a6Sopenharmony_ci} 91c29fa5a6Sopenharmony_ci 92c29fa5a6Sopenharmony_civoid DeviceBase::SetMtSlot(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 93c29fa5a6Sopenharmony_ci{ 94c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 95c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 96c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 97c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_SLOT; 98c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 99c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 100c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 101c29fa5a6Sopenharmony_ci} 102c29fa5a6Sopenharmony_ci 103c29fa5a6Sopenharmony_civoid DeviceBase::SetTrackingId(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 104c29fa5a6Sopenharmony_ci{ 105c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 106c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 107c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 108c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_TRACKING_ID; 109c29fa5a6Sopenharmony_ci static int32_t trackingId = 0; 110c29fa5a6Sopenharmony_ci injectEvent.event.value = ((value == 0) ? trackingId++ : value); 111c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 112c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 113c29fa5a6Sopenharmony_ci} 114c29fa5a6Sopenharmony_ci 115c29fa5a6Sopenharmony_civoid DeviceBase::SetPositionX(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 116c29fa5a6Sopenharmony_ci{ 117c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 118c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 119c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 120c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_POSITION_X; 121c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 122c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 123c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 124c29fa5a6Sopenharmony_ci} 125c29fa5a6Sopenharmony_ci 126c29fa5a6Sopenharmony_civoid DeviceBase::SetPositionY(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 127c29fa5a6Sopenharmony_ci{ 128c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 129c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 130c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 131c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_POSITION_Y; 132c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 133c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 134c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 135c29fa5a6Sopenharmony_ci} 136c29fa5a6Sopenharmony_ci 137c29fa5a6Sopenharmony_civoid DeviceBase::SetMtTouchMajor(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 138c29fa5a6Sopenharmony_ci{ 139c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 140c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 141c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 142c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_TOUCH_MAJOR; 143c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 144c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 145c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 146c29fa5a6Sopenharmony_ci} 147c29fa5a6Sopenharmony_ci 148c29fa5a6Sopenharmony_civoid DeviceBase::SetMtTouchMinor(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 149c29fa5a6Sopenharmony_ci{ 150c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 151c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 152c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 153c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_TOUCH_MINOR; 154c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 155c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 156c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 157c29fa5a6Sopenharmony_ci} 158c29fa5a6Sopenharmony_ci 159c29fa5a6Sopenharmony_civoid DeviceBase::SetMtOrientation(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 160c29fa5a6Sopenharmony_ci{ 161c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 162c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 163c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 164c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MT_ORIENTATION; 165c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 166c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 167c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 168c29fa5a6Sopenharmony_ci} 169c29fa5a6Sopenharmony_ci 170c29fa5a6Sopenharmony_civoid DeviceBase::SetBtnTouch(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 171c29fa5a6Sopenharmony_ci{ 172c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 173c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 174c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 175c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOUCH; 176c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 177c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 178c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 179c29fa5a6Sopenharmony_ci} 180c29fa5a6Sopenharmony_ci 181c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsX(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 182c29fa5a6Sopenharmony_ci{ 183c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 184c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 185c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 186c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_X; 187c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 188c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 189c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 190c29fa5a6Sopenharmony_ci} 191c29fa5a6Sopenharmony_ci 192c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsY(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 193c29fa5a6Sopenharmony_ci{ 194c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 195c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 196c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 197c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_Y; 198c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 199c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 200c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 201c29fa5a6Sopenharmony_ci} 202c29fa5a6Sopenharmony_ci 203c29fa5a6Sopenharmony_civoid DeviceBase::SetMtTouchFingerType(InputEventArray& inputEventArray, int64_t blockTime, 204c29fa5a6Sopenharmony_ci int32_t value, int32_t status) 205c29fa5a6Sopenharmony_ci{ 206c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 207c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 208c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 209c29fa5a6Sopenharmony_ci if (value == FIRST_FINGER) { 210c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_FINGER; 211c29fa5a6Sopenharmony_ci } else if (value == SECOND_FINGER) { 212c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_DOUBLETAP; 213c29fa5a6Sopenharmony_ci } else if (value == THIRD_FINGER) { 214c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_TRIPLETAP; 215c29fa5a6Sopenharmony_ci } else if (value == FOURTH_FINGER) { 216c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_QUADTAP; 217c29fa5a6Sopenharmony_ci } else if (value == FIFTH_FINGER) { 218c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_QUINTTAP; 219c29fa5a6Sopenharmony_ci } else { 220c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_FINGER; 221c29fa5a6Sopenharmony_ci } 222c29fa5a6Sopenharmony_ci injectEvent.event.value = status; 223c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 224c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 225c29fa5a6Sopenharmony_ci} 226c29fa5a6Sopenharmony_ci 227c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsZ(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 228c29fa5a6Sopenharmony_ci{ 229c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 230c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 231c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 232c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_Z; 233c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 234c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 235c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 236c29fa5a6Sopenharmony_ci} 237c29fa5a6Sopenharmony_ci 238c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsRx(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 239c29fa5a6Sopenharmony_ci{ 240c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 241c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 242c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 243c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_RX; 244c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 245c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 246c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 247c29fa5a6Sopenharmony_ci} 248c29fa5a6Sopenharmony_ci 249c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsRy(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 250c29fa5a6Sopenharmony_ci{ 251c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 252c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 253c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 254c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_RY; 255c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 256c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 257c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 258c29fa5a6Sopenharmony_ci} 259c29fa5a6Sopenharmony_ci 260c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsHat0X(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 261c29fa5a6Sopenharmony_ci{ 262c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 263c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 264c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 265c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_HAT0X; 266c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 267c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 268c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 269c29fa5a6Sopenharmony_ci} 270c29fa5a6Sopenharmony_ci 271c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsHat0Y(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 272c29fa5a6Sopenharmony_ci{ 273c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 274c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 275c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 276c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_HAT0Y; 277c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 278c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 279c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 280c29fa5a6Sopenharmony_ci} 281c29fa5a6Sopenharmony_ci 282c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsRz(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 283c29fa5a6Sopenharmony_ci{ 284c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 285c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 286c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 287c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_RZ; 288c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 289c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 290c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 291c29fa5a6Sopenharmony_ci} 292c29fa5a6Sopenharmony_ci 293c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbs(InputEventArray& inputEventArray, int64_t blockTime, uint16_t code, int32_t value) 294c29fa5a6Sopenharmony_ci{ 295c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 296c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 297c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 298c29fa5a6Sopenharmony_ci injectEvent.event.code = code; 299c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 300c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 301c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 302c29fa5a6Sopenharmony_ci} 303c29fa5a6Sopenharmony_ci 304c29fa5a6Sopenharmony_civoid DeviceBase::SetRelX(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 305c29fa5a6Sopenharmony_ci{ 306c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 307c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 308c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_REL; 309c29fa5a6Sopenharmony_ci injectEvent.event.code = REL_X; 310c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 311c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 312c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 313c29fa5a6Sopenharmony_ci} 314c29fa5a6Sopenharmony_ci 315c29fa5a6Sopenharmony_civoid DeviceBase::SetRelY(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 316c29fa5a6Sopenharmony_ci{ 317c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 318c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 319c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_REL; 320c29fa5a6Sopenharmony_ci injectEvent.event.code = REL_Y; 321c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 322c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 323c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 324c29fa5a6Sopenharmony_ci} 325c29fa5a6Sopenharmony_ci 326c29fa5a6Sopenharmony_civoid DeviceBase::SetRelWheel(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 327c29fa5a6Sopenharmony_ci{ 328c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 329c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 330c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_REL; 331c29fa5a6Sopenharmony_ci injectEvent.event.code = REL_WHEEL; 332c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 333c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 334c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 335c29fa5a6Sopenharmony_ci} 336c29fa5a6Sopenharmony_ci 337c29fa5a6Sopenharmony_civoid DeviceBase::SetRelHwheel(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 338c29fa5a6Sopenharmony_ci{ 339c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 340c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 341c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_REL; 342c29fa5a6Sopenharmony_ci injectEvent.event.code = REL_HWHEEL; 343c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 344c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 345c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 346c29fa5a6Sopenharmony_ci} 347c29fa5a6Sopenharmony_ci 348c29fa5a6Sopenharmony_civoid DeviceBase::SetEvAbsWheel(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 349c29fa5a6Sopenharmony_ci{ 350c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 351c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 352c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 353c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_WHEEL; 354c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 355c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 356c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 357c29fa5a6Sopenharmony_ci} 358c29fa5a6Sopenharmony_ci 359c29fa5a6Sopenharmony_civoid DeviceBase::SetAbsMisc(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 360c29fa5a6Sopenharmony_ci{ 361c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 362c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 363c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 364c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_MISC; 365c29fa5a6Sopenharmony_ci if (value == 1) { 366c29fa5a6Sopenharmony_ci injectEvent.event.value = EV_ABS_MISC_DEFAULT_VALUE; 367c29fa5a6Sopenharmony_ci } else { 368c29fa5a6Sopenharmony_ci injectEvent.event.value = 0; 369c29fa5a6Sopenharmony_ci } 370c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 371c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 372c29fa5a6Sopenharmony_ci} 373c29fa5a6Sopenharmony_ci 374c29fa5a6Sopenharmony_civoid DeviceBase::SetAbsTiltX(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 375c29fa5a6Sopenharmony_ci{ 376c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 377c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 378c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 379c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_TILT_X; 380c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 381c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 382c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 383c29fa5a6Sopenharmony_ci} 384c29fa5a6Sopenharmony_ci 385c29fa5a6Sopenharmony_civoid DeviceBase::SetAbsTiltY(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 386c29fa5a6Sopenharmony_ci{ 387c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 388c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 389c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 390c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_TILT_Y; 391c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 392c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 393c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 394c29fa5a6Sopenharmony_ci} 395c29fa5a6Sopenharmony_ci 396c29fa5a6Sopenharmony_civoid DeviceBase::SetAbsPressure(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 397c29fa5a6Sopenharmony_ci{ 398c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 399c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 400c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 401c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_PRESSURE; 402c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 403c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 404c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 405c29fa5a6Sopenharmony_ci} 406c29fa5a6Sopenharmony_ci 407c29fa5a6Sopenharmony_civoid DeviceBase::SetAbsDistance(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 408c29fa5a6Sopenharmony_ci{ 409c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 410c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 411c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 412c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_DISTANCE; 413c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 414c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 415c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 416c29fa5a6Sopenharmony_ci} 417c29fa5a6Sopenharmony_ci 418c29fa5a6Sopenharmony_civoid DeviceBase::SetBtnPen(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 419c29fa5a6Sopenharmony_ci{ 420c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 421c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 422c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 423c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_PEN; 424c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 425c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 426c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 427c29fa5a6Sopenharmony_ci} 428c29fa5a6Sopenharmony_ci 429c29fa5a6Sopenharmony_civoid DeviceBase::SetBtnStylus(InputEventArray& inputEventArray, int64_t blockTime, uint16_t code, 430c29fa5a6Sopenharmony_ci int32_t value) 431c29fa5a6Sopenharmony_ci{ 432c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 433c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 434c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 435c29fa5a6Sopenharmony_ci injectEvent.event.code = code; 436c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 437c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 438c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 439c29fa5a6Sopenharmony_ci} 440c29fa5a6Sopenharmony_ci 441c29fa5a6Sopenharmony_civoid DeviceBase::SetBtnRubber(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 442c29fa5a6Sopenharmony_ci{ 443c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 444c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 445c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_KEY; 446c29fa5a6Sopenharmony_ci injectEvent.event.code = BTN_TOOL_RUBBER; 447c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 448c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 449c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 450c29fa5a6Sopenharmony_ci} 451c29fa5a6Sopenharmony_ci 452c29fa5a6Sopenharmony_civoid DeviceBase::SetMscSerial(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 453c29fa5a6Sopenharmony_ci{ 454c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 455c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 456c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_MSC; 457c29fa5a6Sopenharmony_ci injectEvent.event.code = MSC_SERIAL; 458c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 459c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 460c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 461c29fa5a6Sopenharmony_ci} 462c29fa5a6Sopenharmony_ci 463c29fa5a6Sopenharmony_civoid DeviceBase::SetSynMtReport(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 464c29fa5a6Sopenharmony_ci{ 465c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 466c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 467c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_SYN; 468c29fa5a6Sopenharmony_ci injectEvent.event.code = SYN_MT_REPORT; 469c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 470c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 471c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 472c29fa5a6Sopenharmony_ci} 473c29fa5a6Sopenharmony_ci 474c29fa5a6Sopenharmony_civoid DeviceBase::SetThrottle(InputEventArray& inputEventArray, int64_t blockTime, int32_t value) 475c29fa5a6Sopenharmony_ci{ 476c29fa5a6Sopenharmony_ci InjectEvent injectEvent = {}; 477c29fa5a6Sopenharmony_ci injectEvent.blockTime = blockTime; 478c29fa5a6Sopenharmony_ci injectEvent.event.type = EV_ABS; 479c29fa5a6Sopenharmony_ci injectEvent.event.code = ABS_THROTTLE; 480c29fa5a6Sopenharmony_ci injectEvent.event.value = value; 481c29fa5a6Sopenharmony_ci SetTimeToLibinputEvent(injectEvent); 482c29fa5a6Sopenharmony_ci inputEventArray.events.push_back(injectEvent); 483c29fa5a6Sopenharmony_ci} 484c29fa5a6Sopenharmony_ci} // namespace MMI 485c29fa5a6Sopenharmony_ci} // namespace OHOS