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