• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 I_INPUT_ADAPTER_H
17 #define I_INPUT_ADAPTER_H
18 
19 #include <functional>
20 #include <memory>
21 
22 #include "input_device.h"
23 #include "key_event.h"
24 #include "pointer_event.h"
25 
26 namespace OHOS {
27 namespace Msdp {
28 namespace DeviceStatus {
29 class IInputAdapter {
30 public:
31     IInputAdapter() = default;
32     virtual ~IInputAdapter() = default;
33 
34     virtual int32_t AddMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> callback) = 0;
35     virtual int32_t AddMonitor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> callback) = 0;
36     virtual void RemoveMonitor(int32_t monitorId) = 0;
37 
38     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointerCb) = 0;
39     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCb) = 0;
40     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointerCb,
41                                    std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCb) = 0;
42     virtual void RemoveInterceptor(int32_t interceptorId) = 0;
43 
44     virtual int32_t AddFilter(std::function<bool(std::shared_ptr<MMI::PointerEvent>)> callback) = 0;
45     virtual void RemoveFilter(int32_t filterId) = 0;
46 
47     virtual int32_t SetPointerVisibility(bool visible, int32_t priority = 0) = 0;
48     virtual int32_t SetPointerLocation(int32_t x, int32_t y) = 0;
49     virtual int32_t EnableInputDevice(bool enable) = 0;
50 
51     virtual void SimulateInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) = 0;
52     virtual void SimulateInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) = 0;
53     virtual int32_t AddVirtualInputDevice(std::shared_ptr<MMI::InputDevice> device, int32_t &deviceId) = 0;
54     virtual int32_t RemoveVirtualInputDevice(int32_t deviceId) = 0;
55 };
56 } // namespace DeviceStatus
57 } // namespace Msdp
58 } // namespace OHOS
59 #endif // I_INPUT_ADAPTER_H
60