• 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 #ifndef OHOS_INPUT_DEVICE_EVENT_H
16 #define OHOS_INPUT_DEVICE_EVENT_H
17 #include <functional>
18 #include <map>
19 #include <mutex>
20 #include "nocopyable.h"
21 
22 namespace OHOS {
23 namespace MMI {
24 class InputDeviceImpl {
25 public:
26     static InputDeviceImpl& GetInstance();
27     DISALLOW_COPY_AND_MOVE(InputDeviceImpl);
28     ~InputDeviceImpl() = default;
29 
30     struct InputDeviceInfo {
InputDeviceInfoInputDeviceInfo31         InputDeviceInfo(int32_t id, std::string name, uint32_t devcieType) : id(id),
32             name(name), devcieType(devcieType) {}
33         int32_t id;
34         std::string name;
35         uint32_t devcieType;
36     };
37 
38     void GetInputDeviceIdsAsync(int32_t userData, std::function<void(int32_t, std::vector<int32_t>)> callback);
39     void GetInputDeviceAsync(int32_t userData, int32_t deviceId,
40         std::function<void(int32_t, std::shared_ptr<InputDeviceInfo>)> callback);
41     void OnInputDevice(int32_t userData, int32_t id, std::string name, int32_t deviceId);
42     void OnInputDeviceIds(int32_t userData, std::vector<int32_t> ids);
43 
44 private:
45     InputDeviceImpl() = default;
46     std::map<int32_t, std::function<void(int32_t, std::shared_ptr<InputDeviceInfo>)>> inputDevcices_;
47     std::map<int32_t, std::function<void(int32_t, std::vector<int32_t>)>> inputDevciceIds_;
48     std::mutex mtx_;
49 };
50 } // namespace MMI
51 } // namespace OHOS
52 
53 #endif // OHOS_INPUT_DEVICE_EVENT_H