rendering: fix mouse key input handling

This commit is contained in:
Bixilon 2021-05-16 16:06:31 +02:00
parent 33045040ec
commit 320abcb306
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 8 additions and 1 deletions

View File

@ -24,6 +24,8 @@ import de.bixilon.minosoft.gui.rendering.RenderWindow
import de.bixilon.minosoft.gui.rendering.hud.elements.input.KeyConsumer
import de.bixilon.minosoft.protocol.network.connection.PlayConnection
import de.bixilon.minosoft.util.logging.Log
import de.bixilon.minosoft.util.logging.LogLevels
import de.bixilon.minosoft.util.logging.LogMessageType
import org.lwjgl.glfw.GLFW.*
class RenderWindowInputHandler(
@ -55,6 +57,10 @@ class RenderWindowInputHandler(
var currentKeyConsumer: KeyConsumer? = null
fun mouseKeyInput(windowId: Long, button: Int, action: Int, modifierKey: Int) {
keyInput(windowId, button, 0, action, modifierKey)
}
fun keyInput(windowId: Long, key: Int, char: Int, action: Int, modifierKey: Int) {
if (windowId != renderWindow.windowId) {
return
@ -72,7 +78,7 @@ class RenderWindowInputHandler(
return
}
else -> {
Log.warn("Unknown glfw action $action")
Log.log(LogMessageType.RENDERING_GENERAL, LogLevels.WARN) { "Unknown glfw action $action" }
return
}
}

View File

@ -254,6 +254,7 @@ class RenderWindow(
}
})
glfwSetKeyCallback(this.windowId, inputHandler::keyInput)
glfwSetMouseButtonCallback(this.windowId, inputHandler::mouseKeyInput)
glfwSetCharCallback(windowId, inputHandler::charInput)
glfwSetCursorPosCallback(windowId, inputHandler::mouseMove)