aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/keybindings/FirmamentKeyboardState.kt')
-rw-r--r--src/main/kotlin/keybindings/FirmamentKeyboardState.kt24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
new file mode 100644
index 0000000..da94a44
--- /dev/null
+++ b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
@@ -0,0 +1,24 @@
+package moe.nea.firmament.keybindings
+
+import java.util.BitSet
+import org.lwjgl.glfw.GLFW
+import net.minecraft.client.input.KeyEvent
+
+object FirmamentKeyboardState {
+
+ private val pressedScancodes = BitSet()
+
+ @Synchronized
+ fun isScancodeDown(scancode: Int): Boolean {
+ // TODO: maintain a record of keycodes that were pressed for this scanCode to check if they are still held
+ return pressedScancodes.get(scancode)
+ }
+
+ @Synchronized
+ fun maintainState(keyInput: KeyEvent, action: Int) {
+ when (action) {
+ GLFW.GLFW_PRESS -> pressedScancodes.set(keyInput.scancode)
+ GLFW.GLFW_RELEASE -> pressedScancodes.clear(keyInput.scancode)
+ }
+ }
+}