1
0
mirror of synced 2024-11-24 07:40:17 +01:00

impr: Respect keyboard layouts for shortcuts again

This commit is contained in:
WerWolv 2023-11-18 15:18:33 +01:00
parent 331716dd48
commit 37f9f5619c

View File

@ -1045,7 +1045,7 @@ namespace hex {
#if !defined(OS_WEB)
// Register key press callback
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int, int action, int mods) {
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int scanCode, int action, int mods) {
hex::unused(mods);
auto win = static_cast<Window *>(glfwGetWindowUserPointer(window));
@ -1056,6 +1056,18 @@ namespace hex {
win->m_buttonDown = true;
}
// Handle A-Z keys using their ASCII value instead of the keycode
if (key >= GLFW_KEY_A && key <= GLFW_KEY_Z) {
std::string_view name = glfwGetKeyName(key, scanCode);
// If the key name is only one character long, use the ASCII value instead
// Otherwise the keyboard was set to a non-English layout and the key name
// is not the same as the ASCII value
if (name.length() == 1) {
key = std::toupper(name[0]);
}
}
if (key == GLFW_KEY_UNKNOWN) return;
if (action == GLFW_PRESS || action == GLFW_REPEAT) {