aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/keybindings/SavedKeyBinding.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/keybindings/SavedKeyBinding.kt')
-rw-r--r--src/main/kotlin/keybindings/SavedKeyBinding.kt7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/kotlin/keybindings/SavedKeyBinding.kt b/src/main/kotlin/keybindings/SavedKeyBinding.kt
index 3ae0b89..fc0270d 100644
--- a/src/main/kotlin/keybindings/SavedKeyBinding.kt
+++ b/src/main/kotlin/keybindings/SavedKeyBinding.kt
@@ -7,6 +7,7 @@ import net.minecraft.client.util.InputUtil
import net.minecraft.text.Text
import moe.nea.firmament.util.MC
+// TODO: add support for mouse keybindings
@Serializable
data class SavedKeyBinding(
val keyCode: Int,
@@ -86,6 +87,12 @@ data class SavedKeyBinding(
(shift == this.shift)
}
+ override fun matchesAtLeast(keyCode: Int, scanCode: Int, modifiers: Int): Boolean {
+ if (this.keyCode == GLFW.GLFW_KEY_UNKNOWN) return false
+ val (shift, ctrl, alt) = getMods(modifiers)
+ return keyCode == this.keyCode && this.shift <= shift && this.ctrl <= ctrl && this.alt <= alt
+ }
+
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)