diff --git a/src/index.ts b/src/index.ts index 62bcd90..74698ce 100644 --- a/src/index.ts +++ b/src/index.ts @@ -173,6 +173,7 @@ window.addEventListener(BxEvent.STREAM_STOPPED, e => { STATES.isPlaying = false; STATES.currentStream = {}; + window.BX_EXPOSED.shouldShowSensorControls = false; // Stop MKB listeners getPref(PrefKey.MKB_ENABLED) && MkbHandler.INSTANCE.destroy(); diff --git a/src/modules/patcher.ts b/src/modules/patcher.ts index 296ca51..0dd9790 100644 --- a/src/modules/patcher.ts +++ b/src/modules/patcher.ts @@ -498,6 +498,18 @@ BxLogger.info('patchRemotePlayMkb', ${configsVar}); return str; }, + patchShowSensorControls(str: string) { + const text = '{shouldShowSensorControls:'; + if (!str.includes(text)) { + return false; + } + + const newCode = `{shouldShowSensorControls: (window.BX_EXPOSED && window.BX_EXPOSED.shouldShowSensorControls) ||`; + + str = str.replace(text, newCode); + return str; + }, + exposeEventTarget(str: string) { const text ='this._eventTarget=new EventTarget'; if (!str.includes(text)) { @@ -513,6 +525,7 @@ window.dispatchEvent(new Event('${BxEvent.STREAM_EVENT_TARGET_READY}')) return str; }, + // Class with: connectAsync(), doConnectAsync(), setPlayClient() exposeStreamSession(str: string) { const text =',this._connectionType='; if (!str.includes(text)) { @@ -520,7 +533,6 @@ window.dispatchEvent(new Event('${BxEvent.STREAM_EVENT_TARGET_READY}')) } const newCode = `; - window.BX_EXPOSED.streamSession = this; const orgSetMicrophoneState = this.setMicrophoneState.bind(this); @@ -588,6 +600,7 @@ let PLAYING_PATCH_ORDERS: PatchArray = [ getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && getPref(PrefKey.STREAM_COMBINE_SOURCES) && 'patchCombinedAudioVideoMediaStream', + STATES.hasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all' && 'patchShowSensorControls', STATES.hasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'all' && 'exposeTouchLayoutManager', STATES.hasTouchSupport && (getPref(PrefKey.STREAM_TOUCH_CONTROLLER) === 'off' || getPref(PrefKey.STREAM_TOUCH_CONTROLLER_AUTO_OFF)) && 'disableTakRenderer', STATES.hasTouchSupport && getPref(PrefKey.STREAM_TOUCH_CONTROLLER_DEFAULT_OPACITY) !== 100 && 'patchTouchControlDefaultOpacity', diff --git a/src/modules/touch-controller.ts b/src/modules/touch-controller.ts index b9ec819..d6d47d9 100644 --- a/src/modules/touch-controller.ts +++ b/src/modules/touch-controller.ts @@ -176,6 +176,9 @@ export class TouchController { layoutChanged && Toast.show(msg, layout.name, {html: html}); window.setTimeout(() => { + // Show gyroscope control in the "More options" dialog if this layout has gyroscope + window.BX_EXPOSED.shouldShowSensorControls = JSON.stringify(layout).includes('gyroscope'); + window.BX_EXPOSED.touchLayoutManager.changeLayoutForScope({ type: 'showLayout', scope: xboxTitleId,