From 99aec0a60c9746c313c4b61eed8bfc8c743d73ae Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:00:47 +0700 Subject: [PATCH] Don't emulate MKB in native MKB supported games --- src/modules/mkb/mkb-handler.ts | 6 ++++-- src/types/index.d.ts | 1 + src/utils/bx-exposed.ts | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/modules/mkb/mkb-handler.ts b/src/modules/mkb/mkb-handler.ts index f89fca7..9aafa29 100644 --- a/src/modules/mkb/mkb-handler.ts +++ b/src/modules/mkb/mkb-handler.ts @@ -9,6 +9,8 @@ import { LocalDb } from "../../utils/local-db"; import { KeyHelper } from "./key-helper"; import type { MkbStoredPreset } from "../../types/mkb"; import { showStreamSettings } from "../stream/stream-ui"; +import { STATES } from "../../utils/global"; +import { UserAgent } from "../../utils/user-agent"; /* This class uses some code from Yuzu emulator to handle mouse's movements @@ -457,9 +459,9 @@ export class MkbHandler { } static setupEvents() { - window.addEventListener(BxEvent.STREAM_PLAYING, () => { + getPref(PrefKey.MKB_ENABLED) && !UserAgent.isMobile() && window.addEventListener(BxEvent.STREAM_PLAYING, () => { // Enable MKB - if (getPref(PrefKey.MKB_ENABLED)) { + if (!STATES.currentStream.titleInfo?.details.hasMkbSupport) { console.log('Emulate MKB'); MkbHandler.INSTANCE.init(); } diff --git a/src/types/index.d.ts b/src/types/index.d.ts index f69a7a5..98cbc9f 100644 --- a/src/types/index.d.ts +++ b/src/types/index.d.ts @@ -57,6 +57,7 @@ type XcloudTitleInfo = { productId: string; supportedInputTypes: InputType[]; hasTouchSupport: boolean; + hasMkbSupport: boolean; }; product: { diff --git a/src/utils/bx-exposed.ts b/src/utils/bx-exposed.ts index 3214575..4aacde0 100644 --- a/src/utils/bx-exposed.ts +++ b/src/utils/bx-exposed.ts @@ -49,7 +49,8 @@ export const BxExposed = { supportedInputTypes = supportedInputTypes.filter(i => i !== 'MKB'); } - // Add custom property + // Pre-check supported input types + titleInfo.details.hasMkbSupport = supportedInputTypes.includes(InputType.MKB); titleInfo.details.hasTouchSupport = supportedInputTypes.includes(InputType.NATIVE_TOUCH) && !supportedInputTypes.includes(InputType.CUSTOM_TOUCH_OVERLAY) && !supportedInputTypes.includes(InputType.GENERIC_TOUCH);