Use a better method to enable touch control for all games

This commit is contained in:
redphx
2024-04-29 10:05:22 +07:00
parent 102a4657f0
commit cd6dd1e22d
9 changed files with 104 additions and 128 deletions

View File

@@ -332,14 +332,14 @@ const gamepads = window.navigator.getGamepads();
let gamepadFound = false;
for (let gamepad of gamepads) {
if (gamepad && gamepad.connected) {
gamepadFound = true;
break;
}
if (gamepad && gamepad.connected) {
gamepadFound = true;
break;
}
}
if (gamepadFound) {
return;
return;
}
`;
}
@@ -386,6 +386,24 @@ window.BX_EXPOSED.onPollingModeChanged && window.BX_EXPOSED.onPollingModeChanged
str = str.replace(text, text + newCode);
return str;
},
patchXcloudTitleInfo(str: string) {
const text = 'async cloudConnect';
let index = str.indexOf(text);
if (index === -1) {
return false;
}
// Find the next "{" backet
index = str.indexOf('{', index) + 1;
const newCode = `
e = window.BX_EXPOSED.modifyTitleInfo(e);
console.log(e);
`;
str = str.substring(0, index) + newCode + str.substring(index);
return str;
},
};
let PATCH_ORDERS = [
@@ -432,6 +450,8 @@ let PATCH_ORDERS = [
// Only when playing
const PLAYING_PATCH_ORDERS = [
['patchXcloudTitleInfo'],
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['remotePlayConnectMode'],
getPref(PrefKey.REMOTE_PLAY_ENABLED) && ['remotePlayGuideWorkaround'],