aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/keybindings
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-09-06 02:26:25 +0200
committernea <nea@nea.moe>2023-09-06 02:26:25 +0200
commitd29f886e25d7376c6942e7dbe6c305f601e2768d (patch)
treee2b15ca1cfea28cbcac97333b7fef192f50e2440 /src/main/kotlin/moe/nea/firmament/keybindings
parent7515c6048c5fcee27af394ace02ba35256d10106 (diff)
downloadfirmament-d29f886e25d7376c6942e7dbe6c305f601e2768d.tar.gz
firmament-d29f886e25d7376c6942e7dbe6c305f601e2768d.tar.bz2
firmament-d29f886e25d7376c6942e7dbe6c305f601e2768d.zip
Add auto sprint toggle keybinding
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/keybindings')
-rw-r--r--src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt
index ac73366..c5205bc 100644
--- a/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt
+++ b/src/main/kotlin/moe/nea/firmament/keybindings/SavedKeyBinding.kt
@@ -19,6 +19,8 @@ data class SavedKeyBinding(
val ctrl: Boolean = false,
val alt: Boolean = false,
) : IKeyBinding {
+ val isBound: Boolean get() = keyCode != GLFW.GLFW_KEY_UNKNOWN
+
constructor(keyCode: Int, mods: Triple<Boolean, Boolean, Boolean>) : this(
keyCode,
mods.first && keyCode != GLFW.GLFW_KEY_LEFT_SHIFT && keyCode != GLFW.GLFW_KEY_RIGHT_SHIFT,
@@ -39,7 +41,7 @@ data class SavedKeyBinding(
}
fun isPressed(atLeast: Boolean = false): Boolean {
- if (this.keyCode == GLFW.GLFW_KEY_UNKNOWN) return false
+ if (!isBound) return false
val h = MC.window.handle
if (!InputUtil.isKeyPressed(h, keyCode)) return false