Detect hasTouchSupport based on spoofed User-Agent

This commit is contained in:
redphx 2024-05-11 10:09:10 +07:00
parent 8bee5b2073
commit b866cc95a3

View File

@ -6,12 +6,17 @@ export const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
export const AppInterface = window.AppInterface; export const AppInterface = window.AppInterface;
UserAgent.init(); UserAgent.init();
const userAgent = window.navigator.userAgent.toLowerCase();
const isTv = userAgent.includes('smart-tv') || userAgent.includes('smarttv') || /\baft.*\b/.test(userAgent);
const isVr = window.navigator.userAgent.includes('VR') && window.navigator.userAgent.includes('OculusBrowser');
const hasTouchSupport = !isTv && !isVr && ('ontouchstart' in window || navigator.maxTouchPoints > 0);
export const STATES: BxStates = { export const STATES: BxStates = {
isPlaying: false, isPlaying: false,
appContext: {}, appContext: {},
serverRegions: {}, serverRegions: {},
hasTouchSupport: ('ontouchstart' in window || navigator.maxTouchPoints > 0), hasTouchSupport: hasTouchSupport,
currentStream: {}, currentStream: {},
remotePlay: {}, remotePlay: {},