Support device shortcuts

This commit is contained in:
redphx 2024-05-25 18:10:22 +07:00
parent 7c206bd079
commit 78021020ce

View File

@ -23,6 +23,7 @@ enum ShortcutAction {
STREAM_VOLUME_INC = 'stream-volume-inc', STREAM_VOLUME_INC = 'stream-volume-inc',
STREAM_VOLUME_DEC = 'stream-volume-dec', STREAM_VOLUME_DEC = 'stream-volume-dec',
DEVICE_SOUND_TOGGLE = 'device-sound-toggle',
DEVICE_VOLUME_INC = 'device-volume-inc', DEVICE_VOLUME_INC = 'device-volume-inc',
DEVICE_VOLUME_DEC = 'device-volume-dec', DEVICE_VOLUME_DEC = 'device-volume-dec',
@ -108,6 +109,14 @@ export class ControllerShortcut {
case ShortcutAction.STREAM_VOLUME_DEC: case ShortcutAction.STREAM_VOLUME_DEC:
SoundShortcut.adjustGainNodeVolume(-10); SoundShortcut.adjustGainNodeVolume(-10);
break; break;
case ShortcutAction.DEVICE_BRIGHTNESS_INC:
case ShortcutAction.DEVICE_BRIGHTNESS_DEC:
case ShortcutAction.DEVICE_SOUND_TOGGLE:
case ShortcutAction.DEVICE_VOLUME_INC:
case ShortcutAction.DEVICE_VOLUME_DEC:
AppInterface && AppInterface.runShortcut && AppInterface.runShortcut(action);
break;
} }
} }
@ -228,6 +237,7 @@ export class ControllerShortcut {
const actions: {[key: string]: Partial<{[key in ShortcutAction]: string | string[]}>} = { const actions: {[key: string]: Partial<{[key in ShortcutAction]: string | string[]}>} = {
[t('device')]: AppInterface && { [t('device')]: AppInterface && {
[ShortcutAction.DEVICE_SOUND_TOGGLE]: [t('sound'), t('toggle')],
[ShortcutAction.DEVICE_VOLUME_INC]: [t('volume'), t('increase')], [ShortcutAction.DEVICE_VOLUME_INC]: [t('volume'), t('increase')],
[ShortcutAction.DEVICE_VOLUME_DEC]: [t('volume'), t('decrease')], [ShortcutAction.DEVICE_VOLUME_DEC]: [t('volume'), t('decrease')],