From b673af9925e57828783b5e2ef5a54aa858436ad9 Mon Sep 17 00:00:00 2001 From: Rui Reis Date: Wed, 31 Jul 2024 15:45:33 +0200 Subject: [PATCH] Fix touches with same id not being removed properly --- core/input/touchhandlerultravnc.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/input/touchhandlerultravnc.js b/core/input/touchhandlerultravnc.js index c9ccac91..05fba0ef 100644 --- a/core/input/touchhandlerultravnc.js +++ b/core/input/touchhandlerultravnc.js @@ -88,14 +88,20 @@ export default class TouchHandlerUltraVNC { } } else if (ev.type === "touchend" || ev.type === "touchcancel") { for (let i = 0; i < ev.changedTouches.length; i++) { - const index = this._currentTouches.findIndex(t => t.event.identifier === ev.changedTouches[i].identifier); - if (index !== -1) { - this._currentTouches[index].status = "POINTER_UP"; - } + const indexes = this._getAllIndexes(this._currentTouches, (t) => t.event.identifier === ev.changedTouches[i].identifier) + indexes.forEach((index) => this._currentTouches[index].status = "POINTER_UP"); } } } + _getAllIndexes(arr, func) { + var indexes = [], i; + for (i = 0; i < arr.length; i++) + if (func(arr[i])) + indexes.push(i); + return indexes; + } + _dispatchTouchEvent(ev) { let tev = new CustomEvent('ultravnctouch', { event: ev, detail: { currentTouches: this._currentTouches, giiDeviceOrigin: this._giiDeviceOrigin } }); this._target.dispatchEvent(tev);