Detach VIRTUAL_GAMEPAD_ID from EmulatedMkbHandler

This commit is contained in:
redphx 2024-10-01 17:22:33 +07:00
parent 12d8d766dc
commit 8f6bc5cb1b
8 changed files with 1109 additions and 1413 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@ import { GamepadKey } from "@enums/mkb";
import { PrompFont } from "@enums/prompt-font";
import { CE, removeChildElements } from "@utils/html";
import { t } from "@utils/translation";
import { EmulatedMkbHandler } from "./mkb/mkb-handler";
import { StreamStats } from "./stream/stream-stats";
import { MicrophoneShortcut } from "./shortcuts/shortcut-microphone";
import { StreamUiShortcut } from "./shortcuts/shortcut-stream-ui";
@ -15,6 +14,7 @@ import { setNearby } from "@/utils/navigation-utils";
import { PrefKey } from "@/enums/pref-keys";
import { getPref } from "@/utils/settings-storages/global-settings-storage";
import { SettingsNavigationDialog } from "./ui/dialog/settings-dialog";
import { VIRTUAL_GAMEPAD_ID } from "./mkb/mkb-handler";
const enum ShortcutAction {
BETTER_XCLOUD_SETTINGS_SHOW = 'bx-settings-show',
@ -185,7 +185,7 @@ export class ControllerShortcut {
}
// Ignore emulated gamepad
if (gamepad.id === EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID) {
if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
continue;
}

View File

@ -26,6 +26,7 @@ const PointerToMouseButton = {
4: 1,
}
export const VIRTUAL_GAMEPAD_ID = 'Xbox 360 Controller';
class WebSocketMouseDataProvider extends MouseDataProvider {
#pointerClient: PointerClient | undefined
@ -136,10 +137,8 @@ export class EmulatedMkbHandler extends MkbHandler {
static readonly DEFAULT_DEADZONE_COUNTERWEIGHT = 0.01;
static readonly MAXIMUM_STICK_RANGE = 1.1;
static VIRTUAL_GAMEPAD_ID = 'Xbox 360 Controller';
#VIRTUAL_GAMEPAD = {
id: EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID,
id: VIRTUAL_GAMEPAD_ID,
index: 3,
connected: false,
hapticActuators: null,

View File

@ -1,6 +1,6 @@
import { GamepadKey } from "@/enums/mkb";
import { PrefKey } from "@/enums/pref-keys";
import { EmulatedMkbHandler } from "@/modules/mkb/mkb-handler";
import { VIRTUAL_GAMEPAD_ID } from "@/modules/mkb/mkb-handler";
import { BxEvent } from "@/utils/bx-event";
import { STATES } from "@/utils/global";
import { CE, isElementVisible } from "@/utils/html";
@ -263,7 +263,7 @@ export class NavigationDialogManager {
}
// Ignore virtual controller
if (gamepad.id === EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID) {
if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
continue;
}

View File

@ -509,7 +509,7 @@ export class SettingsNavigationDialog extends NavigationDialog {
group: 'mkb',
label: t('virtual-controller'),
helpUrl: 'https://better-xcloud.github.io/mouse-and-keyboard/',
content: MkbRemapper.INSTANCE.render(),
content: isFullVersion() && MkbRemapper.INSTANCE.render(),
}];
private readonly TAB_NATIVE_MKB_ITEMS: Array<SettingTabContent | false> = [{

View File

@ -1,4 +1,4 @@
import { EmulatedMkbHandler } from "@modules/mkb/mkb-handler";
import { VIRTUAL_GAMEPAD_ID } from "@modules/mkb/mkb-handler";
import { t } from "@utils/translation";
import { Toast } from "@utils/toast";
import { BxLogger } from "@utils/bx-logger";
@ -8,7 +8,7 @@ import { getPref } from "./settings-storages/global-settings-storage";
// Show a toast when connecting/disconecting controller
export function showGamepadToast(gamepad: Gamepad) {
// Don't show Toast for virtual controller
if (gamepad.id === EmulatedMkbHandler.VIRTUAL_GAMEPAD_ID) {
if (gamepad.id === VIRTUAL_GAMEPAD_ID) {
return;
}

View File

@ -1,5 +1,3 @@
import { isFullVersion } from "@macros/build" with {type: "macro"};
import { TouchController } from "@/modules/touch-controller";
import { BxEvent } from "./bx-event";
import { SupportedInputType } from "./bx-exposed";