mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
refactor: clarify adaptive stick hit testing and test setup
This commit is contained in:
1 parent
d8c1bc6059
commit
1c24c600cd
2 files changed
+24
-16
No files matched your search
@@ -694,15 +694,18 @@ class OnScreenControls(
|
||||
private fun adaptiveStickAt(x: Float, y: Float): Control? {
|
||||
if (!settings.adaptiveSticks || editing || buttonsOnly || quickHidden) return null
|
||||
if (x < safe.left || x >= width - safe.right || y < safe.top || y >= height - safe.bottom) return null
|
||||
if (controls.any { it.stick < 0 && isVisible(it) && it.contains(x, y, it.radius, 5f) }) return null
|
||||
return controls.filter {
|
||||
val dx = if (it.stick == 0) max(0f, x - it.cx) else x - it.cx
|
||||
val dy = y - it.cy
|
||||
val reach = it.radius * 1.4f * sqrt(1.5f)
|
||||
it.stick >= 0 && isVisible(it) && it.pressedBy == -1 && dx * dx + dy * dy <= reach * reach
|
||||
}.minByOrNull {
|
||||
val dx = x - it.cx
|
||||
val dy = y - it.cy
|
||||
if (controls.any { control ->
|
||||
control.stick < 0 && isVisible(control) && control.contains(x, y, control.radius, 5f)
|
||||
}) return null
|
||||
return controls.filter { control ->
|
||||
val dx = if (control.stick == 0) max(0f, x - control.cx) else x - control.cx
|
||||
val dy = y - control.cy
|
||||
val reach = control.radius * 1.4f * sqrt(1.5f)
|
||||
control.stick >= 0 && isVisible(control) && control.pressedBy == -1 &&
|
||||
dx * dx + dy * dy <= reach * reach
|
||||
}.minByOrNull { control ->
|
||||
val dx = x - control.cx
|
||||
val dy = y - control.cy
|
||||
dx * dx + dy * dy
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user