mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-17 22:25:37 +00:00
CommonHost: Fix volume hotkeys
This commit is contained in:
parent
49b4e1f0a6
commit
679f1a51db
|
@ -87,6 +87,7 @@ float GetOSDScale();
|
|||
/// Adds OSD messages, duration is in seconds.
|
||||
void AddOSDMessage(std::string message, float duration = 2.0f);
|
||||
void AddKeyedOSDMessage(std::string key, std::string message, float duration = 2.0f);
|
||||
void AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration = 2.0f);
|
||||
void AddFormattedOSDMessage(float duration, const char* format, ...);
|
||||
void AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...);
|
||||
void RemoveKeyedOSDMessage(std::string key);
|
||||
|
|
|
@ -918,15 +918,17 @@ DEFINE_HOTKEY("AudioMute", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("Hotke
|
|||
{
|
||||
g_settings.audio_output_muted = !g_settings.audio_output_muted;
|
||||
const s32 volume = System::GetAudioOutputVolume();
|
||||
// g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||
g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||
if (g_settings.audio_output_muted)
|
||||
{
|
||||
Host::AddKeyedOSDMessage("AudioControlHotkey", Host::TranslateStdString("OSDMessage", "Volume: Muted"), 2.0f);
|
||||
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_MUTE,
|
||||
Host::TranslateStdString("OSDMessage", "Volume: Muted"), 5.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
Host::AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, Host::TranslateString("OSDMessage", "Volume: %d%%"),
|
||||
volume);
|
||||
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
|
||||
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume),
|
||||
5.0f);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -935,9 +937,9 @@ DEFINE_HOTKEY("AudioCDAudioMute", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE
|
|||
if (!pressed && System::IsValid())
|
||||
{
|
||||
g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio;
|
||||
Host::AddKeyedOSDMessage("AudioControlHotkey",
|
||||
g_settings.cdrom_mute_cd_audio ?
|
||||
Host::TranslateStdString("OSDMessage", "CD Audio Muted.") :
|
||||
Host::AddIconOSDMessage(
|
||||
"AudioControlHotkey", g_settings.cdrom_mute_cd_audio ? ICON_FA_VOLUME_MUTE : ICON_FA_VOLUME_UP,
|
||||
g_settings.cdrom_mute_cd_audio ? Host::TranslateStdString("OSDMessage", "CD Audio Muted.") :
|
||||
Host::TranslateStdString("OSDMessage", "CD Audio Unmuted."),
|
||||
2.0f);
|
||||
}
|
||||
|
@ -950,9 +952,10 @@ DEFINE_HOTKEY("AudioVolumeUp", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("H
|
|||
const s32 volume = std::min<s32>(System::GetAudioOutputVolume() + 10, 100);
|
||||
g_settings.audio_output_volume = volume;
|
||||
g_settings.audio_fast_forward_volume = volume;
|
||||
// g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||
Host::AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, Host::TranslateString("OSDMessage", "Volume: %d%%"),
|
||||
volume);
|
||||
g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
|
||||
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume),
|
||||
5.0f);
|
||||
}
|
||||
})
|
||||
DEFINE_HOTKEY("AudioVolumeDown", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("Hotkeys", "Volume Down"),
|
||||
|
@ -964,9 +967,10 @@ DEFINE_HOTKEY("AudioVolumeDown", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE(
|
|||
const s32 volume = std::max<s32>(System::GetAudioOutputVolume() - 10, 0);
|
||||
g_settings.audio_output_volume = volume;
|
||||
g_settings.audio_fast_forward_volume = volume;
|
||||
// g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||
Host::AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f,
|
||||
Host::TranslateString("OSDMessage", "Volume: %d%%"), volume);
|
||||
g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||
Host::AddIconOSDMessage(
|
||||
"AudioControlHotkey", ICON_FA_VOLUME_DOWN,
|
||||
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume), 5.0f);
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -573,6 +573,11 @@ void Host::AddFormattedOSDMessage(float duration, const char* format, ...)
|
|||
return AddKeyedOSDMessage(std::string(), std::move(ret), duration);
|
||||
}
|
||||
|
||||
void Host::AddIconOSDMessage(std::string key, const char* icon, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
return AddKeyedOSDMessage(std::move(key), fmt::format("{} {}", icon, message), duration);
|
||||
}
|
||||
|
||||
void Host::AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...)
|
||||
{
|
||||
std::va_list ap;
|
||||
|
|
Loading…
Reference in a new issue