fix some mouse catching bugs

This commit is contained in:
Bixilon 2021-12-02 16:42:12 +01:00
parent c0905b85a0
commit 8840fc6cbb
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
2 changed files with 15 additions and 7 deletions

View File

@ -55,6 +55,7 @@ import de.bixilon.minosoft.terminal.RunConfiguration
import de.bixilon.minosoft.util.CountUpAndDownLatch
import de.bixilon.minosoft.util.KUtil
import de.bixilon.minosoft.util.KUtil.decide
import de.bixilon.minosoft.util.KUtil.format
import de.bixilon.minosoft.util.KUtil.synchronizedMapOf
import de.bixilon.minosoft.util.KUtil.toResourceLocation
import de.bixilon.minosoft.util.KUtil.unsafeCast
@ -254,7 +255,7 @@ class RenderWindow(
),
ignoreConsumer = true,
)) {
sendDebugMessage("Pausing incoming packets: $it")
sendDebugMessage("Pausing incoming packets: ${it.format()}")
connection.network.pauseReceiving(it)
}
@ -266,7 +267,7 @@ class RenderWindow(
),
ignoreConsumer = true,
)) {
sendDebugMessage("Pausing outgoing packets: $it")
sendDebugMessage("Pausing outgoing packets: ${it.format()}")
connection.network.pauseSending(it)
}
}

View File

@ -14,6 +14,7 @@
package de.bixilon.minosoft.gui.rendering.input.key
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
@ -30,7 +31,7 @@ import de.bixilon.minosoft.gui.rendering.system.window.KeyChangeTypes
import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
import de.bixilon.minosoft.util.KUtil
import de.bixilon.minosoft.util.KUtil.decide
import de.bixilon.minosoft.util.KUtil.format
import de.bixilon.minosoft.util.KUtil.toResourceLocation
class RenderWindowInputHandler(
@ -53,11 +54,17 @@ class RenderWindowInputHandler(
KeyBinding(
mutableMapOf(
KeyAction.MODIFIER to mutableSetOf(KeyCodes.KEY_F4),
KeyAction.STICKY to mutableSetOf(KeyCodes.KEY_M),
KeyAction.PRESS to mutableSetOf(KeyCodes.KEY_M),
),
)) {
renderWindow.window.cursorMode = it.decide(CursorModes.DISABLED, CursorModes.NORMAL)
renderWindow.sendDebugMessage("Toggled mouse catch!")
ignoreConsumer = true,
), defaultPressed = StaticConfiguration.DEBUG_MODE) {
val nextMode = when (renderWindow.window.cursorMode) {
CursorModes.DISABLED -> CursorModes.NORMAL
CursorModes.NORMAL -> CursorModes.DISABLED
CursorModes.HIDDEN -> CursorModes.NORMAL
}
renderWindow.window.cursorMode = nextMode
renderWindow.sendDebugMessage("Mouse catch: ${nextMode.format()}")
}
}