diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 7f26059d8..db90fd1f9 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -1002,6 +1002,8 @@ void HostInterface::SetDefaultSettings(SettingsInterface& si) si.SetBoolValue("Display", "ShowSpeed", false); si.SetBoolValue("Display", "Fullscreen", false); si.SetBoolValue("Display", "VSync", true); + si.SetStringValue("Display", "SoftwareCursorPath", ""); + si.SetFloatValue("Display", "SoftwareCursorScale", 1.0f); si.SetBoolValue("CDROM", "ReadThread", true); si.SetBoolValue("CDROM", "RegionCheck", true); @@ -1152,6 +1154,21 @@ void HostInterface::UpdateSettings(SettingsInterface& si) if (m_display && m_settings.display_integer_scaling != old_settings.display_integer_scaling) m_display->SetDisplayIntegerScaling(m_settings.display_integer_scaling); + if (m_software_cursor_use_count > 0 && m_display && + (m_settings.display_software_cursor_path != old_settings.display_software_cursor_path || + m_settings.display_software_cursor_scale != old_settings.display_software_cursor_scale)) + { + if (m_settings.display_software_cursor_path.empty()) + { + m_display->ClearSoftwareCursor(); + } + else + { + m_display->SetSoftwareCursor(m_settings.display_software_cursor_path.c_str(), + m_settings.display_software_cursor_scale); + } + } + if (m_settings.log_level != old_settings.log_level || m_settings.log_filter != old_settings.log_filter || m_settings.log_to_console != old_settings.log_to_console || m_settings.log_to_window != old_settings.log_to_window || m_settings.log_to_file != old_settings.log_to_file) @@ -1361,3 +1378,21 @@ bool HostInterface::SaveScreenshot(const char* filename /* = nullptr */, bool fu AddFormattedOSDMessage(5.0f, "Screenshot saved to '%s'.", filename); return true; } + +void HostInterface::EnableSoftwareCursor() +{ + if (m_software_cursor_use_count++ > 0 || m_settings.display_software_cursor_path.empty()) + return; + + m_display->SetSoftwareCursor(m_settings.display_software_cursor_path.c_str(), + m_settings.display_software_cursor_scale); +} + +void HostInterface::DisableSoftwareCursor() +{ + DebugAssert(m_software_cursor_use_count > 0); + if (--m_software_cursor_use_count > 0) + return; + + m_display->ClearSoftwareCursor(); +} diff --git a/src/core/host_interface.h b/src/core/host_interface.h index 0871f8c55..c719de509 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -166,6 +166,12 @@ public: /// Deletes save states for the specified game code. If resume is set, the resume state is deleted too. void DeleteSaveStates(const char* game_code, bool resume); + /// Enables the software cursor. Can be called multiple times, but must be matched by a call to DisableSoftwareCursor(). + void EnableSoftwareCursor(); + + /// Disables the software cursor, preventing it from being renderered. + void DisableSoftwareCursor(); + protected: enum : u32 { @@ -270,6 +276,8 @@ protected: std::deque m_osd_messages; std::mutex m_osd_messages_lock; + u32 m_software_cursor_use_count = 0; + bool m_paused = false; bool m_speed_limiter_temp_disabled = false; bool m_speed_limiter_enabled = false; diff --git a/src/core/namco_guncon.cpp b/src/core/namco_guncon.cpp index ef5c56358..1eeb60a27 100644 --- a/src/core/namco_guncon.cpp +++ b/src/core/namco_guncon.cpp @@ -9,9 +9,15 @@ #include Log_SetChannel(NamcoGunCon); -NamcoGunCon::NamcoGunCon(System* system) : m_system(system) {} +NamcoGunCon::NamcoGunCon(System* system) : m_system(system) +{ + m_system->GetHostInterface()->EnableSoftwareCursor(); +} -NamcoGunCon::~NamcoGunCon() = default; +NamcoGunCon::~NamcoGunCon() +{ + m_system->GetHostInterface()->DisableSoftwareCursor(); +} ControllerType NamcoGunCon::GetType() const { diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 0177ee413..c0cec23ba 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -1,8 +1,8 @@ #include "settings.h" #include "common/string_util.h" #include "host_interface.h" -#include #include +#include Settings::Settings() = default; @@ -53,6 +53,8 @@ void Settings::Load(SettingsInterface& si) display_show_vps = si.GetBoolValue("Display", "ShowVPS", false); display_show_speed = si.GetBoolValue("Display", "ShowSpeed", false); video_sync_enabled = si.GetBoolValue("Display", "VSync", true); + display_software_cursor_path = si.GetStringValue("Display", "SoftwareCursorPath", ""); + display_software_cursor_scale = si.GetFloatValue("Display", "SoftwareCursorScale", 1.0f); cdrom_read_thread = si.GetBoolValue("CDROM", "ReadThread", true); cdrom_region_check = si.GetBoolValue("CDROM", "RegionCheck", true); @@ -143,6 +145,8 @@ void Settings::Save(SettingsInterface& si) const si.SetBoolValue("Display", "ShowVPS", display_show_vps); si.SetBoolValue("Display", "ShowSpeed", display_show_speed); si.SetBoolValue("Display", "VSync", video_sync_enabled); + si.SetStringValue("Display", "SoftwareCursorPath", display_software_cursor_path.c_str()); + si.SetFloatValue("Display", "SoftwareCursorScale", display_software_cursor_scale); si.SetBoolValue("CDROM", "ReadThread", cdrom_read_thread); si.SetBoolValue("CDROM", "RegionCheck", cdrom_region_check); diff --git a/src/core/settings.h b/src/core/settings.h index e7337b954..db93ddc72 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -64,6 +64,8 @@ struct Settings bool display_show_vps = false; bool display_show_speed = false; bool video_sync_enabled = true; + std::string display_software_cursor_path; + float display_software_cursor_scale = 1.0f; bool cdrom_read_thread = true; bool cdrom_region_check = true;