aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/keybindings
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-08-31 23:23:43 +0200
committernea <nea@nea.moe>2023-08-31 23:23:43 +0200
commit41dc53e00e683c62cec8eb08641156077b84639c (patch)
tree1d9757fde571e27430573f7b2f4a69380e0608e1 /src/main/kotlin/moe/nea/firmament/keybindings
parent36d5ef29e45a57e88d9d608d1becb5cb7de27cf5 (diff)
downloadFirmament-41dc53e00e683c62cec8eb08641156077b84639c.tar.gz
Firmament-41dc53e00e683c62cec8eb08641156077b84639c.tar.bz2
Firmament-41dc53e00e683c62cec8eb08641156077b84639c.zip
Add the ability to unbind keys using ESCAPE
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/keybindings')
-rw-r--r--src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt20
1 files changed, 2 insertions, 18 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt
index 606485b..e538ff0 100644
--- a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt
+++ b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt
@@ -38,25 +38,8 @@ data class SavedKeyBinding(
}
}
- fun hasShiftDown(): Boolean {
- return InputUtil.isKeyPressed(
- MinecraftClient.getInstance().window.handle,
- GLFW.GLFW_KEY_LEFT_SHIFT
- ) || InputUtil.isKeyPressed(
- MinecraftClient.getInstance().window.handle, GLFW.GLFW_KEY_RIGHT_SHIFT
- )
- }
-
- fun hasAltDown(): Boolean {
- return InputUtil.isKeyPressed(
- MinecraftClient.getInstance().window.handle,
- GLFW.GLFW_KEY_LEFT_ALT
- ) || InputUtil.isKeyPressed(
- MinecraftClient.getInstance().window.handle, GLFW.GLFW_KEY_RIGHT_ALT
- )
- }
-
fun isPressed(): Boolean {
+ if (this.keyCode == GLFW.GLFW_KEY_UNKNOWN) return false
val h = MC.window.handle
if (!InputUtil.isKeyPressed(h, keyCode)) return false
@@ -76,6 +59,7 @@ data class SavedKeyBinding(
}
override fun matches(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ if (this.keyCode == GLFW.GLFW_KEY_UNKNOWN) return false
return keyCode == this.keyCode && getMods(modifiers) == Triple(shift, ctrl, alt)
}