Skip to content

Commit

Permalink
Settings: Remove second source of truth for OSD notifications
Browse files Browse the repository at this point in the history
And split it into warnings/messages. Warnings are always displayed
regardless of the "Show OSD Messages" setting, because they're critical
and users forget they disable messages.
  • Loading branch information
stenzek committed Sep 10, 2024
1 parent 2813b4b commit 20b4581
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 90 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ To download:
You will need a device with armv7 (32-bit ARM), AArch64 (64-bit ARM), or x86_64 (64-bit x86). 64-bit is preferred, the requirements are higher for 32-bit, you'll probably want at least a 1.5GHz CPU.

Download from Google Play: https://play.google.com/store/apps/details?id=com.github.stenzek.duckstation

APK and Beta Downloads: https://www.duckstation.org/android/

**No support is provided for the Android app**, it is free and your expectations should be in line with that. Please **do not** email me about issues about it, or ask for help, you will be ignored.
Expand Down Expand Up @@ -206,16 +207,19 @@ If you wish to use a "portable" build, where the user directory is the same as w
in the same directory as the DuckStation executable.

## Bindings for Qt frontend
Your keyboard or game controller can be used to simulate a variety of PlayStation controllers. Controller input is supported through DInput, XInput, and SDL backends and can be changed through `Settings -> General Settings`.
Your keyboard or game controller can be used to simulate a variety of PlayStation controllers. Controller input is supported through DInput, XInput, and SDL backends and can be changed through `Settings -> Controllers`.

To bind your input device, go to `Settings -> Controllers`. Each of the buttons/axes for the simulated controller will be listed, alongside the corresponding key/button on your device that it is currently bound to. To rebind, click the box next to the button/axis name, and press the key or button on your input device that you wish to bind to. When binding rumble, simply press any button on the controller you wish to send rumble to.
To bind your input device, go to `Settings -> Controllers`, and select the virtual controller you want to map. Automatic mapping handles the majority of ocntrollers. However, if you need to manually bind a controller, click the box below the button/axis name, and press the key or button on your input device that you wish to bind to.

## SDL Game Controller Database
DuckStation releases ship with a database of game controller mappings for the SDL controller backend, courtesy of https://github.com/mdqinc/SDL_GameControllerDB. The included `gamecontrollerdb.txt` file can be found in the `resources` subdirectory of the DuckStation program directory.

