From 79ec72e5a9090bacb67f199459963408ba06a1ba Mon Sep 17 00:00:00 2001 From: Saad Nadeem Date: Sat, 8 Aug 2026 22:39:32 -0400 Subject: [PATCH 1/2] fix(keybinds): disallow combos for minecraft keybinds --- .../internal/ui/keybind/MinecraftKeybindProvider.kt | 1 + .../internal/ui/components/settings/KeybindOption.kt | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt index 49247aee4..66c3d125b 100644 --- a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt +++ b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt @@ -86,6 +86,7 @@ object MinecraftKeybindProvider : KeybindGroupProvider { OneConfigKeybind::class.java, ) prop.addMetadata("visualizer", Visualizer.KeybindVisualizer::class.java) + prop.addMetadata("singleKey", true) prop.addMetadata("category", categoryLabel(mapping)) prop.addMetadata("subcategory", "Minecraft Controls") return prop diff --git a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/components/settings/KeybindOption.kt b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/components/settings/KeybindOption.kt index 9b5af33a1..5ca90869a 100644 --- a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/components/settings/KeybindOption.kt +++ b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/components/settings/KeybindOption.kt @@ -115,6 +115,7 @@ private fun KeyEvent.awtKeyEventId(): Int? = runCatching { @Composable fun KeybindOption(data: KeybindOptionData) { val theme = LocalTheme.current + val singleKey = data.prop.getMetadata("singleKey") == true val interactionSource = rememberInteractionSource() val isHovered by interactionSource.collectIsHoveredAsState() var recording by remember(data.prop) { mutableStateOf(false) } @@ -213,6 +214,11 @@ fun KeybindOption(data: KeybindOptionData) { // would match nothing useful (or, for code 0, match everything). val glfwCode = event.utf16CodePoint if (glfwCode <= 0) return@onKeyEvent true + if (singleKey) { + applyKeybind(intArrayOf(glfwCode), null) + recording = false + return@onKeyEvent true + } if (glfwCode !in recordedKeys) recordedKeys.add(glfwCode) heldKeys.add(glfwCode) return@onKeyEvent true From 468b34f9e0e487b55d35111477a406daa2eb0aa8 Mon Sep 17 00:00:00 2001 From: Saad Nadeem Date: Sat, 8 Aug 2026 22:44:09 -0400 Subject: [PATCH 2/2] fix(keybinds): allow reset to default for minecraft keybinds --- .../internal/ui/keybind/MinecraftKeybindProvider.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt index 66c3d125b..070fc585f 100644 --- a/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt +++ b/minecraft/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/keybind/MinecraftKeybindProvider.kt @@ -87,6 +87,7 @@ object MinecraftKeybindProvider : KeybindGroupProvider { ) prop.addMetadata("visualizer", Visualizer.KeybindVisualizer::class.java) prop.addMetadata("singleKey", true) + prop.addMetadata("default", mapping.defaultKey.toOneConfigKeybind()) prop.addMetadata("category", categoryLabel(mapping)) prop.addMetadata("subcategory", "Minecraft Controls") return prop @@ -156,13 +157,17 @@ object MinecraftKeybindProvider : KeybindGroupProvider { private fun KeyMapping.toOneConfigKeybind(): OneConfigKeybind { val key = runCatching { InputConstants.getKey(saveString()) }.getOrDefault(InputConstants.UNKNOWN) - return when (key.type) { + return key.toOneConfigKeybind() + } + + private fun InputConstants.Key.toOneConfigKeybind(): OneConfigKeybind { + return when (type) { InputConstants.Type.KEYSYM -> { - if (key.value > 0) OneConfigKeybind(intArrayOf(key.value), null, KeyModifiers.NONE, 0L) { true } + if (value > 0) OneConfigKeybind(intArrayOf(value), null, KeyModifiers.NONE, 0L) { true } else OneConfigKeybind(null, null, KeyModifiers.NONE, 0L) { true } } InputConstants.Type.MOUSE -> { - if (key.value >= 0) OneConfigKeybind(null, intArrayOf(key.value), KeyModifiers.NONE, 0L) { true } + if (value >= 0) OneConfigKeybind(null, intArrayOf(value), KeyModifiers.NONE, 0L) { true } else OneConfigKeybind(null, null, KeyModifiers.NONE, 0L) { true } } else -> OneConfigKeybind(null, null, KeyModifiers.NONE, 0L) { true }