mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-14 17:09:17 +02:00
6.0
This commit is contained in:
0
src/modules/shortcuts/shortcut-microphone.ts → src/modules/shortcuts/microphone-shortcut.ts
Normal file → Executable file
0
src/modules/shortcuts/shortcut-microphone.ts → src/modules/shortcuts/microphone-shortcut.ts
Normal file → Executable file
9
src/modules/shortcuts/shortcut-renderer.ts → src/modules/shortcuts/renderer-shortcut.ts
Normal file → Executable file
9
src/modules/shortcuts/shortcut-renderer.ts → src/modules/shortcuts/renderer-shortcut.ts
Normal file → Executable file
@@ -1,18 +1,21 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { limitVideoPlayerFps } from "../stream/stream-settings-utils";
|
||||
import { BxEvent } from "@/utils/bx-event";
|
||||
|
||||
export class RendererShortcut {
|
||||
static toggleVisibility(): boolean {
|
||||
static toggleVisibility() {
|
||||
const $mediaContainer = document.querySelector('#game-stream div[data-testid="media-container"]');
|
||||
if (!$mediaContainer) {
|
||||
return true;
|
||||
BxEvent.dispatch(window, BxEvent.VIDEO_VISIBILITY_CHANGED, { isShowing: true });
|
||||
return;
|
||||
}
|
||||
|
||||
$mediaContainer.classList.toggle('bx-gone');
|
||||
const isShowing = !$mediaContainer.classList.contains('bx-gone');
|
||||
|
||||
// Switch FPS
|
||||
limitVideoPlayerFps(isShowing ? getPref(PrefKey.VIDEO_MAX_FPS) : 0);
|
||||
return isShowing;
|
||||
BxEvent.dispatch(window, BxEvent.VIDEO_VISIBILITY_CHANGED, { isShowing });
|
||||
}
|
||||
}
|
59
src/modules/shortcuts/shortcut-actions.ts
Executable file
59
src/modules/shortcuts/shortcut-actions.ts
Executable file
@@ -0,0 +1,59 @@
|
||||
import { PrefKey } from "@/enums/pref-keys";
|
||||
import { ShortcutAction } from "@/enums/shortcut-actions";
|
||||
import { AppInterface, STATES } from "@/utils/global";
|
||||
import { getPref } from "@/utils/settings-storages/global-settings-storage";
|
||||
import { t } from "@/utils/translation";
|
||||
|
||||
type ShortcutActions = {
|
||||
[key: string]: {
|
||||
[key in ShortcutAction]?: string[];
|
||||
};
|
||||
};
|
||||
|
||||
export const SHORTCUT_ACTIONS: ShortcutActions = {
|
||||
// Script
|
||||
[t('better-xcloud')]: {
|
||||
[ShortcutAction.BETTER_XCLOUD_SETTINGS_SHOW]: [t('settings'), t('show')],
|
||||
},
|
||||
|
||||
// Device
|
||||
...(!!AppInterface ? {
|
||||
[t('device')]: {
|
||||
[ShortcutAction.DEVICE_SOUND_TOGGLE]: [t('sound'), t('toggle')],
|
||||
[ShortcutAction.DEVICE_VOLUME_INC]: [t('volume'), t('increase')],
|
||||
[ShortcutAction.DEVICE_VOLUME_DEC]: [t('volume'), t('decrease')],
|
||||
|
||||
[ShortcutAction.DEVICE_BRIGHTNESS_INC]: [t('brightness'), t('increase')],
|
||||
[ShortcutAction.DEVICE_BRIGHTNESS_DEC]: [t('brightness'), t('decrease')],
|
||||
},
|
||||
} : {}),
|
||||
|
||||
// Stream
|
||||
[t('stream')]: {
|
||||
[ShortcutAction.STREAM_SCREENSHOT_CAPTURE]: [t('take-screenshot')],
|
||||
[ShortcutAction.STREAM_VIDEO_TOGGLE]: [t('video'), t('toggle')],
|
||||
|
||||
[ShortcutAction.STREAM_SOUND_TOGGLE]: [t('sound'), t('toggle')],
|
||||
|
||||
...(getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) ? {
|
||||
[ShortcutAction.STREAM_VOLUME_INC]: [t('volume'), t('increase')],
|
||||
[ShortcutAction.STREAM_VOLUME_DEC]: [t('volume'), t('decrease')],
|
||||
} : {}),
|
||||
|
||||
[ShortcutAction.STREAM_MENU_SHOW]: [t('menu'), t('show')],
|
||||
[ShortcutAction.STREAM_STATS_TOGGLE]: [t('stats'), t('show-hide')],
|
||||
[ShortcutAction.STREAM_MICROPHONE_TOGGLE]: [t('microphone'), t('toggle')],
|
||||
},
|
||||
|
||||
// MKB
|
||||
...(STATES.browser.capabilities.mkb ? {
|
||||
[t('mouse-and-keyboard')]: {
|
||||
[ShortcutAction.MKB_TOGGLE]: [t('toggle')],
|
||||
},
|
||||
} : {}),
|
||||
|
||||
// Other
|
||||
[t('other')]: {
|
||||
[ShortcutAction.TRUE_ACHIEVEMENTS_OPEN]: [t('true-achievements'), t('show')],
|
||||
},
|
||||
} as const;
|
10
src/modules/shortcuts/shortcut-sound.ts → src/modules/shortcuts/sound-shortcut.ts
Normal file → Executable file
10
src/modules/shortcuts/shortcut-sound.ts → src/modules/shortcuts/sound-shortcut.ts
Normal file → Executable file
@@ -13,11 +13,11 @@ export enum SpeakerState {
|
||||
|
||||
export class SoundShortcut {
|
||||
static adjustGainNodeVolume(amount: number): number {
|
||||
if (!getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL)) {
|
||||
if (!getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const currentValue = getPref(PrefKey.AUDIO_VOLUME);
|
||||
const currentValue = getPref<AudioVolume>(PrefKey.AUDIO_VOLUME);
|
||||
let nearestValue: number;
|
||||
|
||||
if (amount > 0) { // Increase
|
||||
@@ -47,9 +47,9 @@ export class SoundShortcut {
|
||||
}
|
||||
|
||||
static muteUnmute() {
|
||||
if (getPref(PrefKey.AUDIO_ENABLE_VOLUME_CONTROL) && STATES.currentStream.audioGainNode) {
|
||||
if (getPref(PrefKey.AUDIO_VOLUME_CONTROL_ENABLED) && STATES.currentStream.audioGainNode) {
|
||||
const gainValue = STATES.currentStream.audioGainNode.gain.value;
|
||||
const settingValue = getPref(PrefKey.AUDIO_VOLUME);
|
||||
const settingValue = getPref<AudioVolume>(PrefKey.AUDIO_VOLUME);
|
||||
|
||||
let targetValue: number;
|
||||
if (settingValue === 0) { // settingValue is 0 => set to 100
|
||||
@@ -73,7 +73,7 @@ export class SoundShortcut {
|
||||
|
||||
BxEvent.dispatch(window, BxEvent.SPEAKER_STATE_CHANGED, {
|
||||
speakerState: targetValue === 0 ? SpeakerState.MUTED : SpeakerState.ENABLED,
|
||||
})
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
0
src/modules/shortcuts/shortcut-stream-ui.ts → src/modules/shortcuts/stream-ui-shortcut.ts
Normal file → Executable file
0
src/modules/shortcuts/shortcut-stream-ui.ts → src/modules/shortcuts/stream-ui-shortcut.ts
Normal file → Executable file
Reference in New Issue
Block a user