• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2024 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_touch_screen.h"
17 
18 namespace OHOS {
19 namespace MMI {
20 namespace {
21 constexpr int32_t ABS_MAX_PRESSURE = 100;
22 constexpr int32_t ABS_MT_MIN_ORIENTATION = -90;
23 constexpr int32_t ABS_MT_MAX_ORIENTATION = 90;
24 constexpr int32_t ABS_MT_BLOB_MAX_ID = 10;
25 constexpr int32_t ABS_MT_TRACKING_MAX_ID = 9;
26 constexpr int32_t ABS_MT_MAX_PRESSURE = 100;
27 } // namespace
28 
GetEventTypes() const29 const std::vector<uint32_t> &VirtualTouchScreen::GetEventTypes() const
30 {
31     static const std::vector<uint32_t> evtTypes {EV_ABS, EV_KEY, EV_SYN};
32     return evtTypes;
33 }
34 
GetKeys() const35 const std::vector<uint32_t> &VirtualTouchScreen::GetKeys() const
36 {
37     static const std::vector<uint32_t> keys {BTN_TOUCH};
38     return keys;
39 }
40 
GetProperties() const41 const std::vector<uint32_t> &VirtualTouchScreen::GetProperties() const
42 {
43     static const std::vector<uint32_t> properties {INPUT_PROP_DIRECT};
44     return properties;
45 }
46 
GetAbs() const47 const std::vector<uint32_t> &VirtualTouchScreen::GetAbs() const
48 {
49     static const std::vector<uint32_t> abs {
50         ABS_X,
51         ABS_Y,
52         ABS_PRESSURE,
53         ABS_MT_TOUCH_MAJOR,
54         ABS_MT_TOUCH_MINOR,
55         ABS_MT_ORIENTATION,
56         ABS_MT_POSITION_X,
57         ABS_MT_POSITION_Y,
58         ABS_MT_BLOB_ID,
59         ABS_MT_TRACKING_ID,
60         ABS_MT_PRESSURE
61         };
62     return abs;
63 }
64 
VirtualTouchScreen(const uint32_t maxX,const uint32_t maxY)65 VirtualTouchScreen::VirtualTouchScreen(const uint32_t maxX, const uint32_t maxY)
66     : VirtualDevice("VSoC touchscreen", 0x6006)
67 {
68     dev_.absmin[ABS_X] = 0;
69     dev_.absmax[ABS_X] = maxX;
70     dev_.absmin[ABS_Y] = 0;
71     dev_.absmax[ABS_Y] = maxY;
72 
73     dev_.absmin[ABS_PRESSURE] = 0;
74     dev_.absmax[ABS_PRESSURE] = ABS_MAX_PRESSURE;
75 
76     dev_.absmin[ABS_MT_TOUCH_MAJOR] = 0;
77     dev_.absmax[ABS_MT_TOUCH_MAJOR] = 1;
78     dev_.absmin[ABS_MT_TOUCH_MINOR] = 0;
79     dev_.absmax[ABS_MT_TOUCH_MINOR] = 1;
80 
81     dev_.absmin[ABS_MT_ORIENTATION] = ABS_MT_MIN_ORIENTATION;
82     dev_.absmax[ABS_MT_ORIENTATION] = ABS_MT_MAX_ORIENTATION;
83 
84     dev_.absmin[ABS_MT_POSITION_X] = 0;
85     dev_.absmax[ABS_MT_POSITION_X] = maxX;
86     dev_.absmin[ABS_MT_POSITION_Y] = 0;
87     dev_.absmax[ABS_MT_POSITION_Y] = maxY;
88 
89     dev_.absmin[ABS_MT_BLOB_ID] = 0;
90     dev_.absmax[ABS_MT_BLOB_ID] = ABS_MT_BLOB_MAX_ID;
91     dev_.absmin[ABS_MT_TRACKING_ID] = 0;
92     dev_.absmax[ABS_MT_TRACKING_ID] = ABS_MT_TRACKING_MAX_ID;
93     dev_.absmin[ABS_MT_PRESSURE] = 0;
94     dev_.absmax[ABS_MT_PRESSURE] = ABS_MT_MAX_PRESSURE;
95 }
96 } // namespace MMI
97 } // namespace OHOS
98