File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
src/main/kotlin/com/lambda/gui/widgets Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,8 @@ class KeybindWidget(
5959
6060 fun ImGuiBuilder.build () {
6161 val current = valueGetter()
62- val translated = KeyCode .virtualMapUS(current.keyCode, 0 )
62+ val scancode = GLFW .glfwGetKeyScancode(current.keyCode)
63+ val translated = KeyCode .virtualMapUS(current.keyCode, scancode)
6364 val preview = if (listening) " $label : Press any key…" else " $label : ${translated.prettyDisplay()} "
6465
6566 if (listening) {
@@ -102,7 +103,15 @@ class KeybindWidget(
102103
103104 private fun KeyCode.prettyDisplay (): String {
104105 if (this == KeyCode .UNBOUND ) return " Unbound"
105- val name = GLFW .glfwGetKeyName(keyCode, 0 )
106- return name?.ifBlank { null }?.uppercase() ? : this .name
106+ if (keyCode == GLFW .GLFW_KEY_UNKNOWN ) return name
107+
108+ val scancode = GLFW .glfwGetKeyScancode(keyCode)
109+ val nameFromGlfw = if (scancode != 0 ) {
110+ GLFW .glfwGetKeyName(GLFW .GLFW_KEY_UNKNOWN , scancode)
111+ } else {
112+ GLFW .glfwGetKeyName(keyCode, 0 )
113+ }
114+
115+ return nameFromGlfw?.takeIf { it.isNotBlank() }?.uppercase() ? : name
107116 }
108117}
You can’t perform that action at this time.
0 commit comments