If you are experiencing issues binding your controller with the SDL controller backend, you may need to add a custom mapping to the database file. Make a copy of `gamecontrollerdb.txt` and place it in your [user directory](#user-directories) (or directly in the program directory, if running in portable mode) and then follow the instructions in the [SDL_GameControllerDB repository](https://github.com/mdqinc/SDL_GameControllerDB) for creating a new mapping. Add this mapping to the new copy of `gamecontrollerdb.txt` and your controller should then be recognized properly.

## Default bindings

Bindings for controllers and hotkeys can be changed in `Settings -> Controllers`.

Controller 1:
- **Left Stick:** W/A/S/D
- **Right Stick:** T/F/G/H
Expand All @@ -229,6 +233,11 @@ Controller 1:

Hotkeys:
- **Escape:** Open Pause Menu
- **F1:** Load State
- **F2:** Save State
- **F3:** Select Previous Save State
- **F4:** Select Next Save State
- **F10:** Save Screenshot
- **F11:** Toggle Fullscreen
- **Tab:** Temporarily Disable Speed Limiter
- **Space:** Pause/Resume Emulation
Expand Down
6 changes: 3 additions & 3 deletions src/core/game_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
}
else if (settings.gpu_pgxp_enable && settings.gpu_pgxp_vertex_cache)
{
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"gamedb_force_pgxp_vertex_cache", ICON_EMOJI_WARNING,
TRANSLATE_STR(
"GameDatabase",
Expand All @@ -558,7 +558,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
#ifndef __ANDROID__
APPEND_MESSAGE(TRANSLATE_SV("GameDatabase", "PGXP CPU mode enabled."));
#else
Host::AddIconOSDMessage("gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING,
Host::AddIconOSDWarning("gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING,
"This game requires PGXP CPU mode, which increases system requirements.\n"
" If the game runs too slow, disable PGXP for this game.",
Host::OSD_WARNING_DURATION);
Expand All @@ -569,7 +569,7 @@ void GameDatabase::Entry::ApplySettings(Settings& settings, bool display_osd_mes
}
else if (settings.UsingPGXPCPUMode())
{
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"gamedb_force_pgxp_cpu", ICON_EMOJI_WARNING,
TRANSLATE_STR("GameDatabase",
"PGXP CPU mode is enabled, but it is not required for this game. This may cause rendering errors."),
Expand Down
3 changes: 1 addition & 2 deletions src/core/host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ bool Host::CreateGPUDevice(RenderAPI api, Error* error)
return false;
}

if (!ImGuiManager::Initialize(g_settings.display_osd_scale / 100.0f, g_settings.display_show_osd_messages,
&create_error))
if (!ImGuiManager::Initialize(g_settings.display_osd_scale / 100.0f, &create_error))
{
ERROR_LOG("Failed to initialize ImGuiManager: {}", create_error.GetDescription());
Error::SetStringFmt(error, "Failed to initialize ImGuiManager: {}", create_error.GetDescription());
Expand Down
4 changes: 2 additions & 2 deletions src/core/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void Settings::Load(SettingsInterface& si, SettingsInterface& controller_si)
display_active_end_offset = static_cast<s16>(si.GetIntValue("Display", "ActiveEndOffset", 0));
display_line_start_offset = static_cast<s8>(si.GetIntValue("Display", "LineStartOffset", 0));
display_line_end_offset = static_cast<s8>(si.GetIntValue("Display", "LineEndOffset", 0));
display_show_osd_messages = si.GetBoolValue("Display", "ShowOSDMessages", true);
ImGuiManager::SetShowOSDMessages(si.GetBoolValue("Display", "ShowOSDMessages", true));
display_show_fps = si.GetBoolValue("Display", "ShowFPS", false);
display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false);
display_show_gpu_stats = si.GetBoolValue("Display", "ShowGPUStatistics", false);
Expand Down Expand Up @@ -573,7 +573,7 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
si.GetIntValue("Display", "CustomAspectRatioDenominator", display_aspect_ratio_custom_denominator);
if (!ignore_base)
{
si.SetBoolValue("Display", "ShowOSDMessages", display_show_osd_messages);
si.SetBoolValue("Display", "ShowOSDMessages", ImGuiManager::IsShowingOSDMessages());
si.SetBoolValue("Display", "ShowFPS", display_show_fps);
si.SetBoolValue("Display", "ShowSpeed", display_show_speed);
si.SetBoolValue("Display", "ShowResolution", display_show_resolution);
Expand Down
1 change: 0 additions & 1 deletion src/core/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ struct Settings
bool display_disable_mailbox_presentation : 1 = true;
bool display_force_4_3_for_24bit : 1 = false;
bool display_24bit_chroma_smoothing : 1 = false;
bool display_show_osd_messages : 1 = true;
bool display_show_fps : 1 = false;
bool display_show_speed : 1 = false;
bool display_show_gpu_stats : 1 = false;
Expand Down
103 changes: 52 additions & 51 deletions src/core/system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ void System::HandleHostGPUDeviceLost()
std::memcpy(g_vram, vram_backup.data(), VRAM_SIZE);

// First frame after reopening is definitely going to be trash, so skip it.
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"HostGPUDeviceLost", ICON_EMOJI_WARNING,
TRANSLATE_STR("System", "Host GPU device encountered an error and has recovered. This may cause broken rendering."),
Host::OSD_CRITICAL_ERROR_DURATION);
Expand Down Expand Up @@ -1301,7 +1301,7 @@ LayeredSettingsInterface System::GetControllerSettingsLayers(std::unique_lock<st
// Select input profile _or_ game settings, not both.
if (SettingsInterface* isi = Host::Internal::GetInputSettingsLayer())
{
ret.SetLayer(LayeredSettingsInterface::Layer::LAYER_INPUT, Host::Internal::GetInputSettingsLayer());
ret.SetLayer(LayeredSettingsInterface::Layer::LAYER_INPUT, isi);
}
else if (SettingsInterface* gsi = Host::Internal::GetGameSettingsLayer();
gsi && gsi->GetBoolValue("ControllerPorts", "UseGameSettingsForController", false))
Expand Down Expand Up @@ -1332,7 +1332,6 @@ void System::SetDefaultSettings(SettingsInterface& si)
Settings temp;

// we don't want to reset some things (e.g. OSD)
temp.display_show_osd_messages = g_settings.display_show_osd_messages;
temp.display_show_fps = g_settings.display_show_fps;
temp.display_show_speed = g_settings.display_show_speed;
temp.display_show_gpu_stats = g_settings.display_show_gpu_stats;
Expand Down Expand Up @@ -1940,7 +1939,8 @@ void System::DestroySystem()
GDBServer::Shutdown();
#endif

Host::ClearOSDMessages();
// TODO-GPU-THREAD: Needs to be called on GPU thread.
Host::ClearOSDMessages(true);

PostProcessing::Shutdown();

Expand Down Expand Up @@ -2398,7 +2398,7 @@ bool System::DoState(StateWrapper& sw, GPUTexture** host_texture, bool update_di
{
WARNING_LOG("BIOS hash mismatch: System: {} | State: {}", BIOS::ImageInfo::GetHashString(s_bios_hash),
BIOS::ImageInfo::GetHashString(bios_hash));
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"StateBIOSMismatch", ICON_FA_EXCLAMATION_TRIANGLE,
TRANSLATE_STR("System", "This save state was created with a different BIOS. This may cause stability issues."),
Host::OSD_WARNING_DURATION);
Expand Down Expand Up @@ -3934,7 +3934,7 @@ bool System::InsertMedia(const char* path)
std::unique_ptr<CDImage> image = CDImage::Open(path, g_settings.cdrom_load_image_patches, &error);
if (!image)
{
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"DiscInserted", ICON_FA_COMPACT_DISC,
fmt::format(TRANSLATE_FS("OSDMessage", "Failed to open disc image '{}': {}."), path, error.GetDescription()),
Host::OSD_ERROR_DURATION);
Expand Down Expand Up @@ -4473,8 +4473,6 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
{
if (g_settings.display_osd_scale != old_settings.display_osd_scale)
ImGuiManager::SetGlobalScale(g_settings.display_osd_scale / 100.0f);
if (g_settings.display_show_osd_messages != old_settings.display_show_osd_messages)
ImGuiManager::SetShowOSDMessages(g_settings.display_show_osd_messages);
}

bool controllers_updated = false;
Expand Down Expand Up @@ -4600,6 +4598,8 @@ void System::WarnAboutUnsafeSettings()
{
append(ICON_EMOJI_WARNING, TRANSLATE_SV("System", "All enhancements are currently disabled."));

if (ImGuiManager::IsShowingOSDMessages())
{
#define APPEND_SUBMESSAGE(msg) \
do \
{ \
Expand All @@ -4608,47 +4608,48 @@ void System::WarnAboutUnsafeSettings()
messages.append('\n'); \
} while (0)

if (g_settings.cpu_overclock_active)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Overclock disabled."));
if (g_settings.enable_8mb_ram)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "8MB RAM disabled."));
if (g_settings.enable_cheats)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Cheats disabled."));
if (g_settings.gpu_resolution_scale != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Resolution scale set to 1x."));
if (g_settings.gpu_multisamples != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Multisample anti-aliasing disabled."));
if (g_settings.gpu_true_color)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "True color disabled."));
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest ||
g_settings.gpu_sprite_texture_filter != GPUTextureFilter::Nearest)
{
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Texture filtering disabled."));
}
if (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Interlaced rendering enabled."));
if (g_settings.gpu_force_video_timing != ForceVideoTimingMode::Disabled)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Video timings set to default."));
if (g_settings.gpu_widescreen_hack)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Widescreen rendering disabled."));
if (g_settings.display_24bit_chroma_smoothing)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "FMV chroma smoothing disabled."));
if (g_settings.cdrom_read_speedup != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM read speedup disabled."));
if (g_settings.cdrom_seek_speedup != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM seek speedup disabled."));
if (g_settings.cdrom_mute_cd_audio)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Mute CD-ROM audio disabled."));
if (g_settings.texture_replacements.enable_vram_write_replacements)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "VRAM write texture replacements disabled."));
if (g_settings.use_old_mdec_routines)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Use old MDEC routines disabled."));
if (g_settings.pcdrv_enable)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "PCDrv disabled."));
if (g_settings.bios_patch_fast_boot)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Fast boot disabled."));
if (g_settings.cpu_overclock_active)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Overclock disabled."));
if (g_settings.enable_8mb_ram)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "8MB RAM disabled."));
if (g_settings.enable_cheats)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Cheats disabled."));
if (g_settings.gpu_resolution_scale != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Resolution scale set to 1x."));
if (g_settings.gpu_multisamples != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Multisample anti-aliasing disabled."));
if (g_settings.gpu_true_color)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "True color disabled."));
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest ||
g_settings.gpu_sprite_texture_filter != GPUTextureFilter::Nearest)
{
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Texture filtering disabled."));
}
if (g_settings.display_deinterlacing_mode == DisplayDeinterlacingMode::Progressive)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Interlaced rendering enabled."));
if (g_settings.gpu_force_video_timing != ForceVideoTimingMode::Disabled)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Video timings set to default."));
if (g_settings.gpu_widescreen_hack)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Widescreen rendering disabled."));
if (g_settings.display_24bit_chroma_smoothing)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "FMV chroma smoothing disabled."));
if (g_settings.cdrom_read_speedup != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM read speedup disabled."));
if (g_settings.cdrom_seek_speedup != 1)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "CD-ROM seek speedup disabled."));
if (g_settings.cdrom_mute_cd_audio)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Mute CD-ROM audio disabled."));
if (g_settings.texture_replacements.enable_vram_write_replacements)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "VRAM write texture replacements disabled."));
if (g_settings.use_old_mdec_routines)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Use old MDEC routines disabled."));
if (g_settings.pcdrv_enable)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "PCDrv disabled."));
if (g_settings.bios_patch_fast_boot)
APPEND_SUBMESSAGE(TRANSLATE_SV("System", "Fast boot disabled."));

