• 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 private:
41     int32_t OnEventDeviceAdded(libinput_event *event);
42     int32_t OnEventDeviceRemoved(libinput_event *event);
43     int32_t HandleKeyboardEvent(libinput_event* event);
44     void Repeat(const std::shared_ptr<KeyEvent> keyEvent);
45     int32_t HandleTouchPadEvent(libinput_event* event);
46     int32_t HandleGestureEvent(libinput_event* event);
47     int32_t HandleMouseEvent(libinput_event* event);
48     int32_t HandleTouchEvent(libinput_event* event);
49     int32_t HandleSwitchInputEvent(libinput_event* event);
50     int32_t HandleTableToolEvent(libinput_event* event);
51     int32_t HandleJoystickEvent(libinput_event* event);
52     void HandlePalmEvent(libinput_event* event, std::shared_ptr<PointerEvent> pointerEvent);
53 
54 private:
55     int32_t timerId_ { -1 };
56     std::set<int32_t> buttonIds_ {};
57     void ResetTouchUpEvent(std::shared_ptr<PointerEvent> pointerEvent, struct libinput_event *event);
58 };
59 } // namespace MMI
60 } // namespace OHOS
61 #endif // EVENT_NORMALIZE_HANDLER_H