1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-12 02:00:58 +01:00

Backends: GLFW: glfwGetKeyName is not implemented in emscripten (#4907, #4858)

This commit is contained in:
RandomErrorMessage 2022-01-14 04:47:53 +00:00 committed by ocornut
parent 6188e94108
commit 45c4365ec3

View File

@ -261,7 +261,7 @@ void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yo
static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode) static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
{ {
#if GLFW_HAS_GET_KEY_NAME #if GLFW_HAS_GET_KEY_NAME && !defined(__EMSCRIPTEN__)
// GLFW 3.1+ attempts to "untranslate" keys, which goes the opposite of what every other framework does, making using lettered shortcuts difficult. // GLFW 3.1+ attempts to "untranslate" keys, which goes the opposite of what every other framework does, making using lettered shortcuts difficult.
// (It had reasons to do so: namely GLFW is/was more likely to be used for WASD-type game controls rather than lettered shortcuts, but IHMO the 3.1 change could have been done differently) // (It had reasons to do so: namely GLFW is/was more likely to be used for WASD-type game controls rather than lettered shortcuts, but IHMO the 3.1 change could have been done differently)
// See https://github.com/glfw/glfw/issues/1502 for details. // See https://github.com/glfw/glfw/issues/1502 for details.
@ -278,6 +278,8 @@ static int ImGui_ImplGlfw_TranslateUntranslatedKey(int key, int scancode)
else if (const char* p = strchr(char_names, key_name[0])) { key = char_keys[p - char_names]; } else if (const char* p = strchr(char_names, key_name[0])) { key = char_keys[p - char_names]; }
} }
// if (action == GLFW_PRESS) printf("key %d scancode %d name '%s'\n", key, scancode, key_name); // if (action == GLFW_PRESS) printf("key %d scancode %d name '%s'\n", key, scancode, key_name);
#else
IM_UNUSED(scancode);
#endif #endif
return key; return key;
} }