• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "virtual_touchscreen.h"
17 
VirtualTouchScreen()18 OHOS::MMI::VirtualTouchScreen::VirtualTouchScreen()
19     : VirtualDevice("Virtual TouchScreen", BUS_USB, 0x6006, 0x6006)
20 {
21     constexpr int32_t ABS_MAX_X = 480;
22     constexpr int32_t ABS_MAX_Y = 960;
23     constexpr int32_t ABS_PRESSURE_MAX = 100;
24     constexpr int32_t ABS_MT_ORIENTATION_MIN = -90;
25     constexpr int32_t ABS_MT_ORIENTATION_MAX = 90;
26     constexpr int32_t ABS_MT_BLOB_ID_MAX = 10;
27     constexpr int32_t ABS_MT_TRACKING_ID_MAX = 9;
28 
29     dev_.absmin[ABS_X] = 0;
30     dev_.absmax[ABS_X] = ABS_MAX_X;
31     dev_.absmin[ABS_Y] = 0;
32     dev_.absmax[ABS_Y] = ABS_MAX_Y;
33 
34     dev_.absmin[ABS_PRESSURE] = 0;
35     dev_.absmax[ABS_PRESSURE] = ABS_PRESSURE_MAX;
36 
37     dev_.absmin[ABS_MT_TOUCH_MAJOR] = 0;
38     dev_.absmax[ABS_MT_TOUCH_MAJOR] = 1;
39     dev_.absmin[ABS_MT_TOUCH_MINOR] = 0;
40     dev_.absmax[ABS_MT_TOUCH_MINOR] = 1;
41 
42     dev_.absmin[ABS_MT_ORIENTATION] = ABS_MT_ORIENTATION_MIN;
43     dev_.absmax[ABS_MT_ORIENTATION] = ABS_MT_ORIENTATION_MAX;
44 
45     dev_.absmin[ABS_MT_POSITION_X] = 0;
46     dev_.absmax[ABS_MT_POSITION_X] = ABS_MAX_X;
47     dev_.absmin[ABS_MT_POSITION_Y] = 0;
48     dev_.absmax[ABS_MT_POSITION_Y] = ABS_MAX_Y;
49 
50     dev_.absmin[ABS_MT_BLOB_ID] = 0;
51     dev_.absmax[ABS_MT_BLOB_ID] = ABS_MT_BLOB_ID_MAX;
52     dev_.absmin[ABS_MT_TRACKING_ID] = 0;
53     dev_.absmax[ABS_MT_TRACKING_ID] = ABS_MT_TRACKING_ID_MAX;
54     dev_.absmin[ABS_MT_PRESSURE] = 0;
55     dev_.absmax[ABS_MT_PRESSURE] = ABS_PRESSURE_MAX;
56 }
57 
~VirtualTouchScreen()58 OHOS::MMI::VirtualTouchScreen::~VirtualTouchScreen() {}
59 
GetEventTypes() const60 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchScreen::GetEventTypes() const
61 {
62     static const std::vector<uint32_t> evTypes {
63         EV_ABS, EV_KEY
64     };
65     return evTypes;
66 }
67 
GetKeys() const68 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchScreen::GetKeys() const
69 {
70     static const std::vector<uint32_t> keys {
71         BTN_TOUCH
72     };
73     return keys;
74 }
75 
GetProperties() const76 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchScreen::GetProperties() const
77 {
78     static const std::vector<uint32_t> properties {
79         INPUT_PROP_DIRECT
80     };
81     return properties;
82 }
83 
GetAbs() const84 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchScreen::GetAbs() const
85 {
86     static const std::vector<uint32_t> abs {
87         ABS_X, ABS_Y, ABS_PRESSURE, ABS_MT_TOUCH_MAJOR, ABS_MT_TOUCH_MINOR, ABS_MT_ORIENTATION, ABS_MT_POSITION_X,
88         ABS_MT_POSITION_Y, ABS_MT_BLOB_ID, ABS_MT_TRACKING_ID, ABS_MT_PRESSURE
89     };
90     return abs;
91 }
92