diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-09-06 17:09:15 +0200 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-09-06 17:09:15 +0200 |
| commit | d62ee562abe14cf06275b30411226e440a6ac3a7 (patch) | |
| tree | 64e8ca75cb8dcdbcf255f456ab09042a2a24894f /src/main/kotlin/keybindings/FirmamentKeyboardState.kt | |
| parent | 781e204c4d7a1883b048e6bf7f41b8c59c2b3270 (diff) | |
| download | Firmament-d62ee562abe14cf06275b30411226e440a6ac3a7.tar.gz Firmament-d62ee562abe14cf06275b30411226e440a6ac3a7.tar.bz2 Firmament-d62ee562abe14cf06275b30411226e440a6ac3a7.zip | |
feat: rework input system to be more generic towards keycodes
Diffstat (limited to 'src/main/kotlin/keybindings/FirmamentKeyboardState.kt')
| -rw-r--r-- | src/main/kotlin/keybindings/FirmamentKeyboardState.kt | 23 |
1 files changed, 23 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..65288bc --- /dev/null +++ b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt @@ -0,0 +1,23 @@ +package moe.nea.firmament.keybindings + +import java.util.BitSet +import org.lwjgl.glfw.GLFW + +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(key: Int, scancode: Int, action: Int, modifiers: Int) { + when (action) { + GLFW.GLFW_PRESS -> pressedScancodes.set(scancode) + GLFW.GLFW_RELEASE -> pressedScancodes.clear(scancode) + } + } +} |
