Fix disabling touch control doesn't always work

This commit is contained in:
redphx 2024-08-14 17:52:09 +07:00
parent 3d2b887859
commit 8b56ae218d

View File

@ -392,9 +392,11 @@ if (window.BX_EXPOSED.stopTakRendering) {
return false; return false;
} }
let remotePlayCode = ''; let autoOffCode = '';
if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== 'off' && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) { if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'off') {
remotePlayCode = ` autoOffCode = 'return;';
} else if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) {
autoOffCode = `
const gamepads = window.navigator.getGamepads(); const gamepads = window.navigator.getGamepads();
let gamepadFound = false; let gamepadFound = false;
@ -412,14 +414,12 @@ if (gamepadFound) {
} }
const newCode = ` const newCode = `
if (!!window.BX_REMOTE_PLAY_CONFIG) { ${autoOffCode}
${remotePlayCode}
} else {
const titleInfo = window.BX_EXPOSED.getTitleInfo(); const titleInfo = window.BX_EXPOSED.getTitleInfo();
if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) { if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) {
return; return;
} }
}
`; `;
str = str.replace(text, newCode + text); str = str.replace(text, newCode + text);