mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Update device suggestion URL
This commit is contained in:
parent
17c08792e1
commit
b0ecc7171b
14
dist/better-xcloud.lite.user.js
vendored
14
dist/better-xcloud.lite.user.js
vendored
@ -3939,9 +3939,14 @@ class SettingsNavigationDialog extends NavigationDialog {
|
||||
reloadPage() {
|
||||
this.$btnGlobalReload.disabled = !0, this.$btnGlobalReload.firstElementChild.textContent = t("settings-reloading"), this.hide(), FullscreenText.getInstance().show(t("settings-reloading")), window.location.reload();
|
||||
}
|
||||
async getRecommendedSettings(deviceCode) {
|
||||
async getRecommendedSettings(androidInfo) {
|
||||
function normalize(str) {
|
||||
return str.toLowerCase().trim().replaceAll(/\s+/g, "-").replaceAll(/-+/g, "-");
|
||||
}
|
||||
try {
|
||||
let json = await (await NATIVE_FETCH(`https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${deviceCode.toLowerCase()}.json`)).json(), recommended = {};
|
||||
let { manufacturer, board, model } = androidInfo;
|
||||
manufacturer = normalize(manufacturer), board = normalize(board), model = normalize(model);
|
||||
let url = `https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${manufacturer}/${board}-${model}.json`, json = await (await NATIVE_FETCH(url)).json(), recommended = {};
|
||||
if (json.schema_version !== 1) return null;
|
||||
let scriptSettings = json.settings.script;
|
||||
if (scriptSettings._base) {
|
||||
@ -3999,10 +4004,7 @@ class SettingsNavigationDialog extends NavigationDialog {
|
||||
}
|
||||
let recommendedDevice = "";
|
||||
if (BX_FLAGS.DeviceInfo.deviceType.includes("android")) {
|
||||
if (BX_FLAGS.DeviceInfo.androidInfo) {
|
||||
let deviceCode = BX_FLAGS.DeviceInfo.androidInfo.board;
|
||||
recommendedDevice = await this.getRecommendedSettings(deviceCode);
|
||||
}
|
||||
if (BX_FLAGS.DeviceInfo.androidInfo) recommendedDevice = await this.getRecommendedSettings(BX_FLAGS.DeviceInfo.androidInfo);
|
||||
}
|
||||
let hasRecommendedSettings = Object.keys(this.suggestedSettings.recommended).length > 0, deviceType = BX_FLAGS.DeviceInfo.deviceType;
|
||||
if (deviceType === "android-handheld") this.addDefaultSuggestedSetting("stream_touch_controller", "off"), this.addDefaultSuggestedSetting("controller_device_vibration", "on");
|
||||
|
14
dist/better-xcloud.user.js
vendored
14
dist/better-xcloud.user.js
vendored
@ -5101,9 +5101,14 @@ class SettingsNavigationDialog extends NavigationDialog {
|
||||
reloadPage() {
|
||||
this.$btnGlobalReload.disabled = !0, this.$btnGlobalReload.firstElementChild.textContent = t("settings-reloading"), this.hide(), FullscreenText.getInstance().show(t("settings-reloading")), window.location.reload();
|
||||
}
|
||||
async getRecommendedSettings(deviceCode) {
|
||||
async getRecommendedSettings(androidInfo) {
|
||||
function normalize(str) {
|
||||
return str.toLowerCase().trim().replaceAll(/\s+/g, "-").replaceAll(/-+/g, "-");
|
||||
}
|
||||
try {
|
||||
let json = await (await NATIVE_FETCH(`https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${deviceCode.toLowerCase()}.json`)).json(), recommended = {};
|
||||
let { manufacturer, board, model } = androidInfo;
|
||||
manufacturer = normalize(manufacturer), board = normalize(board), model = normalize(model);
|
||||
let url = `https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${manufacturer}/${board}-${model}.json`, json = await (await NATIVE_FETCH(url)).json(), recommended = {};
|
||||
if (json.schema_version !== 1) return null;
|
||||
let scriptSettings = json.settings.script;
|
||||
if (scriptSettings._base) {
|
||||
@ -5161,10 +5166,7 @@ class SettingsNavigationDialog extends NavigationDialog {
|
||||
}
|
||||
let recommendedDevice = "";
|
||||
if (BX_FLAGS.DeviceInfo.deviceType.includes("android")) {
|
||||
if (BX_FLAGS.DeviceInfo.androidInfo) {
|
||||
let deviceCode = BX_FLAGS.DeviceInfo.androidInfo.board;
|
||||
recommendedDevice = await this.getRecommendedSettings(deviceCode);
|
||||
}
|
||||
if (BX_FLAGS.DeviceInfo.androidInfo) recommendedDevice = await this.getRecommendedSettings(BX_FLAGS.DeviceInfo.androidInfo);
|
||||
}
|
||||
let hasRecommendedSettings = Object.keys(this.suggestedSettings.recommended).length > 0, deviceType = BX_FLAGS.DeviceInfo.deviceType;
|
||||
if (deviceType === "android-handheld") this.addDefaultSuggestedSetting("stream_touch_controller", "off"), this.addDefaultSuggestedSetting("controller_device_vibration", "on");
|
||||
|
@ -19,7 +19,7 @@ import { setNearby } from "@/utils/navigation-utils";
|
||||
import { PatcherCache } from "@/modules/patcher";
|
||||
import { UserAgentProfile } from "@/enums/user-agent";
|
||||
import { UserAgent } from "@/utils/user-agent";
|
||||
import { BX_FLAGS, NATIVE_FETCH } from "@/utils/bx-flags";
|
||||
import { BX_FLAGS, NATIVE_FETCH, type BxFlags } from "@/utils/bx-flags";
|
||||
import { copyToClipboard } from "@/utils/utils";
|
||||
import { GamepadKey } from "@/enums/mkb";
|
||||
import { PrefKey, StorageKey } from "@/enums/pref-keys";
|
||||
@ -683,10 +683,23 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
private async getRecommendedSettings(deviceCode: string): Promise<string | null> {
|
||||
private async getRecommendedSettings(androidInfo: BxFlags['DeviceInfo']['androidInfo']): Promise<string | null> {
|
||||
function normalize(str: string) {
|
||||
return str.toLowerCase()
|
||||
.trim()
|
||||
.replaceAll(/\s+/g, '-')
|
||||
.replaceAll(/-+/g, '-');
|
||||
}
|
||||
|
||||
// Get recommended settings from GitHub
|
||||
try {
|
||||
const response = await NATIVE_FETCH(`https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${deviceCode.toLowerCase()}.json`);
|
||||
let {manufacturer, board, model} = androidInfo!;
|
||||
manufacturer = normalize(manufacturer);
|
||||
board = normalize(board);
|
||||
model = normalize(model);
|
||||
|
||||
const url = `https://raw.githubusercontent.com/redphx/better-xcloud/gh-pages/devices/${manufacturer}/${board}-${model}.json`;
|
||||
const response = await NATIVE_FETCH(url);
|
||||
const json = (await response.json()) as RecommendedSettings;
|
||||
const recommended: PartialRecord<PrefKey, any> = {};
|
||||
|
||||
@ -804,11 +817,17 @@ export class SettingsNavigationDialog extends NavigationDialog {
|
||||
|
||||
if (BX_FLAGS.DeviceInfo.deviceType.includes('android')) {
|
||||
if (BX_FLAGS.DeviceInfo.androidInfo) {
|
||||
const deviceCode = BX_FLAGS.DeviceInfo.androidInfo.board;
|
||||
recommendedDevice = await this.getRecommendedSettings(deviceCode);
|
||||
recommendedDevice = await this.getRecommendedSettings(BX_FLAGS.DeviceInfo.androidInfo);
|
||||
}
|
||||
}
|
||||
// recommendedDevice = await this.getRecommendedSettings('foster_e');
|
||||
|
||||
/*
|
||||
recommendedDevice = await this.getRecommendedSettings({
|
||||
manufacturer: 'Lenovo',
|
||||
board: 'kona',
|
||||
model: 'Lenovo TB-9707F',
|
||||
});
|
||||
*/
|
||||
|
||||
const hasRecommendedSettings = Object.keys(this.suggestedSettings.recommended).length > 0;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { BxLogger } from "./bx-logger";
|
||||
|
||||
type BxFlags = {
|
||||
export type BxFlags = {
|
||||
Debug: boolean;
|
||||
|
||||
CheckForUpdate: boolean;
|
||||
@ -15,7 +15,9 @@ type BxFlags = {
|
||||
userAgent?: string,
|
||||
|
||||
androidInfo?: {
|
||||
manufacturer: string,
|
||||
board: string,
|
||||
model: string,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user