Skip to content

Commit

Permalink
input: update grabbing touched points to default to POINTER1 if none …
Browse files Browse the repository at this point in the history
…are available (#224)
  • Loading branch information
LeHaine authored Jan 22, 2024
1 parent 98b9d5a commit db64e6d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
8 changes: 2 additions & 6 deletions core/src/jsMain/kotlin/com/lehaine/littlekt/input/JsInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class JsInput(val canvas: HTMLCanvasElement) : Input {
val rect = canvas.getBoundingClientRect()
val x = touchEvent.clientX.toFloat() - rect.left.toFloat()
val y = touchEvent.clientY.toFloat() - rect.top.toFloat()
inputCache.onMove(x, y, touchedPointers.last())
inputCache.onMove(x, y, touchedPointers.lastOrNull() ?: Pointer.POINTER1)
}
}

Expand Down Expand Up @@ -146,11 +146,7 @@ class JsInput(val canvas: HTMLCanvasElement) : Input {
logicalMouseX = mouseX
logicalMouseY = mouseY

if (touchedPointers.isNotEmpty()) {
inputCache.onMove(mouseX, mouseY, touchedPointers.last())
} else {
inputCache.onMove(mouseX, mouseY, Pointer.POINTER1)
}
inputCache.onMove(mouseX, mouseY, touchedPointers.lastOrNull() ?: Pointer.POINTER1)
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ class LwjglInput(private val context: LwjglContext) : Input {
mouseY *= yScale
}


if (touchedPointers.size > 0) {
inputCache.onMove(mouseX, mouseY, touchedPointers.last())
} else {
inputCache.onMove(mouseX, mouseY, Pointer.POINTER1)
}
inputCache.onMove(mouseX, mouseY, touchedPointers.lastOrNull() ?: Pointer.POINTER1)
}

glfwSetMouseButtonCallback(windowHandle) { window, button, action, mods ->
Expand Down

0 comments on commit db64e6d

Please sign in to comment.