1c29fa5a6Sopenharmony_ci/* 2c29fa5a6Sopenharmony_ci * Copyright (c) 2021-2022 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 "virtual_stylus.h" 17c29fa5a6Sopenharmony_ci 18c29fa5a6Sopenharmony_cinamespace OHOS { 19c29fa5a6Sopenharmony_cinamespace MMI { 20c29fa5a6Sopenharmony_cinamespace { 21c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_X = 31920; 22c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_Y = 19950; 23c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MIN_Z = -900; 24c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_Z = 899; 25c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_WHEEL = 2047; 26c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_PRESSURE = 8191; 27c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MIN_TILT_XY = -64; 28c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_TILT_XY_DISTANCE = 63; 29c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MIN_MISC = -2147483648; 30c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MISC = 2147483647; 31c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_FUZZ_XY = 4; 32c29fa5a6Sopenharmony_ciconstexpr int32_t STYLUS_ABS_RANGE = 200; 33c29fa5a6Sopenharmony_ci 34c29fa5a6Sopenharmony_ciAbsInfo absInfos[] = { 35c29fa5a6Sopenharmony_ci { ABS_X, 0, ABS_MAX_X, ABS_FUZZ_XY, 0 }, 36c29fa5a6Sopenharmony_ci { ABS_Y, 0, ABS_MAX_Y, ABS_FUZZ_XY, 0 }, 37c29fa5a6Sopenharmony_ci { ABS_Z, ABS_MIN_Z, ABS_MAX_Z, 0, 0 }, 38c29fa5a6Sopenharmony_ci { ABS_WHEEL, 0, ABS_MAX_WHEEL, 0, 0 }, 39c29fa5a6Sopenharmony_ci { ABS_PRESSURE, 0, ABS_MAX_PRESSURE, 0, 0 }, 40c29fa5a6Sopenharmony_ci { ABS_DISTANCE, 0, ABS_MAX_TILT_XY_DISTANCE, 0, 0 }, 41c29fa5a6Sopenharmony_ci { ABS_TILT_X, ABS_MIN_TILT_XY, ABS_MAX_TILT_XY_DISTANCE, 0, 0 }, 42c29fa5a6Sopenharmony_ci { ABS_TILT_Y, ABS_MIN_TILT_XY, ABS_MAX_TILT_XY_DISTANCE, 0, 0 }, 43c29fa5a6Sopenharmony_ci { ABS_MISC, ABS_MIN_MISC, ABS_MAX_MISC, 0, 0 } 44c29fa5a6Sopenharmony_ci}; 45c29fa5a6Sopenharmony_ci 46c29fa5a6Sopenharmony_ciResolutionInfo resolutionInfos[] = { 47c29fa5a6Sopenharmony_ci { ABS_X, STYLUS_ABS_RANGE }, 48c29fa5a6Sopenharmony_ci { ABS_Y, STYLUS_ABS_RANGE } 49c29fa5a6Sopenharmony_ci}; 50c29fa5a6Sopenharmony_ci} // namespace 51c29fa5a6Sopenharmony_ci 52c29fa5a6Sopenharmony_ciVirtualStylus::VirtualStylus() : VirtualDevice("Virtual Stylus", BUS_USB, 0x56a, 0x392) 53c29fa5a6Sopenharmony_ci{ 54c29fa5a6Sopenharmony_ci eventTypes_ = { EV_KEY, EV_ABS, EV_MSC }; 55c29fa5a6Sopenharmony_ci miscellaneous_ = { MSC_SERIAL }; 56c29fa5a6Sopenharmony_ci properties_ = { INPUT_PROP_POINTER }; 57c29fa5a6Sopenharmony_ci abs_ = { ABS_X, ABS_Y, ABS_Z, ABS_WHEEL, ABS_PRESSURE, ABS_DISTANCE, ABS_TILT_X, ABS_TILT_Y, ABS_MISC }; 58c29fa5a6Sopenharmony_ci keys_ = { 59c29fa5a6Sopenharmony_ci BTN_TOOL_PEN, BTN_TOOL_RUBBER, BTN_TOOL_BRUSH, BTN_TOOL_PENCIL, BTN_TOOL_AIRBRUSH, BTN_TOOL_MOUSE, 60c29fa5a6Sopenharmony_ci BTN_TOOL_LENS, BTN_STYLUS3, BTN_TOUCH, BTN_STYLUS, BTN_STYLUS2 61c29fa5a6Sopenharmony_ci }; 62c29fa5a6Sopenharmony_ci 63c29fa5a6Sopenharmony_ci for (const auto &item : absInfos) { 64c29fa5a6Sopenharmony_ci SetAbsValue(item); 65c29fa5a6Sopenharmony_ci } 66c29fa5a6Sopenharmony_ci 67c29fa5a6Sopenharmony_ci for (const auto &item : resolutionInfos) { 68c29fa5a6Sopenharmony_ci SetResolution(item); 69c29fa5a6Sopenharmony_ci } 70c29fa5a6Sopenharmony_ci} 71c29fa5a6Sopenharmony_ci} // namespace MMI 72c29fa5a6Sopenharmony_ci} // namespace OHOS