• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 STYLUS_KEY_HANDLER_H
17 #define STYLUS_KEY_HANDLER_H
18 
19 #include "key_command_handler.h"
20 
21 #include "singleton.h"
22 
23 namespace OHOS {
24 namespace MMI {
25 struct StylusKey {
26     bool lastEventIsStylus { false };
27     bool isLaunchAbility { false };
28     std::string statusConfig;
29     bool statusConfigValue { false };
30     Ability ability;
31 };
32 
33 struct ShortHandTarget {
34     std::string statusConfig;
35     bool statusConfigValue { false };
36 };
37 class StylusKeyHandler final {
38     DECLARE_DELAYED_SINGLETON(StylusKeyHandler);
39 public:
40     DISALLOW_COPY_AND_MOVE(StylusKeyHandler);
41     bool HandleStylusKey(std::shared_ptr<KeyEvent> keyEvent);
42     void IsLaunchAbility();
43     void SetLastEventState(bool state);
44 private:
45     template <class T>
46     void CreateStatusConfigObserver(T& item);
47     void LaunchAbility(const Ability &ability);
48 private:
49     StylusKey stylusKey_;
50     ShortHandTarget shortHandTarget_;
51     bool isShortHandConfig_ { false };
52 };
53 #define STYLUS_HANDLER ::OHOS::DelayedSingleton<StylusKeyHandler>::GetInstance()
54 } // namespace MMI
55 } // namespace OHOS
56 #endif // STYLUS_KEY_HANDLER_H