aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/keybindings/GenericInputButton.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-11-15 23:13:50 +0100
committerLinnea Gräf <nea@nea.moe>2025-11-15 23:13:50 +0100
commit4d8399ff4d769def62e6a8241327c4f2dac47e71 (patch)
tree703f8651cb680d2583d82c2b1b4aee0911ccb490 /src/main/kotlin/keybindings/GenericInputButton.kt
parent215178c650d38a4a77fdef6dc8815c07bef29c25 (diff)
downloadFirmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.tar.gz
Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.tar.bz2
Firmament-4d8399ff4d769def62e6a8241327c4f2dac47e71.zip
snapshot: main source set compile
Diffstat (limited to 'src/main/kotlin/keybindings/GenericInputButton.kt')
-rw-r--r--src/main/kotlin/keybindings/GenericInputButton.kt16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/main/kotlin/keybindings/GenericInputButton.kt b/src/main/kotlin/keybindings/GenericInputButton.kt
index ddbf509..39bb4dd 100644
--- a/src/main/kotlin/keybindings/GenericInputButton.kt
+++ b/src/main/kotlin/keybindings/GenericInputButton.kt
@@ -14,7 +14,9 @@ import kotlinx.serialization.json.buildJsonObject
import kotlinx.serialization.json.int
import kotlinx.serialization.json.put
import net.minecraft.client.MinecraftClient
+import net.minecraft.client.input.KeyInput
import net.minecraft.client.util.InputUtil
+import net.minecraft.client.util.MacWindowUtil
import net.minecraft.text.Text
import moe.nea.firmament.util.MC
import moe.nea.firmament.util.mc.InitLevel
@@ -107,7 +109,7 @@ sealed interface GenericInputButton {
}
override fun isPressed(): Boolean {
- return InputUtil.isKeyPressed(MC.window.handle, keyCode)
+ return InputUtil.isKeyPressed(MC.window, keyCode)
}
override fun isCtrl(): Boolean {
@@ -188,6 +190,9 @@ sealed interface GenericInputAction {
fun mouse(mouseButton: Int): GenericInputAction = MouseInput(mouseButton)
@JvmStatic
+ fun of(input: KeyInput): GenericInputAction = key(input.keycode, input.scancode)
+
+ @JvmStatic
fun key(keyCode: Int, scanCode: Int): GenericInputAction = KeyboardInput(keyCode, scanCode)
}
}
@@ -199,8 +204,8 @@ data class InputModifiers(
companion object {
@JvmStatic
fun current(): InputModifiers {
- val h = MC.window.handle
- val ctrl = if (MinecraftClient.IS_SYSTEM_MAC) {
+ val h = MC.window
+ val ctrl = if (MacWindowUtil.IS_MAC) {
InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_SUPER)
|| InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_RIGHT_SUPER)
} else InputUtil.isKeyPressed(h, GLFW.GLFW_KEY_LEFT_CONTROL)
@@ -223,7 +228,7 @@ data class InputModifiers(
val superKeys = listOf(GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER)
- val controlKeys = if (MinecraftClient.IS_SYSTEM_MAC) {
+ val controlKeys = if (MacWindowUtil.IS_MAC) {
listOf(GLFW.GLFW_KEY_LEFT_SUPER, GLFW.GLFW_KEY_RIGHT_SUPER)
} else {
listOf(GLFW.GLFW_KEY_LEFT_CONTROL, GLFW.GLFW_KEY_RIGHT_CONTROL)
@@ -265,6 +270,9 @@ data class InputModifiers(
@JvmStatic
fun of(modifiers: Int) = InputModifiers(modifiers)
+ @JvmStatic
+ fun of(input: KeyInput) = InputModifiers(input.modifiers)
+
fun none(): InputModifiers {
return InputModifiers(0)
}