From 277c7771214ff07b14bea8954916e5899badc613 Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:08:40 +0700 Subject: [PATCH] Add "Show controller connection status" setting --- src/index.ts | 6 ++++-- src/modules/stream/stream-stats.ts | 3 +-- src/modules/ui/global-settings.ts | 1 + src/utils/preferences.ts | 6 ++++++ src/utils/translation.ts | 1 + 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 926ff67..3503acb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -303,8 +303,10 @@ function main() { disablePwa(); // Show a toast when connecting/disconecting controller - window.addEventListener('gamepadconnected', e => showGamepadToast(e.gamepad)); - window.addEventListener('gamepaddisconnected', e => showGamepadToast(e.gamepad)); + if (getPref(PrefKey.CONTROLLER_SHOW_CONNECTION_STATUS)) { + window.addEventListener('gamepadconnected', e => showGamepadToast(e.gamepad)); + window.addEventListener('gamepaddisconnected', e => showGamepadToast(e.gamepad)); + } // Preload Remote Play if (getPref(PrefKey.REMOTE_PLAY_ENABLED)) { diff --git a/src/modules/stream/stream-stats.ts b/src/modules/stream/stream-stats.ts index e64f474..0e2c260 100644 --- a/src/modules/stream/stream-stats.ts +++ b/src/modules/stream/stream-stats.ts @@ -1,6 +1,5 @@ -import { PrefKey } from "@utils/preferences" +import { PrefKey, getPref } from "@utils/preferences" import { BxEvent } from "@utils/bx-event" -import { getPref } from "@utils/preferences" import { CE } from "@utils/html" import { t } from "@utils/translation" import { STATES } from "@utils/global" diff --git a/src/modules/ui/global-settings.ts b/src/modules/ui/global-settings.ts index a916161..8607456 100644 --- a/src/modules/ui/global-settings.ts +++ b/src/modules/ui/global-settings.ts @@ -89,6 +89,7 @@ const SETTINGS_UI = { items: [ PrefKey.UI_LAYOUT, PrefKey.UI_HOME_CONTEXT_MENU_DISABLED, + PrefKey.CONTROLLER_SHOW_CONNECTION_STATUS, PrefKey.STREAM_SIMPLIFY_MENU, PrefKey.SKIP_SPLASH_VIDEO, !AppInterface && PrefKey.UI_SCROLLBAR_HIDE, diff --git a/src/utils/preferences.ts b/src/utils/preferences.ts index d95815f..9bb62aa 100644 --- a/src/utils/preferences.ts +++ b/src/utils/preferences.ts @@ -45,6 +45,7 @@ export enum PrefKey { CONTROLLER_ENABLE_VIBRATION = 'controller_enable_vibration', CONTROLLER_DEVICE_VIBRATION = 'controller_device_vibration', CONTROLLER_VIBRATION_INTENSITY = 'controller_vibration_intensity', + CONTROLLER_SHOW_CONNECTION_STATUS = 'controller_show_connection_status', NATIVE_MKB_ENABLED = 'native_mkb_enabled', NATIVE_MKB_SCROLL_HORIZONTAL_SENSITIVITY = 'native_mkb_scroll_x_sensitivity', @@ -384,6 +385,11 @@ export class Preferences { }, */ + [PrefKey.CONTROLLER_SHOW_CONNECTION_STATUS]: { + label: t('show-controller-connection-status'), + default: true, + }, + [PrefKey.CONTROLLER_ENABLE_SHORTCUTS]: { default: false, }, diff --git a/src/utils/translation.ts b/src/utils/translation.ts index e7d387b..205ed2e 100644 --- a/src/utils/translation.ts +++ b/src/utils/translation.ts @@ -200,6 +200,7 @@ const Texts = { "sharpness": "Sharpness", "shortcut-keys": "Shortcut keys", "show": "Show", + "show-controller-connection-status": "Show controller connection status", "show-game-art": "Show game art", "show-hide": "Show/hide", "show-stats-on-startup": "Show stats when starting the game",