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
18 namespace OHOS {
19 namespace MMI {
20 namespace {
21 constexpr int32_t ABS_MAX_WHEEL = 71;
22 constexpr int32_t ABS_RANGE = 200;
23
24 AbsInfo absInfos[] = {
25 { ABS_X, 0, 1, 0, 0 },
26 { ABS_Y, 0, 1, 0, 0 },
27 { ABS_WHEEL, 0, ABS_MAX_WHEEL, 0, 0 },
28 { ABS_MISC, 0, 0, 0, 0 },
29 };
30
31 ResolutionInfo resolutionInfos[] = {
32 { ABS_X, ABS_RANGE },
33 { ABS_Y, ABS_RANGE }
34 };
35 } // namespace
36
VirtualTouchpad()37 VirtualTouchpad::VirtualTouchpad() : VirtualDevice("Virtual Touchpad", BUS_USB, 0x56a, 0x392)
38 {
39 eventTypes_ = { EV_KEY, EV_ABS };
40 abs_ = { ABS_X, ABS_Y, ABS_WHEEL, ABS_MISC };
41 keys_ = { BTN_0, BTN_1, BTN_2, BTN_3, BTN_4, BTN_5, BTN_6, BTN_STYLUS, BTN_TOOL_PEN };
42
43 for (const auto &item : absInfos) {
44 SetAbsValue(item);
45 }
46
47 for (const auto &item : resolutionInfos) {
48 SetResolution(item);
49 }
50 }
51 } // namespace MMI
52 } // namespace OHOS