1 /* 2 * Copyright (c) 2023 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_EVENT_INTERCEPTOR_H 17 #define INPUT_EVENT_INTERCEPTOR_H 18 19 #include "nocopyable.h" 20 21 #include "channel.h" 22 #include "cooperate_events.h" 23 #include "i_context.h" 24 25 namespace OHOS { 26 namespace Msdp { 27 namespace DeviceStatus { 28 namespace Cooperate { 29 class Context; 30 31 class InputEventInterceptor final { 32 public: InputEventInterceptor(IContext * env)33 InputEventInterceptor(IContext *env) : env_(env) { } 34 ~InputEventInterceptor(); 35 DISALLOW_COPY_AND_MOVE(InputEventInterceptor); 36 37 void Enable(Context &context); 38 void Disable(); 39 void Update(Context &context); 40 41 private: 42 void OnPointerEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent); 43 void OnKeyEvent(std::shared_ptr<MMI::KeyEvent> keyEvent); 44 void ReportPointerEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent); 45 46 IContext *env_ { nullptr }; 47 int32_t interceptorId_ { -1 }; 48 std::string remoteNetworkId_; 49 Channel<CooperateEvent>::Sender sender_; 50 static std::set<int32_t> filterKeys_; 51 static std::set<int32_t> filterPointers_; 52 }; 53 } // namespace Cooperate 54 } // namespace DeviceStatus 55 } // namespace Msdp 56 } // namespace OHOS 57 #endif // INPUT_EVENT_INTERCEPTOR_H 58