1 /*
2 * Copyright (c) 2024 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 "oh_input_device_listener.h"
17
18 #include "define_multimodal.h"
19 #include "error_multimodal.h"
20 #include "input_manager.h"
21 #include "input_manager_impl.h"
22 #include "mmi_log.h"
23
24 #undef MMI_LOG_TAG
25 #define MMI_LOG_TAG "OHInputDeviceListener"
26
27 namespace OHOS {
28 namespace MMI {
OHInputDeviceListener()29 OHInputDeviceListener::OHInputDeviceListener() {}
30
~OHInputDeviceListener()31 OHInputDeviceListener::~OHInputDeviceListener() {}
32
OnDeviceAdded(int32_t deviceId,const std::string & type)33 void OHInputDeviceListener::OnDeviceAdded(int32_t deviceId, const std::string &type)
34 {
35 if (addCallbacks_ != nullptr) {
36 addCallbacks_(deviceId, type);
37 }
38 }
39
OnDeviceRemoved(int32_t deviceId,const std::string & type)40 void OHInputDeviceListener::OnDeviceRemoved(int32_t deviceId, const std::string &type)
41 {
42 if (removeCallbacks_!= nullptr) {
43 removeCallbacks_(deviceId, type);
44 }
45 }
46
SetDeviceAddedCallback(const std::function<void (int32_t deviceId,const std::string & type)> & callback)47 void OHInputDeviceListener::SetDeviceAddedCallback(
48 const std::function<void(int32_t deviceId, const std::string &type)> &callback)
49 {
50 addCallbacks_ = callback;
51 }
52
SetDeviceRemovedCallback(const std::function<void (int32_t deviceId,const std::string & type)> & callback)53 void OHInputDeviceListener::SetDeviceRemovedCallback(
54 const std::function<void(int32_t deviceId, const std::string &type)> &callback)
55 {
56 removeCallbacks_ = callback;
57 }
58 }
59 }