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