• 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 
30 namespace {
31 using MMIDevListener = std::function<void(int32_t, const std::string&)>;
32 }
33 class IInputAdapter {
34 public:
35     IInputAdapter() = default;
36     virtual ~IInputAdapter() = default;
37 
38     virtual int32_t AddMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> callback) = 0;
39     virtual int32_t AddMonitor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> callback) = 0;
40     virtual int32_t AddMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback,
41         std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback, MMI::HandleEventType eventType) = 0;
42     virtual void RemoveMonitor(int32_t monitorId) = 0;
43 
44     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback) = 0;
45     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback) = 0;
46     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback,
47                                    std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback) = 0;
48     virtual void RemoveInterceptor(int32_t interceptorId) = 0;
49 
50     virtual int32_t AddFilter(std::function<bool(std::shared_ptr<MMI::PointerEvent>)> callback) = 0;
51     virtual void RemoveFilter(int32_t filterId) = 0;
52 
53     virtual int32_t SetPointerVisibility(bool visible, int32_t priority = 0) = 0;
54     virtual int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId = -1) = 0;
55     virtual int32_t EnableInputDevice(bool enable) = 0;
56 
57     virtual void SimulateInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) = 0;
58     virtual void SimulateInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) = 0;
59     virtual int32_t AddVirtualInputDevice(std::shared_ptr<MMI::InputDevice> device, int32_t &deviceId) = 0;
60     virtual int32_t RemoveVirtualInputDevice(int32_t deviceId) = 0;
61     virtual int32_t GetPointerSpeed(int32_t &speed) = 0;
62     virtual int32_t SetPointerSpeed(int32_t speed) = 0;
63     virtual int32_t GetTouchPadSpeed(int32_t &speed) = 0;
64     virtual int32_t SetTouchPadSpeed(int32_t speed) = 0;
65     virtual bool HasLocalPointerDevice() = 0;
66     virtual int32_t RegisterDevListener(MMIDevListener devAddedCallback, MMIDevListener devRemovedCallback) = 0;
67     virtual int32_t UnregisterDevListener() = 0;
68     virtual int32_t AddPreMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback,
69         std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback,
70         MMI::HandleEventType eventType, std::vector<int32_t> keys) = 0;
71     virtual void RemovePreMonitor(int32_t preMonitorId) = 0;
72 };
73 } // namespace DeviceStatus
74 } // namespace Msdp
75 } // namespace OHOS
76 #endif // I_INPUT_ADAPTER_H
77