2020-04-10 00:20:19 +08:00
|
|
|
#pragma once
|
|
|
|
#include <interface/lowlevel_keyboard_event_data.h>
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include <mutex>
|
2020-04-09 09:14:22 +08:00
|
|
|
#include <windows.h>
|
2020-04-10 00:20:19 +08:00
|
|
|
|
2020-04-19 07:12:26 +08:00
|
|
|
using namespace winrt;
|
|
|
|
|
2020-04-10 00:20:19 +08:00
|
|
|
// Wrapper class to handle keyboard layout
|
|
|
|
class LayoutMap
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
// Stores mappings for all the virtual key codes to the name of the key
|
|
|
|
std::mutex keyboardLayoutMap_mutex;
|
2020-04-19 07:12:26 +08:00
|
|
|
|
|
|
|
// Stores the previous layout
|
2020-04-09 09:14:22 +08:00
|
|
|
HKL previousLayout = 0;
|
2020-04-10 00:20:19 +08:00
|
|
|
|
2020-04-19 07:12:26 +08:00
|
|
|
// Stores the keys which have a unicode representation
|
|
|
|
std::map<DWORD, std::wstring> unicodeKeys;
|
|
|
|
|
|
|
|
// Stores the keys which do not have a name
|
|
|
|
std::map<DWORD, std::wstring> unknownKeys;
|
|
|
|
|
|
|
|
// Stores true if the fixed ordering key code list has already been set
|
|
|
|
bool isKeyCodeListGenerated = false;
|
|
|
|
|
|
|
|
// Stores a fixed order key code list for the drop down menus. It is kept fixed to change in ordering due to languages
|
|
|
|
std::vector<DWORD> keyCodeList;
|
|
|
|
|
2020-04-10 00:20:19 +08:00
|
|
|
public:
|
2020-04-19 07:12:26 +08:00
|
|
|
std::map<DWORD, std::wstring> keyboardLayoutMap;
|
|
|
|
|
2020-04-09 09:14:22 +08:00
|
|
|
// Update Keyboard layout according to input locale identifier
|
|
|
|
void UpdateLayout();
|
|
|
|
|
2020-04-10 00:20:19 +08:00
|
|
|
LayoutMap()
|
|
|
|
{
|
2020-04-09 09:14:22 +08:00
|
|
|
UpdateLayout();
|
2020-04-10 00:20:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Function to return the unicode string name of the key
|
|
|
|
std::wstring GetKeyName(DWORD key);
|
2020-04-09 09:14:22 +08:00
|
|
|
|
2020-04-19 07:12:26 +08:00
|
|
|
// Function to return the list of key codes in the order for the drop down. It creates it if it doesn't exist
|
|
|
|
std::vector<DWORD> GetKeyCodeList(const bool isShortcut = false);
|
|
|
|
|
|
|
|
// Function to return the list of key name in the order for the drop down based on the key codes
|
|
|
|
Windows::Foundation::Collections::IVector<Windows::Foundation::IInspectable> GetKeyNameList(const bool isShortcut = false);
|
2020-04-10 00:20:19 +08:00
|
|
|
};
|