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_BINDING_INTERNAL_H
17 #define INPUT_BINDING_INTERNAL_H
18 
19 #include "input_binding.h"
20 
21 struct CPointerEvent {
22     std::shared_ptr<OHOS::MMI::PointerEvent> event;
23 
CPointerEventCPointerEvent24     CPointerEvent(std::shared_ptr<OHOS::MMI::PointerEvent> pointerEvent)
25     {
26         event = pointerEvent;
27     }
28 };
29 
30 struct CKeyEvent {
31     std::shared_ptr<OHOS::MMI::KeyEvent> event;
32 
CKeyEventCKeyEvent33     CKeyEvent(std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent)
34     {
35         event = keyEvent;
36     }
37 };
38 
39 struct CAxisEvent {
40     std::shared_ptr<OHOS::MMI::AxisEvent> event;
41 };
42 
43 struct CPointerStyle {
44     int32_t size { -1 };
45     int32_t color { 0 };
46     int32_t id { 0 };
47 };
48 
49 struct CExtraData {
50     bool appended { false };
51     uint8_t* buffer;
52     size_t bufferSize;
53     int32_t sourceType { -1 };
54     int32_t pointerId { -1 };
55 };
56 
57 class DragMonitorConsumer : public OHOS::MMI::IInputEventConsumer {
58 public:
59     explicit DragMonitorConsumer(void (*cb)(CPointerEvent *));
60 
61     void OnInputEvent(std::shared_ptr<OHOS::MMI::PointerEvent> pointerEvent) const override;
62     void OnInputEvent(std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent) const override;
63     void OnInputEvent(std::shared_ptr<OHOS::MMI::AxisEvent> axisEvent) const override;
64 
65 private:
66     void (*callback_)(CPointerEvent *);
67 };
68 
69 #endif // INPUT_BINDING_INTERNAL_H