mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-03 06:07:19 +02:00
Lite: disable navigating using gamepad in Settings dialog
This commit is contained in:
parent
d05a68c470
commit
77e0f2d8ba
@ -1,3 +1,5 @@
|
||||
import { isFullVersion } from "@macros/build" with { type: "macro" };
|
||||
|
||||
import { GamepadKey } from "@/enums/gamepad";
|
||||
import { VIRTUAL_GAMEPAD_ID } from "@/modules/mkb/mkb-handler";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
@ -408,9 +410,6 @@ export class NavigationDialogManager {
|
||||
|
||||
BxEventBus.Script.emit('dialog.shown', {});
|
||||
|
||||
// Stop xCloud's navigation polling
|
||||
window.BX_EXPOSED.disableGamepadPolling = true;
|
||||
|
||||
// Lock scroll bar
|
||||
document.body.classList.add('bx-no-scroll');
|
||||
|
||||
@ -437,11 +436,18 @@ export class NavigationDialogManager {
|
||||
this.$container.addEventListener('keydown', this);
|
||||
|
||||
// Start gamepad polling
|
||||
this.startGamepadPolling();
|
||||
if (isFullVersion()) {
|
||||
this.startGamepadPolling();
|
||||
}
|
||||
}
|
||||
|
||||
hide() {
|
||||
this.clearGamepadHoldingInterval();
|
||||
// Stop gamepad polling
|
||||
if (isFullVersion()) {
|
||||
this.clearGamepadHoldingInterval();
|
||||
this.stopGamepadPolling();
|
||||
}
|
||||
|
||||
if (!this.isShowing()) {
|
||||
return;
|
||||
}
|
||||
@ -459,9 +465,6 @@ export class NavigationDialogManager {
|
||||
// Remove event listeners
|
||||
this.$container.removeEventListener('keydown', this);
|
||||
|
||||
// Stop gamepad polling
|
||||
this.stopGamepadPolling();
|
||||
|
||||
// Remove current dialog and everything after it from dialogs stack
|
||||
if (this.dialog) {
|
||||
const dialogIndex = this.dialogsStack.indexOf(this.dialog);
|
||||
@ -473,9 +476,6 @@ export class NavigationDialogManager {
|
||||
// Unmount dialog
|
||||
this.unmountCurrentDialog();
|
||||
|
||||
// Enable xCloud's navigation polling
|
||||
window.BX_EXPOSED.disableGamepadPolling = false;
|
||||
|
||||
// Show the last dialog in dialogs stack
|
||||
if (this.dialogsStack.length) {
|
||||
this.dialogsStack[this.dialogsStack.length - 1].show();
|
||||
@ -639,14 +639,18 @@ export class NavigationDialogManager {
|
||||
}
|
||||
|
||||
private startGamepadPolling() {
|
||||
this.stopGamepadPolling();
|
||||
// Stop xCloud's navigation polling
|
||||
window.BX_EXPOSED.disableGamepadPolling = true;
|
||||
|
||||
this.stopGamepadPolling();
|
||||
this.gamepadPollingIntervalId = window.setInterval(this.pollGamepad, NavigationDialogManager.GAMEPAD_POLLING_INTERVAL);
|
||||
}
|
||||
|
||||
private stopGamepadPolling() {
|
||||
this.gamepadLastStates = [];
|
||||
// Enable xCloud's navigation polling
|
||||
window.BX_EXPOSED.disableGamepadPolling = false;
|
||||
|
||||
this.gamepadLastStates = [];
|
||||
this.gamepadPollingIntervalId && window.clearInterval(this.gamepadPollingIntervalId);
|
||||
this.gamepadPollingIntervalId = null;
|
||||
}
|
||||
|
@ -579,20 +579,20 @@ export class SettingsDialog extends NavigationDialog {
|
||||
}],
|
||||
}];
|
||||
|
||||
private readonly TAB_MKB_ITEMS: (() => Array<SettingTabSection | false>) = () => [
|
||||
isFullVersion() && {
|
||||
private readonly TAB_MKB_ITEMS: (() => Array<SettingTabSection | false>) = isFullVersion() ? () => [
|
||||
{
|
||||
requiredVariants: 'full',
|
||||
group: 'mkb',
|
||||
label: t('mouse-and-keyboard'),
|
||||
helpUrl: 'https://better-xcloud.github.io/mouse-and-keyboard/',
|
||||
items: [
|
||||
isFullVersion() && (($parent: HTMLElement) => {
|
||||
($parent: HTMLElement) => {
|
||||
$parent.appendChild(MkbExtraSettings.renderSettings.apply(this));
|
||||
})
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
isFullVersion() && NativeMkbHandler.isAllowed() && {
|
||||
NativeMkbHandler.isAllowed() && {
|
||||
requiredVariants: 'full',
|
||||
group: 'native-mkb',
|
||||
label: t('native-mkb'),
|
||||
@ -607,7 +607,7 @@ export class SettingsDialog extends NavigationDialog {
|
||||
NativeMkbHandler.getInstance()?.setHorizontalScrollMultiplier(value / 100);
|
||||
},
|
||||
}] : [],
|
||||
}];
|
||||
}] : () => [];
|
||||
|
||||
private readonly TAB_STATS_ITEMS: Array<SettingTabSection | false> = [{
|
||||
group: 'stats',
|
||||
|
Loading…
x
Reference in New Issue
Block a user