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 KEY_MAP_MANAGER_H 17 #define KEY_MAP_MANAGER_H 18 19 #include <map> 20 21 #include "key_event_value_transformation.h" 22 #include "libinput.h" 23 #include "singleton.h" 24 25 namespace OHOS { 26 namespace MMI { 27 class KeyMapManager final { 28 DECLARE_DELAYED_SINGLETON(KeyMapManager); 29 public: 30 DISALLOW_COPY_AND_MOVE(KeyMapManager); 31 void GetConfigKeyValue(const std::string &fileName, int32_t deviceId); 32 void ParseDeviceConfigFile(struct libinput_device *device); 33 void RemoveKeyValue(struct libinput_device *device); 34 std::string GetProFilePath(const std::string &fileName) const; 35 std::string GetKeyEventFileName(struct libinput_device *device); 36 int32_t GetDefaultKeyId(); 37 int32_t TransferDefaultKeyValue(int32_t inputKey); 38 int32_t TransferDeviceKeyValue(struct libinput_device *device, int32_t inputKey); 39 std::vector<int32_t> InputTransferKeyValue(int32_t deviceId, int32_t keyCode); 40 private: 41 std::map<int32_t, std::map<int32_t, int32_t>> configKeyValue_; 42 int32_t defaultKeyId_ { -1 }; 43 }; 44 45 #define KeyMapMgr ::OHOS::DelayedSingleton<KeyMapManager>::GetInstance() 46 } // namespace MMI 47 } // namespace OHOS 48 #endif // KEY_MAP_MANAGER_H