fix: Shortcuts not working correctly with non-western keyboards
This commit is contained in:
parent
e7bfa483f8
commit
2d45dce075
@ -189,7 +189,15 @@ namespace hex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const Shortcut &other) const {
|
bool operator==(const Shortcut &other) const {
|
||||||
return this->m_keys == other.m_keys;
|
auto thisKeys = this->m_keys;
|
||||||
|
auto otherKeys = other.m_keys;
|
||||||
|
|
||||||
|
thisKeys.erase(CurrentView);
|
||||||
|
thisKeys.erase(AllowWhileTyping);
|
||||||
|
otherKeys.erase(CurrentView);
|
||||||
|
otherKeys.erase(AllowWhileTyping);
|
||||||
|
|
||||||
|
return thisKeys == otherKeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLocal() const {
|
bool isLocal() const {
|
||||||
|
@ -42,42 +42,34 @@ namespace hex {
|
|||||||
return pressedShortcut;
|
return pressedShortcut;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutManager::process(const std::unique_ptr<View> ¤tView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) {
|
static void processShortcut(const Shortcut &shortcut, const std::map<Shortcut, ShortcutManager::ShortcutEntry> &shortcuts) {
|
||||||
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, focused, keyCode);
|
|
||||||
|
|
||||||
if (keyCode != 0)
|
|
||||||
s_prevShortcut = Shortcut(pressedShortcut.getKeys());
|
|
||||||
|
|
||||||
if (s_paused) return;
|
if (s_paused) return;
|
||||||
|
|
||||||
if (ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId))
|
if (ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (currentView->m_shortcuts.contains(pressedShortcut + AllowWhileTyping)) {
|
if (shortcuts.contains(shortcut + AllowWhileTyping)) {
|
||||||
currentView->m_shortcuts[pressedShortcut + AllowWhileTyping].callback();
|
shortcuts.at(shortcut + AllowWhileTyping).callback();
|
||||||
} else if (currentView->m_shortcuts.contains(pressedShortcut)) {
|
} else if (shortcuts.contains(shortcut)) {
|
||||||
if (!ImGui::GetIO().WantTextInput)
|
if (!ImGui::GetIO().WantTextInput)
|
||||||
currentView->m_shortcuts[pressedShortcut].callback();
|
shortcuts.at(shortcut).callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ShortcutManager::process(const std::unique_ptr<View> ¤tView, bool ctrl, bool alt, bool shift, bool super, bool focused, u32 keyCode) {
|
||||||
|
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, focused, keyCode);
|
||||||
|
if (keyCode != 0)
|
||||||
|
s_prevShortcut = Shortcut(pressedShortcut.getKeys());
|
||||||
|
|
||||||
|
processShortcut(pressedShortcut, currentView->m_shortcuts);
|
||||||
|
}
|
||||||
|
|
||||||
void ShortcutManager::processGlobals(bool ctrl, bool alt, bool shift, bool super, u32 keyCode) {
|
void ShortcutManager::processGlobals(bool ctrl, bool alt, bool shift, bool super, u32 keyCode) {
|
||||||
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, false, keyCode);
|
Shortcut pressedShortcut = getShortcut(ctrl, alt, shift, super, false, keyCode);
|
||||||
|
|
||||||
if (keyCode != 0)
|
if (keyCode != 0)
|
||||||
s_prevShortcut = pressedShortcut;
|
s_prevShortcut = Shortcut(pressedShortcut.getKeys());
|
||||||
|
|
||||||
if (s_paused) return;
|
processShortcut(pressedShortcut, s_globalShortcuts);
|
||||||
|
|
||||||
if (ImGui::IsPopupOpen(ImGuiID(0), ImGuiPopupFlags_AnyPopupId))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (s_globalShortcuts.contains(pressedShortcut + AllowWhileTyping)) {
|
|
||||||
s_globalShortcuts[pressedShortcut + AllowWhileTyping].callback();
|
|
||||||
} else if (s_globalShortcuts.contains(pressedShortcut)) {
|
|
||||||
if (!ImGui::GetIO().WantTextInput)
|
|
||||||
s_globalShortcuts[pressedShortcut].callback();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShortcutManager::clearShortcuts() {
|
void ShortcutManager::clearShortcuts() {
|
||||||
|
@ -1044,7 +1044,7 @@ namespace hex {
|
|||||||
|
|
||||||
#if !defined(OS_WEB)
|
#if !defined(OS_WEB)
|
||||||
// Register key press callback
|
// Register key press callback
|
||||||
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int scancode, int action, int mods) {
|
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int, int action, int mods) {
|
||||||
hex::unused(mods);
|
hex::unused(mods);
|
||||||
|
|
||||||
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
|
||||||
@ -1057,10 +1057,6 @@ namespace hex {
|
|||||||
|
|
||||||
if (key == GLFW_KEY_UNKNOWN) return;
|
if (key == GLFW_KEY_UNKNOWN) return;
|
||||||
|
|
||||||
auto keyName = glfwGetKeyName(key, scancode);
|
|
||||||
if (keyName != nullptr)
|
|
||||||
key = std::toupper(keyName[0]);
|
|
||||||
|
|
||||||
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
if (action == GLFW_PRESS || action == GLFW_REPEAT) {
|
||||||
if (key != GLFW_KEY_LEFT_CONTROL && key != GLFW_KEY_RIGHT_CONTROL &&
|
if (key != GLFW_KEY_LEFT_CONTROL && key != GLFW_KEY_RIGHT_CONTROL &&
|
||||||
key != GLFW_KEY_LEFT_ALT && key != GLFW_KEY_RIGHT_ALT &&
|
key != GLFW_KEY_LEFT_ALT && key != GLFW_KEY_RIGHT_ALT &&
|
||||||
|
Loading…
Reference in New Issue
Block a user