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_touchpad.h"
17
VirtualTouchpad()18 OHOS::MMI::VirtualTouchpad::VirtualTouchpad() : VirtualDevice("Virtual Touchpad",
19 BUS_USB, 0x56a, 0x392)
20 {
21 constexpr int32_t ABS_MAX_WHEEL = 71;
22
23 dev_.absmin[ABS_X] = 0;
24 dev_.absmax[ABS_X] = 1;
25 dev_.absfuzz[ABS_X] = 0;
26 dev_.absflat[ABS_X] = 0;
27
28 dev_.absmin[ABS_Y] = 0;
29 dev_.absmax[ABS_Y] = 1;
30 dev_.absfuzz[ABS_Y] = 0;
31 dev_.absflat[ABS_Y] = 0;
32
33 dev_.absmin[ABS_WHEEL] = 0;
34 dev_.absmax[ABS_WHEEL] = ABS_MAX_WHEEL;
35 dev_.absfuzz[ABS_WHEEL] = 0;
36 dev_.absflat[ABS_WHEEL] = 0;
37
38 dev_.absmin[ABS_MISC] = 0;
39 dev_.absmax[ABS_MISC] = 0;
40 dev_.absfuzz[ABS_MISC] = 0;
41 dev_.absflat[ABS_MISC] = 0;
42 }
43
GetEventTypes() const44 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchpad::GetEventTypes() const
45 {
46 static const std::vector<uint32_t> evt_types {
47 EV_KEY, EV_ABS
48 };
49 return evt_types;
50 }
51
~VirtualTouchpad()52 OHOS::MMI::VirtualTouchpad::~VirtualTouchpad() {}
53
GetKeys() const54 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchpad::GetKeys() const
55 {
56 static const std::vector<uint32_t> keys {
57 BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_STYLUS, BTN_TOOL_PEN
58 };
59 return keys;
60 }
61
GetAbs() const62 const std::vector<uint32_t>& OHOS::MMI::VirtualTouchpad::GetAbs() const
63 {
64 static const std::vector<uint32_t> abs {
65 ABS_X, ABS_Y, ABS_WHEEL, ABS_MISC
66 };
67 return abs;
68 }