@@ -132,6 +132,7 @@ class OverlayView @JvmOverloads constructor(
132
132
if (detectClick(event, event.actionIndex, it.x, it.y, it.radius)) {
133
133
it.isPressed = true
134
134
it.fingerId = event.actionIndex
135
+
135
136
handleButton(it, true )
136
137
137
138
return @forEach
@@ -146,7 +147,7 @@ class OverlayView @JvmOverloads constructor(
146
147
it.fingerX = posX
147
148
it.fingerY = posY
148
149
it.isPressed = true
149
- it.fingerId = event.getPointerId(event. actionIndex)
150
+ it.fingerId = event.actionIndex
150
151
151
152
val axisX = posX / (it.radius / 4 )
152
153
val axisY = posY / (it.radius / 4 )
@@ -174,13 +175,10 @@ class OverlayView @JvmOverloads constructor(
174
175
175
176
buttonList.forEach {
176
177
if (it.fingerId == i) {
177
- val clicked = detectClick(event, i, it.x, it.y, it.radius)
178
- it.isPressed = clicked
179
- handleButton(it, clicked)
178
+ it.isPressed = true
179
+ handleButton(it, true )
180
180
181
- if (clicked) {
182
- isFingerPressingButton = true
183
- }
181
+ isFingerPressingButton = true
184
182
}
185
183
}
186
184
@@ -230,20 +228,21 @@ class OverlayView @JvmOverloads constructor(
230
228
231
229
MotionEvent .ACTION_POINTER_UP -> {
232
230
buttonList.forEach {
231
+ if (it.fingerId == event.actionIndex) {
232
+ it.fingerId = - 1
233
+ }
233
234
if (detectClick(event, event.actionIndex, it.x, it.y, it.radius)) {
234
235
handleButton(it, false )
235
236
}
236
237
}
237
238
238
239
analogList.forEach {
239
- if ((event.getX(event.actionIndex) >= it.x - it.radius / 2 && event.getX(event.actionIndex) <= (it.x + (it.radius / 2 ))) &&
240
- (event.getY(event.actionIndex) >= it.y - it.radius / 2 && event.getY(event.actionIndex) <= (it.y + (it.radius / 2 )))
241
- ) {
240
+ if (it.fingerId == event.actionIndex) {
241
+ it.fingerId = - 1
242
242
it.fingerX = 0F
243
243
it.fingerY = 0F
244
244
245
245
it.isPressed = false
246
- it.fingerId = - 1
247
246
248
247
virtualAxis(
249
248
0F ,
@@ -262,6 +261,7 @@ class OverlayView @JvmOverloads constructor(
262
261
263
262
MotionEvent .ACTION_UP -> {
264
263
buttonList.forEach {
264
+ it.fingerId = - 1
265
265
handleButton(it, false )
266
266
}
267
267
0 commit comments