Widescreen Hotkey (#2080)
* Widescreen Hotkey Added the ability to toggle Widescreen Hack and set the Aspect Ratio via a hotkey. This is in response to Discussion #1912 (https://github.com/stenzek/duckstation/discussions/1912) * Widescreen Hotkey Uses Settings The Widescreen Hotkey now looks at the user's global or game settings when toggling. This means: When disabling the widescreen hack it uses a non-wide ratio as set by the user if available or auto if unavailable. When enabling the widescreen hack it uses a wide ratio as set by the user if available or 16:9 if unavailable. * Avoids loading the entire settings now. Specifically loads the aspect ratio setting.
This commit is contained in:
parent
d77dfb4b23
commit
057c264d97
|
@ -12,10 +12,12 @@
|
|||
#include "core/cpu_code_cache.h"
|
||||
#include "core/dma.h"
|
||||
#include "core/gpu.h"
|
||||
#include "core/gte.h"
|
||||
#include "core/host_display.h"
|
||||
#include "core/mdec.h"
|
||||
#include "core/pgxp.h"
|
||||
#include "core/save_state_version.h"
|
||||
#include "core/settings.h"
|
||||
#include "core/spu.h"
|
||||
#include "core/system.h"
|
||||
#include "core/texture_replacements.h"
|
||||
|
@ -2039,6 +2041,14 @@ void CommonHostInterface::RegisterGraphicsHotkeys()
|
|||
g_texture_replacements.Reload();
|
||||
}
|
||||
});
|
||||
|
||||
RegisterHotkey(StaticString(TRANSLATABLE("Hotkeys", "Graphics")), StaticString("ToggleWidescreen"),
|
||||
StaticString(TRANSLATABLE("Hotkeys", "Toggle Widescreen")), [this](bool pressed) {
|
||||
if (pressed && System::IsValid())
|
||||
{
|
||||
ToggleWidescreen();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void CommonHostInterface::RegisterSaveStateHotkeys()
|
||||
|
@ -3344,6 +3354,31 @@ void CommonHostInterface::ReloadPostProcessingShaders()
|
|||
AddOSDMessage(TranslateStdString("OSDMessage", "Post-processing shaders reloaded."), 10.0f);
|
||||
}
|
||||
|
||||
void CommonHostInterface::ToggleWidescreen()
|
||||
{
|
||||
g_settings.gpu_widescreen_hack = !g_settings.gpu_widescreen_hack;
|
||||
const GameSettings::Entry* gs = m_game_list->GetGameSettings(System::GetRunningPath(), System::GetRunningCode());
|
||||
DisplayAspectRatio userRatio;
|
||||
if (gs && gs->display_aspect_ratio.has_value())
|
||||
userRatio = gs->display_aspect_ratio.value();
|
||||
else
|
||||
userRatio = Settings::ParseDisplayAspectRatio(
|
||||
m_settings_interface
|
||||
->GetStringValue("Display", "AspectRatio", Settings::GetDisplayAspectRatioName(DisplayAspectRatio::Auto))
|
||||
.c_str())
|
||||
.value_or(DisplayAspectRatio::Auto);
|
||||
if (userRatio == DisplayAspectRatio::Auto || userRatio == DisplayAspectRatio::PAR1_1 || userRatio == DisplayAspectRatio::R4_3)
|
||||
g_settings.display_aspect_ratio = g_settings.gpu_widescreen_hack ? DisplayAspectRatio::R16_9 : userRatio;
|
||||
else
|
||||
g_settings.display_aspect_ratio = g_settings.gpu_widescreen_hack ? userRatio : DisplayAspectRatio::Auto;
|
||||
|
||||
String arMessage;
|
||||
arMessage.AppendFormattedString("Widescreen Hack is now %s and aspect ratio set to %s.", g_settings.gpu_widescreen_hack ? "enabled" : "disabled", Settings::GetDisplayAspectRatioName(g_settings.display_aspect_ratio));
|
||||
AddOSDMessage(TranslateStdString("OSDMessage", arMessage), 5.0f);
|
||||
|
||||
GTE::UpdateAspectRatio();
|
||||
}
|
||||
|
||||
bool CommonHostInterface::ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height,
|
||||
float* refresh_rate)
|
||||
{
|
||||
|
|
|
@ -269,6 +269,9 @@ public:
|
|||
/// Reloads post processing shaders with the current configuration.
|
||||
void ReloadPostProcessingShaders();
|
||||
|
||||
/// Toggle Widescreen Hack and Aspect Ratio
|
||||
void ToggleWidescreen();
|
||||
|
||||
/// Parses a fullscreen mode into its components (width * height @ refresh hz)
|
||||
static bool ParseFullscreenMode(const std::string_view& mode, u32* width, u32* height, float* refresh_rate);
|
||||
|
||||
|
|
Loading…
Reference in New Issue