From bcd61833b291b6f9d2f68b6c9c07bda12543ae8d Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Fri, 3 May 2024 17:05:58 +0700 Subject: [PATCH] Fix touch controller not working in Remote Play --- src/modules/patcher.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index 371ddfd..13f3890 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -320,11 +320,34 @@ if (match) { return false; } - const newCode = ` -const titleInfo = window.BX_EXPOSED.getTitleInfo(); -if (!titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) { + let remotePlayCode = ''; + if (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) !== 'off' && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) { + remotePlayCode = ` +const gamepads = window.navigator.getGamepads(); +let gamepadFound = false; + +for (let gamepad of gamepads) { + if (gamepad && gamepad.connected) { + gamepadFound = true; + break; + } +} + +if (gamepadFound) { return; } +`; + } + + const newCode = ` +if (!!window.BX_REMOTE_PLAY_CONFIG) { + ${remotePlayCode} +} else { + const titleInfo = window.BX_EXPOSED.getTitleInfo(); + if (titleInfo && !titleInfo.details.hasTouchSupport && !titleInfo.details.hasFakeTouchSupport) { + return; + } +} `; str = str.replace(text, newCode + text);