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_finger.h"
17c29fa5a6Sopenharmony_ci
18c29fa5a6Sopenharmony_cinamespace OHOS {
19c29fa5a6Sopenharmony_cinamespace MMI {
20c29fa5a6Sopenharmony_cinamespace {
21c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_X = 6400;
22c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_Y = 4000;
23c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MT_SLOT = 9;
24c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MT_TOUCH_MAJOR = 21;
25c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MT_TOUCH_MINOR = 21;
26c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MT_TRACKING_ID = 65535;
27c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MT_PRESSURE = 8191;
28c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_TOOL_TYPE_MAX = 15;
29c29fa5a6Sopenharmony_ciconstexpr int32_t ABS_MAX_MT_ORIENTATION = 1;
30c29fa5a6Sopenharmony_ciconstexpr int32_t FINGER_ABS_RANGE = 40;
31c29fa5a6Sopenharmony_ci
32c29fa5a6Sopenharmony_ciResolutionInfo resolutionInfos[] = {
33c29fa5a6Sopenharmony_ci    { ABS_X, FINGER_ABS_RANGE },
34c29fa5a6Sopenharmony_ci    { ABS_Y, FINGER_ABS_RANGE },
35c29fa5a6Sopenharmony_ci    { ABS_MT_POSITION_X, FINGER_ABS_RANGE },
36c29fa5a6Sopenharmony_ci    { ABS_MT_POSITION_Y, FINGER_ABS_RANGE },
37c29fa5a6Sopenharmony_ci    { ABS_MT_TOOL_X, FINGER_ABS_RANGE },
38c29fa5a6Sopenharmony_ci    { ABS_MT_TOOL_Y, FINGER_ABS_RANGE },
39c29fa5a6Sopenharmony_ci};
40c29fa5a6Sopenharmony_ci
41c29fa5a6Sopenharmony_ciAbsInfo absInfos[] = {
42c29fa5a6Sopenharmony_ci    { ABS_X, 0, ABS_MAX_X, 0, 0 },
43c29fa5a6Sopenharmony_ci    { ABS_Y, 0, ABS_MAX_Y, 0, 0 },
44c29fa5a6Sopenharmony_ci    { ABS_MT_SLOT, 0, ABS_MAX_MT_SLOT, 0, 0 },
45c29fa5a6Sopenharmony_ci    { ABS_MT_TOUCH_MAJOR, 0, ABS_MAX_MT_TOUCH_MAJOR, 0, 0 },
46c29fa5a6Sopenharmony_ci    { ABS_MT_TOUCH_MINOR, 0, ABS_MAX_MT_TOUCH_MINOR, 0, 0 },
47c29fa5a6Sopenharmony_ci    { ABS_MT_ORIENTATION, 0, ABS_MAX_MT_ORIENTATION, 0, 0 },
48c29fa5a6Sopenharmony_ci    { ABS_MT_POSITION_X, 0, ABS_MAX_X, 0, 0 },
49c29fa5a6Sopenharmony_ci    { ABS_MT_POSITION_Y, 0, ABS_MAX_Y, 0, 0 },
50c29fa5a6Sopenharmony_ci    { ABS_MT_TRACKING_ID, 0, ABS_MAX_MT_TRACKING_ID, 0, 0 },
51c29fa5a6Sopenharmony_ci    { ABS_MT_PRESSURE, 0, ABS_MAX_MT_PRESSURE, 0, 0 },
52c29fa5a6Sopenharmony_ci    { ABS_MT_TOOL_TYPE, 0, ABS_TOOL_TYPE_MAX, 0, 0 },
53c29fa5a6Sopenharmony_ci    { ABS_MT_TOOL_X, 0, ABS_MAX_X, 0, 0 },
54c29fa5a6Sopenharmony_ci    { ABS_MT_TOOL_Y, 0, ABS_MAX_Y, 0, 0 },
55c29fa5a6Sopenharmony_ci    { ABS_MT_WIDTH_MAJOR, 0, ABS_MAX_X, 0, 0 },
56c29fa5a6Sopenharmony_ci    { ABS_MT_WIDTH_MINOR, 0, ABS_MAX_Y, 0, 0 }
57c29fa5a6Sopenharmony_ci};
58c29fa5a6Sopenharmony_ci} // namespace
59c29fa5a6Sopenharmony_ci
60c29fa5a6Sopenharmony_ciVirtualFinger::VirtualFinger() : VirtualDevice("Virtual Finger", BUS_USB, 0x56a, 0x392)
61c29fa5a6Sopenharmony_ci{
62c29fa5a6Sopenharmony_ci    eventTypes_ = { EV_KEY, EV_ABS, EV_SW };
63c29fa5a6Sopenharmony_ci    properties_ = { INPUT_PROP_POINTER };
64c29fa5a6Sopenharmony_ci    switches_ = { SW_MUTE_DEVICE };
65c29fa5a6Sopenharmony_ci    keys_ = {
66c29fa5a6Sopenharmony_ci        BTN_TOOL_FINGER, BTN_TOOL_QUINTTAP, BTN_TOUCH, BTN_TOOL_DOUBLETAP, BTN_TOOL_TRIPLETAP,
67c29fa5a6Sopenharmony_ci        BTN_TOOL_QUADTAP, BTN_TOOL_RUBBER, BTN_TOOL_BRUSH, BTN_TOOL_PENCIL, BTN_TOOL_AIRBRUSH,
68c29fa5a6Sopenharmony_ci        BTN_TOOL_FINGER, BTN_TOOL_MOUSE, BTN_TOOL_LENS
69c29fa5a6Sopenharmony_ci    };
70c29fa5a6Sopenharmony_ci    abs_ = {
71c29fa5a6Sopenharmony_ci        ABS_X, ABS_Y, ABS_MT_SLOT, ABS_MT_TOUCH_MAJOR, ABS_MT_TOUCH_MINOR, ABS_MT_ORIENTATION,
72c29fa5a6Sopenharmony_ci        ABS_MT_POSITION_X, ABS_MT_POSITION_Y, ABS_MT_TRACKING_ID, ABS_MT_PRESSURE, ABS_MT_TOOL_TYPE,
73c29fa5a6Sopenharmony_ci        ABS_MT_TOOL_X, ABS_MT_TOOL_Y, ABS_MT_WIDTH_MAJOR, ABS_MT_WIDTH_MINOR
74c29fa5a6Sopenharmony_ci    };
75c29fa5a6Sopenharmony_ci
76c29fa5a6Sopenharmony_ci    for (const auto &item : absInfos) {
77c29fa5a6Sopenharmony_ci        SetAbsValue(item);
78c29fa5a6Sopenharmony_ci    }
79c29fa5a6Sopenharmony_ci
80c29fa5a6Sopenharmony_ci    for (const auto &item : resolutionInfos) {
81c29fa5a6Sopenharmony_ci        SetResolution(item);
82c29fa5a6Sopenharmony_ci    }
83c29fa5a6Sopenharmony_ci}
84c29fa5a6Sopenharmony_ci} // namespace MMI
85c29fa5a6Sopenharmony_ci} // namespace OHOS