• 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 int32_t AddMonitor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback,
37         std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback, MMI::HandleEventType eventType) = 0;
38     virtual void RemoveMonitor(int32_t monitorId) = 0;
39 
40     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback) = 0;
41     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback) = 0;
42     virtual int32_t AddInterceptor(std::function<void(std::shared_ptr<MMI::PointerEvent>)> pointCallback,
43                                    std::function<void(std::shared_ptr<MMI::KeyEvent>)> keyCallback) = 0;
44     virtual void RemoveInterceptor(int32_t interceptorId) = 0;
45 
46     virtual int32_t AddFilter(std::function<bool(std::shared_ptr<MMI::PointerEvent>)> callback) = 0;
47     virtual void RemoveFilter(int32_t filterId) = 0;
48 
49     virtual int32_t SetPointerVisibility(bool visible, int32_t priority = 0) = 0;
50     virtual int32_t SetPointerLocation(int32_t x, int32_t y, int32_t displayId = -1) = 0;
51     virtual int32_t EnableInputDevice(bool enable) = 0;
52 
53     virtual void SimulateInputEvent(std::shared_ptr<MMI::PointerEvent> pointerEvent) = 0;
54     virtual void SimulateInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) = 0;
55     virtual int32_t AddVirtualInputDevice(std::shared_ptr<MMI::InputDevice> device, int32_t &deviceId) = 0;
56     virtual int32_t RemoveVirtualInputDevice(int32_t deviceId) = 0;
57     virtual int32_t GetPointerSpeed(int32_t &speed) = 0;
58     virtual int32_t SetPointerSpeed(int32_t speed) = 0;
59     virtual int32_t GetTouchPadSpeed(int32_t &speed) = 0;
60     virtual int32_t SetTouchPadSpeed(int32_t speed) = 0;
61     virtual bool HasLocalPointerDevice() = 0;
62 };
63 } // namespace DeviceStatus
64 } // namespace Msdp
65 } // namespace OHOS
66 #endif // I_INPUT_ADAPTER_H
67