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 INPUT_EVENT_MONITOR_H 16 #define INPUT_EVENT_MONITOR_H 17 #include <map> 18 #include <vector> 19 #include <algorithm> 20 #include "uds_session.h" 21 #include "singleton.h" 22 #include <list> 23 #include "key_event.h" 24 #include "nocopyable.h" 25 #include "pointer_event.h" 26 #include "struct_multimodal.h" 27 28 namespace OHOS { 29 namespace MMI { 30 struct MonitorItem { 31 int32_t eventType; 32 SessionPtr session = nullptr; 33 bool operator == (const MonitorItem& item) 34 { 35 return eventType == item.eventType && session == item.session; 36 } 37 }; 38 39 class InputEventMonitorManager { 40 public: 41 InputEventMonitorManager(); 42 DISALLOW_COPY_AND_MOVE(InputEventMonitorManager); 43 virtual ~InputEventMonitorManager(); 44 45 int32_t AddInputEventMontior(SessionPtr session, int32_t eventType); 46 void RemoveInputEventMontior(SessionPtr session, int32_t eventType); 47 void OnMonitorInputEvent(std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent); 48 49 int32_t AddInputEventTouchpadMontior(int32_t eventType, SessionPtr session); 50 void RemoveInputEventTouchpadMontior(int32_t eventType, SessionPtr session); 51 bool ReportTouchpadEvent(std::shared_ptr<OHOS::MMI::PointerEvent> pointerEvent); 52 53 private: 54 std::mutex mu_; 55 std::list<MonitorItem> monitors_; 56 std::list<MonitorItem> monitorsTouch_; 57 58 void OnTouchpadMonitorInputEvent(std::shared_ptr<PointerEvent> PointerEvent); 59 }; 60 } // namespace MMI 61 } // namespace OHOS 62 #define InputMonitorServiceMgr OHOS::Singleton<OHOS::MMI::InputEventMonitorManager>::GetInstance() 63 #endif // INPUT_EVENT_MONITOR_H 64