Skip to content

Commit

Permalink
Fix IPC events
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Jun 19, 2024
1 parent cb13814 commit bbe396d
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions korge/src@jvm/korlibs/korge/KorgeExtJvm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,22 +74,32 @@ class IPCViewsCompleter : ViewsCompleter {

when (e.type) {
IPCEvent.KEY_DOWN, IPCEvent.KEY_UP -> {
views.dispatch(
KeyEvent(when (e.type) {
IPCEvent.KEY_DOWN -> KeyEvent.Type.DOWN
IPCEvent.KEY_UP -> KeyEvent.Type.UP
else -> KeyEvent.Type.DOWN
}, key = awtKeyCodeToKey(e.p0)
)
views.gameWindow.dispatchKeyEvent(
type = when (e.type) {
IPCEvent.KEY_DOWN -> KeyEvent.Type.DOWN
IPCEvent.KEY_UP -> KeyEvent.Type.UP
else -> KeyEvent.Type.DOWN
},
id = 0,
key = awtKeyCodeToKey(e.p0),
character = e.p1.toChar(),
keyCode = e.p0,
str = null,
)
}
IPCEvent.MOUSE_MOVE, IPCEvent.MOUSE_DOWN, IPCEvent.MOUSE_UP -> {
views.dispatch(MouseEvent(type = when (e.type) {
IPCEvent.MOUSE_MOVE -> MouseEvent.Type.MOVE
IPCEvent.MOUSE_DOWN -> MouseEvent.Type.UP
IPCEvent.MOUSE_UP -> MouseEvent.Type.UP
else -> MouseEvent.Type.DOWN
}, x = e.p0, y = e.p1, button = MouseButton[e.p2]))
IPCEvent.MOUSE_MOVE, IPCEvent.MOUSE_DOWN, IPCEvent.MOUSE_UP, IPCEvent.MOUSE_CLICK -> {
views.gameWindow.dispatchMouseEvent(
id = 0,
type = when (e.type) {
IPCEvent.MOUSE_CLICK -> MouseEvent.Type.CLICK
IPCEvent.MOUSE_MOVE -> MouseEvent.Type.MOVE
IPCEvent.MOUSE_DOWN -> MouseEvent.Type.UP
IPCEvent.MOUSE_UP -> MouseEvent.Type.UP
else -> MouseEvent.Type.DOWN
}, x = e.p0, y = e.p1,
button = MouseButton[e.p2]
)
println(e)
}
IPCEvent.RESIZE -> {
val awtGameWindow = (views.gameWindow as? AwtGameWindow?)
Expand Down

0 comments on commit bbe396d

Please sign in to comment.