mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-05 12:56:42 +02:00
Refactor browser & userAgent's capabilities
This commit is contained in:
@@ -34,7 +34,7 @@ export const BxExposed = {
|
||||
|
||||
titleInfo.details.hasMkbSupport = supportedInputTypes.includes(InputType.MKB);
|
||||
|
||||
if (STATES.userAgentHasTouchSupport) {
|
||||
if (STATES.userAgent.capabilities.touch) {
|
||||
let touchControllerAvailability = getPref(PrefKey.STREAM_TOUCH_CONTROLLER);
|
||||
|
||||
// Disable touch control when gamepad found
|
||||
|
@@ -16,8 +16,19 @@ export const STATES: BxStates = {
|
||||
isPlaying: false,
|
||||
appContext: {},
|
||||
serverRegions: {},
|
||||
userAgentHasTouchSupport: userAgentHasTouchSupport,
|
||||
browserHasTouchSupport: browserHasTouchSupport,
|
||||
|
||||
browser: {
|
||||
capabilities: {
|
||||
touch: browserHasTouchSupport,
|
||||
batteryApi: 'getBattery' in window.navigator,
|
||||
},
|
||||
},
|
||||
|
||||
userAgent: {
|
||||
capabilities: {
|
||||
touch: userAgentHasTouchSupport,
|
||||
}
|
||||
},
|
||||
|
||||
currentStream: {},
|
||||
remotePlay: {},
|
||||
|
@@ -595,7 +595,7 @@ export function interceptHttpRequests() {
|
||||
}
|
||||
|
||||
// Add list of games with custom layouts to the official list
|
||||
if (STATES.userAgentHasTouchSupport && url.includes('catalog.gamepass.com/sigls/')) {
|
||||
if (STATES.userAgent.capabilities.touch && url.includes('catalog.gamepass.com/sigls/')) {
|
||||
const response = await NATIVE_FETCH(request, init);
|
||||
const obj = await response.clone().json();
|
||||
|
||||
|
@@ -268,7 +268,7 @@ export class Preferences {
|
||||
all: t('tc-all-games'),
|
||||
off: t('off'),
|
||||
},
|
||||
unsupported: !STATES.userAgentHasTouchSupport,
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
ready: (setting: PreferenceSetting) => {
|
||||
if (setting.unsupported) {
|
||||
setting.default = 'default';
|
||||
@@ -278,7 +278,7 @@ export class Preferences {
|
||||
[PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF]: {
|
||||
label: t('tc-auto-off'),
|
||||
default: false,
|
||||
unsupported: !STATES.userAgentHasTouchSupport,
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
[PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY]: {
|
||||
type: SettingElementType.NUMBER_STEPPER,
|
||||
@@ -292,7 +292,7 @@ export class Preferences {
|
||||
ticks: 10,
|
||||
hideSlider: true,
|
||||
},
|
||||
unsupported: !STATES.userAgentHasTouchSupport,
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_STANDARD]: {
|
||||
label: t('tc-standard-layout-style'),
|
||||
@@ -302,7 +302,7 @@ export class Preferences {
|
||||
white: t('tc-all-white'),
|
||||
muted: t('tc-muted-colors'),
|
||||
},
|
||||
unsupported: !STATES.userAgentHasTouchSupport,
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
[PrefKey.STREAM_TOUCH_CONTROLLER_STYLE_CUSTOM]: {
|
||||
label: t('tc-custom-layout-style'),
|
||||
@@ -311,7 +311,7 @@ export class Preferences {
|
||||
default: t('default'),
|
||||
muted: t('tc-muted-colors'),
|
||||
},
|
||||
unsupported: !STATES.userAgentHasTouchSupport,
|
||||
unsupported: !STATES.userAgent.capabilities.touch,
|
||||
},
|
||||
|
||||
[PrefKey.STREAM_SIMPLIFY_MENU]: {
|
||||
@@ -554,7 +554,7 @@ export class Preferences {
|
||||
|
||||
[PrefKey.UI_HOME_CONTEXT_MENU_DISABLED]: {
|
||||
label: t('disable-home-context-menu'),
|
||||
default: STATES.browserHasTouchSupport,
|
||||
default: STATES.browser.capabilities.touch,
|
||||
},
|
||||
|
||||
[PrefKey.BLOCK_SOCIAL_FEATURES]: {
|
||||
|
@@ -24,7 +24,7 @@ export function overridePreloadState() {
|
||||
}
|
||||
|
||||
// Add list of games with custom layouts to the official list
|
||||
if (STATES.userAgentHasTouchSupport) {
|
||||
if (STATES.userAgent.capabilities.touch) {
|
||||
try {
|
||||
const sigls = state.xcloud.sigls;
|
||||
if (GamePassCloudGallery.TOUCH in sigls) {
|
||||
|
Reference in New Issue
Block a user