• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 MULTIMODAL_INPUT_PREFERENCES_MANAGER_H
17 #define MULTIMODAL_INPUT_PREFERENCES_MANAGER_H
18 
19 #include <nocopyable.h>
20 #include <preferences_helper.h>
21 
22 #include "i_preference_manager.h"
23 
24 namespace OHOS {
25 namespace MMI {
26 class MultiModalInputPreferencesManager : public IPreferenceManager {
27 public:
28     MultiModalInputPreferencesManager() = default;
29     ~MultiModalInputPreferencesManager() = default;
30     DISALLOW_COPY_AND_MOVE(MultiModalInputPreferencesManager);
31 
32     int32_t InitPreferences() override;
33     int32_t GetIntValue(const std::string &key, int32_t defaultValue) override;
34     bool GetBoolValue(const std::string &key, bool defaultValue) override;
35     int32_t SetIntValue(const std::string &key, const std::string &setFile, int32_t setValue) override;
36     int32_t SetBoolValue(const std::string &key, const std::string &setFile, bool setValue) override;
37     int32_t GetShortKeyDuration(const std::string &key) override;
38     int32_t SetShortKeyDuration(const std::string &key, int32_t setValue) override;
39     bool IsInitPreference() override;
40     void UpdatePreferencesMap(const std::string &key, const std::string &setFile,
41         int32_t setValue, std::string &filePath) override;
42     NativePreferences::PreferencesValue GetPreValue(const std::string &key,
43         NativePreferences::PreferencesValue defaultValue) override;
44     int32_t SetPreValue(const std::string &key, const std::string &filePath,
45         const NativePreferences::PreferencesValue &setValue) override;
46 
47 private:
48     int32_t GetPreferencesSettings();
49     int32_t InitPreferencesMap();
50 
51     std::map<std::string, std::pair<std::string, int32_t>> preferencesMap_;
52     std::map<std::string, int32_t> shortcutKeyMap_;
53     int32_t keyboardRepeatRate_ { 50 };
54     int32_t keyboardRepeatDelay_ { 500 };
55     int32_t mouseScrollRows_ { 3 };
56     int32_t mousePrimaryButton_ { 0 };
57     int32_t pointerSpeed_ { 10 };
58     int32_t touchpadRightClickType_ { 1 };
59     int32_t touchpadPointerSpeed_ { 9 };
60     bool touchpadTapSwitch_ { true };
61     bool touchpadDoubleTapAndDrag_ { false };
62     bool touchpadScrollDirection_ { true };
63     bool touchpadScrollSwitch_ { true };
64     bool touchpadPinchSwitch_ { true };
65     bool touchpadSwipeSwitch_ { true };
66     bool hoverScrollState_ { true };
67     std::atomic<bool> isInitPreference_ { false };
68 #ifdef OHOS_BUILD_ENABLE_MOVE_EVENT_FILTERS
69     bool moveEventFilterFlag_ { false };
70 #endif // OHOS_BUILD_ENABLE_MOVE_EVENT_FILTERS
71     bool touchpadThreeFingerTapSwitch_ {false};
72     int32_t pointerColor_ { -1 };
73     int32_t pointerSize_ { 1 };
74     int32_t pointerStyle_ { 0 };
75     int32_t touchpadScrollRows_ { 3 };
76     const std::string strKeyboardRepeatRate_ = "keyboardRepeatRate";
77     const std::string strKeyboardRepeatDelay_ = "keyboardRepeatDelay";
78     const std::string strMouseScrollRows_ = "rows";
79     const std::string strMousePrimaryButton_ = "primaryButton";
80     const std::string strPointerSpeed_ = "speed";
81     const std::string strTouchpadRightClickType_ = "rightMenuSwitch";
82     const std::string strTouchpadPointerSpeed_ = "touchPadPointerSpeed";
83     const std::string strTouchpadTapSwitch_ = "touchpadTap";
84     const std::string strTouchpadScrollDirection_ = "scrollDirection";
85     const std::string strTouchpadScrollSwitch_ = "scrollSwitch";
86     const std::string strTouchpadPinchSwitch_ = "touchpadPinch";
87     const std::string strTouchpadSwipeSwitch_ = "touchpadSwipe";
88     const std::string strHoverScrollState_ = "isEnableHoverScroll";
89 #ifdef OHOS_BUILD_ENABLE_MOVE_EVENT_FILTERS
90     const std::string strMoveEventFilterFlag_ = "moveEventFilterFlag";
91 #endif // OHOS_BUILD_ENABLE_MOVE_EVENT_FILTERS
92     const std::string strPointerColor_ = "pointerColor";
93     const std::string strPointerSize_ = "pointerSize";
94     const std::string strPointerStyle_ = "pointerStyle";
95     const std::string strTouchpadThreeFingerTapSwitch_ = "touchpadThreeFingerTap";
96     const std::string strTouchpadScrollRows_ = "touchpadScrollRows";
97     const std::string strTouchpadDoubleTapAndDrag_ = "touchpadDoubleTapAndDrag";
98 #ifdef OHOS_BUILD_ENABLE_MAGICCURSOR
99     int32_t magicPointerColor_ { -1 };
100     int32_t magicPointerSize_ { 1 };
101     const std::string strMagicPointerColor_ = "magicPointerColor";
102     const std::string strMagicPointerSize_ = "magicPointerSize";
103 #endif // OHOS_BUILD_ENABLE_MAGICCURSOR
104     int32_t GetRightClickTypeVal(std::shared_ptr<NativePreferences::Preferences> &touchpadPref);
105 };
106 } // namespace MMI
107 } // namespace OHOS
108 #endif // MULTIMODAL_INPUT_PREFERENCES_MANAGER_H