From 20bd0329a56ab973737510fe2132605966543301 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Wed, 24 Jan 2024 17:06:15 +0100 Subject: [PATCH] Clarify event test reporting of keys Reshuffled line to group key-related items together. Omitted key code output for unknown keys to put focus on the (lack of) name. (cherry picked from commit d81fcb93f185a2dc9b9872cbfc51f5498b8386ff) --- tests/events.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/tests/events.c b/tests/events.c index 9f698f26..455f886f 100644 --- a/tests/events.c +++ b/tests/events.c @@ -393,24 +393,34 @@ static void scroll_callback(GLFWwindow* window, double x, double y) static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods) { Slot* slot = glfwGetWindowUserPointer(window); - const char* name = glfwGetKeyName(key, scancode); - if (name) + if (key == GLFW_KEY_UNKNOWN) { - printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (%s) (with%s) was %s\n", - counter++, slot->number, glfwGetTime(), key, scancode, - get_key_name(key), - name, - get_mods_name(mods), - get_action_name(action)); + printf("%08x to %i at %0.3f: Key (%s) Scancode 0x%04x (with%s) was %s\n", + counter++, slot->number, glfwGetTime(), + get_key_name(key), scancode, + get_mods_name(mods), + get_action_name(action)); } else { - printf("%08x to %i at %0.3f: Key 0x%04x Scancode 0x%04x (%s) (with%s) was %s\n", - counter++, slot->number, glfwGetTime(), key, scancode, - get_key_name(key), - get_mods_name(mods), - get_action_name(action)); + const char* name = glfwGetKeyName(key, scancode); + if (name) + { + printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x Name %s (with%s) was %s\n", + counter++, slot->number, glfwGetTime(), + key, get_key_name(key), scancode, name, + get_mods_name(mods), + get_action_name(action)); + } + else + { + printf("%08x to %i at %0.3f: Key 0x%04x (%s) Scancode 0x%04x (with%s) was %s\n", + counter++, slot->number, glfwGetTime(), + key, get_key_name(key), scancode, + get_mods_name(mods), + get_action_name(action)); + } } if (action != GLFW_PRESS)