• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 EVENT_NORMALIZE_HANDLER_H
17 #define EVENT_NORMALIZE_HANDLER_H
18 
19 #include <memory>
20 
21 #include "i_input_event_handler.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 class EventNormalizeHandler : public IInputEventHandler {
26 public:
27     EventNormalizeHandler() = default;
28     ~EventNormalizeHandler() = default;
29     void HandleEvent(libinput_event* event);
30 #ifdef OHOS_BUILD_ENABLE_KEYBOARD
31     void HandleKeyEvent(const std::shared_ptr<KeyEvent> keyEvent) override;
32 #endif // OHOS_BUILD_ENABLE_KEYBOARD
33 #ifdef OHOS_BUILD_ENABLE_POINTER
34     void HandlePointerEvent(const std::shared_ptr<PointerEvent> pointerEvent) override;
35 #endif // OHOS_BUILD_ENABLE_POINTER
36 #ifdef OHOS_BUILD_ENABLE_TOUCH
37     void HandleTouchEvent(const std::shared_ptr<PointerEvent> pointerEvent) override;
38 #endif // OHOS_BUILD_ENABLE_TOUCH
39     int32_t AddHandleTimer(int32_t timeout = 300);
40 #ifdef OHOS_BUILD_ENABLE_COOPERATE
41     bool CheckKeyboardWhiteList(std::shared_ptr<KeyEvent> keyEvent);
42 #endif // OHOS_BUILD_ENABLE_COOPERATE
43 private:
44     int32_t OnEventDeviceAdded(libinput_event *event);
45     int32_t OnEventDeviceRemoved(libinput_event *event);
46     int32_t HandleKeyboardEvent(libinput_event* event);
47     void Repeat(const std::shared_ptr<KeyEvent> keyEvent);
48     int32_t HandleTouchPadEvent(libinput_event* event);
49     int32_t HandleGestureEvent(libinput_event* event);
50     int32_t HandleMouseEvent(libinput_event* event);
51     int32_t HandleTouchEvent(libinput_event* event);
52     int32_t HandleTableToolEvent(libinput_event* event);
53 #ifdef OHOS_BUILD_ENABLE_COOPERATE
54     bool IsNeedFilterOut(const std::string& deviceId, const std::shared_ptr<KeyEvent> keyEvent);
55 #endif // OHOS_BUILD_ENABLE_COOPERATE
56 
57 private:
58     int32_t timerId_ { -1 };
59     void ResetTouchUpEvent(std::shared_ptr<PointerEvent> pointerEvent, struct libinput_event *event);
60 };
61 } // namespace MMI
62 } // namespace OHOS
63 #endif // EVENT_NORMALIZE_HANDLER_H