mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
Add unicode naming for keys (dev/keyboardManager) (#1978)
* Added key names * Display names in detect keyboard UI * Added keyboard layout for edit keyboard window * Removed commented code * removed unused code * fixed argument modifiers * Added newline at EOF * Added unicode changes to edit shortcuts window
This commit is contained in:
committed by
Tomas Agustin Raies
parent
6fbed4ad5c
commit
e0ddaa74d0
@@ -58,6 +58,10 @@ void KeyboardManagerState::ResetUIState()
|
||||
detectedShortcut.Reset();
|
||||
detectedShortcut_lock.unlock();
|
||||
|
||||
std::unique_lock<std::mutex> currentShortcut_lock(currentShortcut_mutex);
|
||||
currentShortcut.Reset();
|
||||
currentShortcut_lock.unlock();
|
||||
|
||||
// Reset all the single key remap UI stored variables.
|
||||
std::unique_lock<std::mutex> currentSingleKeyUI_lock(currentSingleKeyUI_mutex);
|
||||
currentSingleKeyUI = nullptr;
|
||||
@@ -158,8 +162,11 @@ void KeyboardManagerState::UpdateDetectShortcutUI()
|
||||
|
||||
|
||||
std::unique_lock<std::mutex> detectedShortcut_lock(detectedShortcut_mutex);
|
||||
|
||||
std::vector<hstring> shortcut = detectedShortcut.GetKeyVector();
|
||||
std::unique_lock<std::mutex> currentShortcut_lock(currentShortcut_mutex);
|
||||
// Save the latest displayed shortcut
|
||||
currentShortcut = detectedShortcut;
|
||||
currentShortcut_lock.unlock();
|
||||
std::vector<hstring> shortcut = detectedShortcut.GetKeyVector(keyboardMap);
|
||||
|
||||
detectedShortcut_lock.unlock();
|
||||
|
||||
@@ -184,7 +191,7 @@ void KeyboardManagerState::UpdateDetectSingleKeyRemapUI()
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> detectedRemapKey_lock(detectedRemapKey_mutex);
|
||||
hstring key = winrt::to_hstring((unsigned int)detectedRemapKey);
|
||||
hstring key = winrt::to_hstring(keyboardMap.GetKeyName(detectedRemapKey).c_str());
|
||||
detectedRemapKey_lock.unlock();
|
||||
|
||||
// Since this function is invoked from the back-end thread, in order to update the UI the dispatcher must be used.
|
||||
@@ -198,37 +205,15 @@ void KeyboardManagerState::UpdateDetectSingleKeyRemapUI()
|
||||
// Function to return the currently detected shortcut which is displayed on the UI
|
||||
Shortcut KeyboardManagerState::GetDetectedShortcut()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(currentShortcutUI_mutex);
|
||||
|
||||
std::vector<winrt::hstring> keys;
|
||||
if (currentShortcutUI.Children().Size() > 0)
|
||||
{
|
||||
for (auto border : currentShortcutUI.Children())
|
||||
{
|
||||
auto keyString = border.as<Border>().Child().as<TextBlock>().Text();
|
||||
keys.push_back(keyString);
|
||||
}
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
return Shortcut::CreateShortcut(keys);
|
||||
std::lock_guard<std::mutex> lock(currentShortcut_mutex);
|
||||
return currentShortcut;
|
||||
}
|
||||
|
||||
// Function to return the currently detected remap key which is displayed on the UI
|
||||
DWORD KeyboardManagerState::GetDetectedSingleRemapKey()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(currentSingleKeyUI_mutex);
|
||||
DWORD key = 0;
|
||||
if (currentSingleKeyUI.Children().Size() > 0)
|
||||
{
|
||||
auto border = currentSingleKeyUI.Children().GetAt(0);
|
||||
auto keyString = border.as<Border>().Child().as<TextBlock>().Text();
|
||||
key = std::stoul(keyString.c_str());
|
||||
}
|
||||
|
||||
lock.unlock();
|
||||
|
||||
return key;
|
||||
std::lock_guard<std::mutex> lock(detectedRemapKey_mutex);
|
||||
return detectedRemapKey;
|
||||
}
|
||||
|
||||
// Function which can be used in HandleKeyboardHookEvent before the single key remap event to use the UI and suppress events while the remap window is active.
|
||||
|
||||
Reference in New Issue
Block a user