#undef APPEND_SUBMESSAGE
}
}

if (!g_settings.apply_compatibility_settings)
Expand All @@ -4663,11 +4664,11 @@ void System::WarnAboutUnsafeSettings()
messages.pop_back();

LogUnsafeSettingsToConsole(messages);
Host::AddKeyedOSDMessage("performance_settings_warning", std::string(messages.view()), Host::OSD_WARNING_DURATION);
Host::AddKeyedOSDWarning("performance_settings_warning", std::string(messages.view()), Host::OSD_WARNING_DURATION);
}
else
{
Host::RemoveKeyedOSDMessage("performance_settings_warning");
Host::RemoveKeyedOSDWarning("performance_settings_warning");
}
}

Expand Down Expand Up @@ -5214,7 +5215,7 @@ bool System::StartMediaCapture(std::string path, bool capture_video, bool captur
std::string(),
&error))
{
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"MediaCapture", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Failed to create media capture: {0}"), error.GetDescription()),
Host::OSD_ERROR_DURATION);
Expand Down Expand Up @@ -5253,7 +5254,7 @@ void System::StopMediaCapture()
}
else
{
Host::AddIconOSDMessage(
Host::AddIconOSDWarning(
"MediaCapture", ICON_FA_EXCLAMATION_TRIANGLE,
fmt::format(TRANSLATE_FS("System", "Stopped {0}: {1}."),
GetCaptureTypeForMessage(s_media_capture->IsCapturingVideo(), s_media_capture->IsCapturingAudio()),
Expand Down
2 changes: 1 addition & 1 deletion src/duckstation-qt/graphicssettingswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsWindow* dialog, QWidget*
dialog->registerWidgetHelp(
m_ui.stretchDisplayVertically, tr("Stretch Vertically"), tr("Unchecked"),
tr("Prefers stretching the display vertically instead of horizontally, when applying the display aspect ratio."));
dialog->registerWidgetHelp(m_ui.stretchDisplayVertically, tr("Automatically Resize Window"), tr("Unchecked"),
dialog->registerWidgetHelp(m_ui.automaticallyResizeWindow, tr("Automatically Resize Window"), tr("Unchecked"),
tr("Automatically resizes the window to match the internal resolution. <strong>For high "
"internal resolutions, this will create very large windows.</strong>"));
#ifdef _WIN32
Expand Down
Loading

0 comments on commit 20b4581

Please sign in to comment.