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.
|
/// Adds OSD messages, duration is in seconds.
|
||||||
void AddOSDMessage(std::string message, float duration = 2.0f);
|
void AddOSDMessage(std::string message, float duration = 2.0f);
|
||||||
void AddKeyedOSDMessage(std::string key, 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 AddFormattedOSDMessage(float duration, const char* format, ...);
|
||||||
void AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...);
|
void AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...);
|
||||||
void RemoveKeyedOSDMessage(std::string key);
|
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;
|
g_settings.audio_output_muted = !g_settings.audio_output_muted;
|
||||||
const s32 volume = System::GetAudioOutputVolume();
|
const s32 volume = System::GetAudioOutputVolume();
|
||||||
// g_spu.GetOutputStream()->SetOutputVolume(volume);
|
g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||||
if (g_settings.audio_output_muted)
|
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
|
else
|
||||||
{
|
{
|
||||||
Host::AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, Host::TranslateString("OSDMessage", "Volume: %d%%"),
|
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
|
||||||
volume);
|
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume),
|
||||||
|
5.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -935,11 +937,11 @@ DEFINE_HOTKEY("AudioCDAudioMute", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE
|
||||||
if (!pressed && System::IsValid())
|
if (!pressed && System::IsValid())
|
||||||
{
|
{
|
||||||
g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio;
|
g_settings.cdrom_mute_cd_audio = !g_settings.cdrom_mute_cd_audio;
|
||||||
Host::AddKeyedOSDMessage("AudioControlHotkey",
|
Host::AddIconOSDMessage(
|
||||||
g_settings.cdrom_mute_cd_audio ?
|
"AudioControlHotkey", g_settings.cdrom_mute_cd_audio ? ICON_FA_VOLUME_MUTE : ICON_FA_VOLUME_UP,
|
||||||
Host::TranslateStdString("OSDMessage", "CD Audio Muted.") :
|
g_settings.cdrom_mute_cd_audio ? Host::TranslateStdString("OSDMessage", "CD Audio Muted.") :
|
||||||
Host::TranslateStdString("OSDMessage", "CD Audio Unmuted."),
|
Host::TranslateStdString("OSDMessage", "CD Audio Unmuted."),
|
||||||
2.0f);
|
2.0f);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
DEFINE_HOTKEY("AudioVolumeUp", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("Hotkeys", "Volume Up"), [](s32 pressed) {
|
DEFINE_HOTKEY("AudioVolumeUp", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("Hotkeys", "Volume Up"), [](s32 pressed) {
|
||||||
|
@ -950,9 +952,10 @@ DEFINE_HOTKEY("AudioVolumeUp", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("H
|
||||||
const s32 volume = std::min<s32>(System::GetAudioOutputVolume() + 10, 100);
|
const s32 volume = std::min<s32>(System::GetAudioOutputVolume() + 10, 100);
|
||||||
g_settings.audio_output_volume = volume;
|
g_settings.audio_output_volume = volume;
|
||||||
g_settings.audio_fast_forward_volume = volume;
|
g_settings.audio_fast_forward_volume = volume;
|
||||||
// g_spu.GetOutputStream()->SetOutputVolume(volume);
|
g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||||
Host::AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f, Host::TranslateString("OSDMessage", "Volume: %d%%"),
|
Host::AddIconOSDMessage("AudioControlHotkey", ICON_FA_VOLUME_UP,
|
||||||
volume);
|
fmt::format(Host::TranslateString("OSDMessage", "Volume: {}%").GetCharArray(), volume),
|
||||||
|
5.0f);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
DEFINE_HOTKEY("AudioVolumeDown", TRANSLATABLE("Hotkeys", "Audio"), TRANSLATABLE("Hotkeys", "Volume Down"),
|
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);
|
const s32 volume = std::max<s32>(System::GetAudioOutputVolume() - 10, 0);
|
||||||
g_settings.audio_output_volume = volume;
|
g_settings.audio_output_volume = volume;
|
||||||
g_settings.audio_fast_forward_volume = volume;
|
g_settings.audio_fast_forward_volume = volume;
|
||||||
// g_spu.GetOutputStream()->SetOutputVolume(volume);
|
g_spu.GetOutputStream()->SetOutputVolume(volume);
|
||||||
Host::AddKeyedFormattedOSDMessage("AudioControlHotkey", 2.0f,
|
Host::AddIconOSDMessage(
|
||||||
Host::TranslateString("OSDMessage", "Volume: %d%%"), volume);
|
"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);
|
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, ...)
|
void Host::AddKeyedFormattedOSDMessage(std::string key, float duration, const char* format, ...)
|
||||||
{
|
{
|
||||||
std::va_list ap;
|
std::va_list ap;
|
||||||
|
|
Loading…
Reference in a new issue