• 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 
16 #ifndef KEY_EVENT_NORMALIZE_H
17 #define KEY_EVENT_NORMALIZE_H
18 
19 #include "singleton.h"
20 
21 #include "i_input_windows_manager.h"
22 #include "key_event.h"
23 #include "util.h"
24 
25 namespace OHOS {
26 namespace MMI {
27 class KeyEventNormalize final {
28     DECLARE_DELAYED_SINGLETON(KeyEventNormalize);
29 public:
30     DISALLOW_COPY_AND_MOVE(KeyEventNormalize);
31     std::shared_ptr<KeyEvent> GetKeyEvent();
32     int32_t Normalize(libinput_event *event, std::shared_ptr<KeyEvent> keyEvent);
33     void ResetKeyEvent(struct libinput_device* device);
34     int32_t SetShieldStatus(int32_t shieldMode, bool isShield);
35     int32_t GetShieldStatus(int32_t shieldMode, bool &isShield);
36     void SetCurrentShieldMode(int32_t shieldMode);
37     int32_t GetCurrentShieldMode();
38 private:
39     void HandleKeyAction(struct libinput_device* device, KeyEvent::KeyItem &item, std::shared_ptr<KeyEvent> keyEvent);
40 
41 private:
42     std::shared_ptr<KeyEvent> keyEvent_ { nullptr };
43     std::map<int32_t, bool> shieldStatus_ {
44         {SHIELD_MODE::FACTORY_MODE, false},
45         {SHIELD_MODE::OOBE_MODE, false},
46     };
47     int32_t lastShieldMode_ { -1 };
48 };
49 #define KeyEventHdr ::OHOS::DelayedSingleton<KeyEventNormalize>::GetInstance()
50 } // namespace MMI
51 } // namespace OHOS
52 #endif // KEY_EVENT_NORMALIZE_H