1f857971dSopenharmony_ci/* 2f857971dSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd. 3f857971dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4f857971dSopenharmony_ci * you may not use this file except in compliance with the License. 5f857971dSopenharmony_ci * You may obtain a copy of the License at 6f857971dSopenharmony_ci * 7f857971dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8f857971dSopenharmony_ci * 9f857971dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10f857971dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11f857971dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12f857971dSopenharmony_ci * See the License for the specific language governing permissions and 13f857971dSopenharmony_ci * limitations under the License. 14f857971dSopenharmony_ci */ 15f857971dSopenharmony_ci 16f857971dSopenharmony_ci#ifndef VIRTUAL_TOUCHSCREEN_BUILDER_H 17f857971dSopenharmony_ci#define VIRTUAL_TOUCHSCREEN_BUILDER_H 18f857971dSopenharmony_ci 19f857971dSopenharmony_ci#include <memory> 20f857971dSopenharmony_ci 21f857971dSopenharmony_ci#include <nlohmann/json.hpp> 22f857971dSopenharmony_ci 23f857971dSopenharmony_ci#include "virtual_device_builder.h" 24f857971dSopenharmony_ci 25f857971dSopenharmony_cinamespace OHOS { 26f857971dSopenharmony_cinamespace Msdp { 27f857971dSopenharmony_cinamespace DeviceStatus { 28f857971dSopenharmony_ciclass VirtualTouchScreenBuilder final : public VirtualDeviceBuilder { 29f857971dSopenharmony_cipublic: 30f857971dSopenharmony_ci VirtualTouchScreenBuilder(); 31f857971dSopenharmony_ci ~VirtualTouchScreenBuilder() = default; 32f857971dSopenharmony_ci DISALLOW_COPY_AND_MOVE(VirtualTouchScreenBuilder); 33f857971dSopenharmony_ci 34f857971dSopenharmony_ci static std::string GetDeviceName(); 35f857971dSopenharmony_ci static void ShowUsage(); 36f857971dSopenharmony_ci static void Mount(); 37f857971dSopenharmony_ci static void Unmount(); 38f857971dSopenharmony_ci static void Clone(); 39f857971dSopenharmony_ci static void Monitor(); 40f857971dSopenharmony_ci static void Act(int32_t argc, char *argv[]); 41f857971dSopenharmony_ci 42f857971dSopenharmony_ciprivate: 43f857971dSopenharmony_ci static void ReadDownAction(int32_t argc, char *argv[]); 44f857971dSopenharmony_ci static void ReadMoveAction(int32_t argc, char *argv[]); 45f857971dSopenharmony_ci static void ReadUpAction(); 46f857971dSopenharmony_ci static void ReadMoveToAction(int32_t argc, char *argv[]); 47f857971dSopenharmony_ci static void ReadDragToAction(int32_t argc, char *argv[]); 48f857971dSopenharmony_ci static void ReadActions(const char *path); 49f857971dSopenharmony_ci static void ReadModel(const nlohmann::json &model, int32_t level); 50f857971dSopenharmony_ci static void ReadAction(const nlohmann::json &model); 51f857971dSopenharmony_ci static void HandleDown(const nlohmann::json &model); 52f857971dSopenharmony_ci static void HandleMove(const nlohmann::json &model); 53f857971dSopenharmony_ci static void HandleUp(const nlohmann::json &model); 54f857971dSopenharmony_ci static void HandleMoveTo(const nlohmann::json &model); 55f857971dSopenharmony_ci static void HandleWait(const nlohmann::json &model); 56f857971dSopenharmony_ci static void ReadRawInput(const char *path); 57f857971dSopenharmony_ci static void ReadRawModel(const nlohmann::json &model, int32_t level); 58f857971dSopenharmony_ci static void ReadRawData(const nlohmann::json &model); 59f857971dSopenharmony_ci static int32_t GetModelValue(const nlohmann::json &model, const std::string &targetName, int32_t defaultValue); 60f857971dSopenharmony_ci using InterfaceParameterLess = void(*)(); 61f857971dSopenharmony_ci using InterfaceParameterOne = void(*)(const char*); 62f857971dSopenharmony_ci using InterfaceParameterTwo = void(*)(int32_t, char**); 63f857971dSopenharmony_ci inline static std::map<const char, InterfaceParameterLess> ruleTscrnActions_ { 64f857971dSopenharmony_ci { 'u', &ReadUpAction } 65f857971dSopenharmony_ci }; 66f857971dSopenharmony_ci inline static std::map<const char, InterfaceParameterOne> readTscrnActions_ { 67f857971dSopenharmony_ci { 'f', &ReadActions }, { 'r', &ReadRawInput} 68f857971dSopenharmony_ci }; 69f857971dSopenharmony_ci inline static std::map<const char, InterfaceParameterTwo> moveTscrnActions_ { 70f857971dSopenharmony_ci { 'd', &ReadDownAction }, { 'm', &ReadMoveAction }, 71f857971dSopenharmony_ci { 'D', &ReadDragToAction }, { 'M', &ReadMoveToAction } 72f857971dSopenharmony_ci }; 73f857971dSopenharmony_ci}; 74f857971dSopenharmony_ci} // namespace DeviceStatus 75f857971dSopenharmony_ci} // namespace Msdp 76f857971dSopenharmony_ci} // namespace OHOS 77f857971dSopenharmony_ci#endif // VIRTUAL_TOUCHSCREEN_BUILDER_H