From 71c33ff3eeb88df0078264a62c552488e63a7bb1 Mon Sep 17 00:00:00 2001 From: Ethan O'Brien <77750390+ethanaobrien@users.noreply.github.com> Date: Tue, 4 Jul 2023 19:32:00 -0500 Subject: [PATCH] Touch handling cleanup --- data/emulator.js | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/data/emulator.js b/data/emulator.js index 69e4418..a470b90 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -312,6 +312,9 @@ class EmulatorJS { } } startButtonClicked(e) { + if (e.pointerType === "touch") { + this.touch = true; + } if (e.preventDefault) { e.preventDefault(); e.target.remove(); @@ -2411,7 +2414,7 @@ class EmulatorJS { }, 'download'); } - if (this.touch) { + if (this.touch || navigator.maxTouchPoints > 0) { addToMenu(this.localization('Virtual Gamepad'), 'virtual-gamepad', { 'enabled': this.localization("Enabled"), 'disabled': this.localization("Disabled") @@ -2422,21 +2425,23 @@ class EmulatorJS { }, 'disabled'); } - this.gameManager.getCoreOptions().split('\n').forEach((line, index) => { - let option = line.split('; '); - let name = option[0]; - let options = option[1].split('|'), - optionName = name.split("|")[0].replace(/_/g, ' ').replace(/.+\-(.+)/, '$1'); - options.slice(1, -1); - if (options.length === 1) return; - let availableOptions = {}; - for (let i=0; i 1) ? name.split("|")[1] : options[0].replace('(Default) ', '')); - }) + if (this.gameManager.getCoreOptions()) { + this.gameManager.getCoreOptions().split('\n').forEach((line, index) => { + let option = line.split('; '); + let name = option[0]; + let options = option[1].split('|'), + optionName = name.split("|")[0].replace(/_/g, ' ').replace(/.+\-(.+)/, '$1'); + options.slice(1, -1); + if (options.length === 1) return; + let availableOptions = {}; + for (let i=0; i 1) ? name.split("|")[1] : options[0].replace('(Default) ', '')); + }) + } this.settingsMenu.appendChild(nested);