• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 #ifndef PROCESSING_KEYBOARD_DEVICE_H
16 #define PROCESSING_KEYBOARD_DEVICE_H
17 
18 #include "msg_head.h"
19 #include "device_base.h"
20 
21 namespace OHOS {
22 namespace MMI {
23 class ProcessingKeyboardDevice : public DeviceBase {
24     struct KeyBoardEvent {
25         std::string eventType;
26         int32_t keyValue;
27         int32_t blockTime;
28     };
29 public:
30     ProcessingKeyboardDevice() = default;
31     ~ProcessingKeyboardDevice() = default;
32     int32_t TransformJsonDataToInputData(const Json& inputEventArrays, InputEventArray& inputEventArray);
33 private:
34     int32_t AnalysisKeyBoardEvent(const Json& inputData, std::vector<KeyBoardEvent>& keyBoardEvent);
35     void TransformKeyBoardEventToInputEvent(const std::vector<KeyBoardEvent>& keyBoardEventArray,
36                                             InputEventArray& inputEventArray);
37     void TransformKeyPressEvent(const KeyBoardEvent& keyBoardEvent, InputEventArray& inputEventArray);
38     void TransformKeyLongPressEvent(const KeyBoardEvent& keyBoardEvent, InputEventArray& inputEventArray);
39     void TransformKeyReleaseEvent(const KeyBoardEvent& keyBoardEvent, InputEventArray& inputEventArray);
40     void TransformKeyClickEvent(const KeyBoardEvent& keyBoardEvent, InputEventArray& inputEventArray);
41 private:
42     static constexpr int32_t EV_ABS_MISC_DEFAULT_VALUE = 15;
43     static constexpr int32_t EVENT_REPROT_COUNTS = 50;
44     static constexpr int32_t EVENT_REPROT_TIMES = 20;
45 };
46 } // namespace MMI
47 } // namespace OHOS
48 #endif // PROCESSING_KEYBOARD_DEVICE_H