Fix problem with controller in Settings dialog

This commit is contained in:
redphx
2025-01-16 21:50:23 +07:00
parent 0bf4c289db
commit d3ef988af7
4 changed files with 33 additions and 33 deletions

View File

@@ -410,6 +410,9 @@ 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');
@@ -436,18 +439,11 @@ export class NavigationDialogManager {
this.$container.addEventListener('keydown', this);
// Start gamepad polling
if (isFullVersion()) {
this.startGamepadPolling();
}
this.startGamepadPolling();
}
hide() {
// Stop gamepad polling
if (isFullVersion()) {
this.clearGamepadHoldingInterval();
this.stopGamepadPolling();
}
this.clearGamepadHoldingInterval();
if (!this.isShowing()) {
return;
}
@@ -465,6 +461,9 @@ 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);
@@ -476,6 +475,9 @@ 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,18 +641,16 @@ export class NavigationDialogManager {
}
private startGamepadPolling() {
// Stop xCloud's navigation polling
window.BX_EXPOSED.disableGamepadPolling = true;
this.stopGamepadPolling();
this.gamepadPollingIntervalId = window.setInterval(this.pollGamepad, NavigationDialogManager.GAMEPAD_POLLING_INTERVAL);
if (isFullVersion()) {
this.gamepadPollingIntervalId = window.setInterval(this.pollGamepad, NavigationDialogManager.GAMEPAD_POLLING_INTERVAL);
}
}
private stopGamepadPolling() {
// Enable xCloud's navigation polling
window.BX_EXPOSED.disableGamepadPolling = false;
this.gamepadLastStates = [];
this.gamepadPollingIntervalId && window.clearInterval(this.gamepadPollingIntervalId);
this.gamepadPollingIntervalId = null;
}