1 /* 2 * Copyright (c) 2025 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_CONSUMER_H 17 #define INPUT_DEVICE_CONSUMER_H 18 19 #include <map> 20 #include <mutex> 21 #include "nocopyable.h" 22 #include <singleton.h> 23 24 #include "input_device.h" 25 #include "i_input_event_consumer.h" 26 27 namespace OHOS { 28 namespace MMI { 29 class InputDeviceConsumer { 30 public: 31 DECLARE_SINGLETON(InputDeviceConsumer); 32 33 public: 34 DISALLOW_MOVE(InputDeviceConsumer); 35 int32_t SetInputDeviceConsumer(const std::vector<std::string>& deviceNames, 36 std::shared_ptr<IInputEventConsumer> consumer); 37 void OnConnected(); 38 39 std::shared_ptr<IInputEventConsumer> deviceConsumer_ { nullptr }; 40 std::vector<std::string> deviceNames_; 41 std::mutex mtx_; 42 }; 43 #define DEVICE_CONSUMER ::OHOS::Singleton<InputDeviceConsumer>::GetInstance() 44 } // namespace MMI 45 } // namespace OHOS 46 #endif // INPUT_DEVICE_CONSUMER_H 47