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_knob_consumer_ctrl.h"
17
VirtualKnobConsumerCtrl()18 OHOS::MMI::VirtualKnobConsumerCtrl::VirtualKnobConsumerCtrl() : VirtualDevice("Virtual KnobConsumerCtrl",
19 BUS_USB, 0x5ac, 0x202)
20 {
21 constexpr int32_t ABS_MAX_VOLUME = 572;
22
23 dev_.absmin[ABS_VOLUME] = 0;
24 dev_.absmax[ABS_VOLUME] = ABS_MAX_VOLUME;
25 dev_.absfuzz[ABS_VOLUME] = 0;
26 dev_.absflat[ABS_VOLUME] = 0;
27 }
28
~VirtualKnobConsumerCtrl()29 OHOS::MMI::VirtualKnobConsumerCtrl::~VirtualKnobConsumerCtrl() {}
30
31 static std::vector<uint32_t> g_virtualKey = {
32 1, 28, 74, 78, 103, 105, 106, 108, 113, 114, 115, 116, 119, 128, 130, 131, 133, 134, 135, 136, 137, 138, 139, 140,
33 142, 144, 150, 152, 155, 156, 158, 159, 161, 163, 164, 165, 166, 167, 168, 169, 171, 172, 173, 174, 177, 178, 181,
34 206, 207, 208, 209, 210, 212, 216, 217, 219, 224, 225, 228, 229, 230, 234, 235, 240, 241, 244, 256, 353, 354, 358,
35 362, 366, 370, 372, 374, 375, 376, 377, 378, 379, 380, 381, 383, 384, 386, 387, 389, 392, 393, 396, 397, 398, 399,
36 400, 401, 402, 403, 405, 407, 408, 409, 410, 412, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428,
37 429, 430, 431, 432, 433, 439, 442, 576, 577, 578, 579, 580, 581, 582, 583, 592, 593
38 };
39
GetEventTypes() const40 const std::vector<uint32_t>& OHOS::MMI::VirtualKnobConsumerCtrl::GetEventTypes() const
41 {
42 static const std::vector<uint32_t> evt_types {
43 EV_KEY, EV_REL, EV_ABS, EV_MSC
44 };
45 return evt_types;
46 }
47
GetKeys() const48 const std::vector<uint32_t>& OHOS::MMI::VirtualKnobConsumerCtrl::GetKeys() const
49 {
50 static const std::vector<uint32_t> keys(g_virtualKey.begin(),
51 g_virtualKey.end());
52
53 return keys;
54 }
55
GetRelBits() const56 const std::vector<uint32_t>& OHOS::MMI::VirtualKnobConsumerCtrl::GetRelBits() const
57 {
58 static const std::vector<uint32_t> rels {
59 REL_HWHEEL, REL_HWHEEL_HI_RES
60 };
61
62 return rels;
63 }
64
GetAbs() const65 const std::vector<uint32_t>& OHOS::MMI::VirtualKnobConsumerCtrl::GetAbs() const
66 {
67 static const std::vector<uint32_t> abs {
68 ABS_VOLUME
69 };
70
71 return abs;
72 }
73
GetMscs() const74 const std::vector<uint32_t>& OHOS::MMI::VirtualKnobConsumerCtrl::GetMscs() const
75 {
76 static const std::vector<uint32_t> mscs {
77 MSC_SCAN
78 };
79 return mscs;
80 }
81