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