• 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 IMF_KEYBOARD_EVENT_H
17 #define IMF_KEYBOARD_EVENT_H
18 
19 #include <cstdint>
20 #include <functional>
21 
22 #include "global.h"
23 #include "key_event.h"
24 
25 namespace OHOS {
26 namespace MiscServices {
27 using KeyHandle = std::function<int32_t(uint32_t)>;
28 
29 class KeyboardEvent {
30 public:
31     static KeyboardEvent &GetInstance();
32     static int32_t AddKeyEventMonitor(KeyHandle handle);
33     static constexpr uint8_t SHIFT_LEFT_MASK = 0X1;
34     static constexpr uint8_t SHIFT_RIGHT_MASK = 0X1 << 1;
35     static constexpr uint8_t CTRL_LEFT_MASK = 0X1 << 2;
36     static constexpr uint8_t CTRL_RIGHT_MASK = 0X1 << 3;
37     static constexpr uint8_t CAPS_MASK = 0X1 << 4;
38 
39 private:
40     static constexpr int32_t PRESS_KEY_DELAY_MS = 200;
41     KeyboardEvent() = default;
42     KeyboardEvent(const KeyboardEvent &) = delete;
43     KeyboardEvent(KeyboardEvent &&) = delete;
44     KeyboardEvent &operator=(const KeyboardEvent &) = delete;
45     KeyboardEvent &operator=(KeyboardEvent &&) = delete;
46 };
47 } // namespace MiscServices
48 } // namespace OHOS
49 #endif // IMF_KEYBOARD_EVENT_H
50