diff --git a/lib/Surface/Handler.js b/lib/Surface/Handler.js index 1b31182975..1a19679e9f 100644 --- a/lib/Surface/Handler.js +++ b/lib/Surface/Handler.js @@ -42,6 +42,9 @@ class SurfaceHandler extends CoreBase { */ currentPincodeEntry = '' + /** Currently pressed buttons, and what they are keeping pressed */ + #currentButtonPresses = {} + /** * Whether the surface is currently locked */ @@ -68,8 +71,6 @@ class SurfaceHandler extends CoreBase { this.isSurfaceLocked = isLocked this.currentPage = 1 // The current page of the device - this.lastpress = '' - this.lastpage = 0 // Fill in max offsets const keysPerRow = this.panel.info.keysPerRow || 0 @@ -300,18 +301,13 @@ class SurfaceHandler extends CoreBase { let thisPage = this.currentPage - // TODO - what is lastpress vs lastpage. This flow looks weird and like it might get things wrong sometimes.. - let thispress = this.currentPage if (pressed) { - this.lastpress = thispress - this.lastpage = this.currentPage - } else if (thispress != this.lastpress) { - // page changed on this device before button released - // release the old page+bank - thisPage = this.lastpage - this.lastpress = '' + // Track what page was pressed for this key + this.#currentButtonPresses[key] = thisPage } else { - this.lastpress = '' + // Release the same page that was previously pressed + thisPage = this.#currentButtonPresses[key] ?? thisPage + delete this.#currentButtonPresses[key] } // allow the xkeys to span pages