• 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 #ifndef INPUT_DEVICE_H
17 #define INPUT_DEVICE_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "nocopyable.h"
23 
24 namespace OHOS {
25 namespace MMI {
26 class InputDevice {
27 public:
28     InputDevice() = default;
29     DISALLOW_COPY_AND_MOVE(InputDevice);
30     ~InputDevice() = default;
31 
32     void SetId(int32_t deviceId);
33     int32_t GetId() const;
34     void SetName(std::string name);
35     std::string GetName() const;
36     void SetType(int32_t deviceType);
37     int32_t GetType() const;
38     void SetBus(int32_t bus);
39     int32_t GetBus() const;
40     void SetVersion(int32_t version);
41     int32_t GetVersion() const;
42     void SetProduct(int32_t product);
43     int32_t GetProduct() const;
44     void SetVendor(int32_t vendor);
45     int32_t GetVendor() const;
46     void SetPhys(std::string phys);
47     std::string GetPhys() const;
48     void SetUniq(std::string uniq);
49     std::string GetUniq() const;
50 
51     class AxisInfo {
52     public:
53         AxisInfo() = default;
54         AxisInfo(int32_t type, int32_t min, int32_t max, int32_t fuzz, int32_t flat, int32_t resolution);
55         ~AxisInfo() = default;
56         void SetAxisType(int32_t type);
57         int32_t GetAxisType() const;
58         void SetMinimum(int32_t min);
59         int32_t GetMinimum() const;
60         void SetMaximum(int32_t max);
61         int32_t GetMaximum() const;
62         void SetFuzz(int32_t fuzz);
63         int32_t GetFuzz() const;
64         void SetFlat(int32_t flat);
65         int32_t GetFlat() const;
66         void SetResolution(int32_t resolution);
67         int32_t GetResolution() const;
68 
69     private:
70         int32_t axisType_ { 0 };
71         int32_t minimum_ { 0 };
72         int32_t maximum_ { 0 };
73         int32_t fuzz_ { 0 };
74         int32_t flat_ { 0 };
75         int32_t resolution_ { 0 };
76     };
77     void AddAxisInfo(AxisInfo axis);
78     std::vector<AxisInfo> GetAxisInfo();
79     InputDevice(int32_t id, std::string name, int32_t deviceType, int32_t bus, int32_t version, int32_t product,
80                 int32_t vendor, std::string phys, std::string uniq, std::vector<AxisInfo> axis);
81 private:
82     int32_t id_ { -1 };
83     std::string name_ { "null" };
84     int32_t type_ { 0 };
85     int32_t bus_ { -1 };
86     int32_t version_ { -1 };
87     int32_t product_ { -1 };
88     int32_t vendor_ { -1 };
89     std::string phys_ { "null" };
90     std::string uniq_ { "null" };
91     std::vector<AxisInfo> axis_;
92     std::vector<int32_t> deviceIdList_;
93 };
94 } // namespace MMI
95 } // namespace OHOS
96 #endif // INPUT_DEVICE_H