Move emu callbacks to own file

Reduces some System.h includes
This commit is contained in:
Megamouse
2026-09-15 22:01:55 +02:00
parent 1b3e02044f
commit be509deda0
47 changed files with 325 additions and 305 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
#include "version.h"
#include "Emu/IdManager.h"
#include "Emu/Memory/vm.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/VFS.h"
@@ -1387,7 +1388,7 @@ static usz apply_modification(std::vector<u32>& applied, patch_engine::patch_inf
if (exec_addr)
{
Emu.GetCallbacks().add_breakpoint(exec_addr);
g_emu_callbacks.add_breakpoint(exec_addr);
}
break;
+3 -3
View File
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "audio_utils.h"
#include "Emu/system_config.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Emu/IdManager.h"
#include "Emu/RSX/Overlays/overlay_message.h"
#include <cmath>
@@ -17,7 +17,7 @@ namespace audio
{
audio_fxo& fxo = g_fxo->get<audio_fxo>();
fxo.audio_muted = !fxo.audio_muted;
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
rsx::overlays::queue_message(fxo.audio_muted ? localized_string_id::AUDIO_MUTED : localized_string_id::AUDIO_UNMUTED, 3'000'000);
}
@@ -50,7 +50,7 @@ namespace audio
return;
g_cfg.audio.volume.set(std::clamp<s32>(new_volume, g_cfg.audio.volume.min, g_cfg.audio.volume.max));
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
rsx::overlays::queue_message(localized_string(localized_string_id::AUDIO_CHANGED, "%d%%", g_cfg.audio.volume.get()), 3'000'000, {}, rsx::overlays::message_pin_location::top_left, {}, true, true);
}
+2 -1
View File
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/Audio/audio_utils.h"
@@ -63,7 +64,7 @@ void cell_audio_config::reset(bool backend_changed)
if (!backend || backend_changed)
{
backend.reset();
backend = Emu.GetCallbacks().get_audio();
backend = g_emu_callbacks.get_audio();
}
cellAudio.notice("cellAudio initializing. Backend: %s", backend->GetName());
+2 -1
View File
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "cellCamera.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/Cell/PPUModule.h"
@@ -1770,7 +1771,7 @@ bool camera_context::open_camera()
Emu.BlockingCallFromMainThread([this]()
{
handler.reset();
handler = Emu.GetCallbacks().get_camera_handler();
handler = g_emu_callbacks.get_camera_handler();
if (handler)
{
handler->open_camera();
+13 -12
View File
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Emu/localized_string.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_utils.hpp"
#include "Emu/VFS.h"
@@ -241,14 +242,14 @@ static bool check_system_ver(vm::cptr<char> systemVersion)
disc_change_manager::disc_change_manager()
{
Emu.GetCallbacks().enable_disc_eject(false);
Emu.GetCallbacks().enable_disc_insert(false);
g_emu_callbacks.enable_disc_eject(false);
g_emu_callbacks.enable_disc_insert(false);
}
disc_change_manager::~disc_change_manager()
{
Emu.GetCallbacks().enable_disc_eject(false);
Emu.GetCallbacks().enable_disc_insert(false);
g_emu_callbacks.enable_disc_eject(false);
g_emu_callbacks.enable_disc_insert(false);
}
error_code disc_change_manager::register_callbacks(vm::ptr<CellGameDiscEjectCallback> func_eject, vm::ptr<CellGameDiscInsertCallback> func_insert)
@@ -265,8 +266,8 @@ error_code disc_change_manager::register_callbacks(vm::ptr<CellGameDiscEjectCall
state = is_disc_mounted ? eject_state::inserted : eject_state::ejected;
}
Emu.GetCallbacks().enable_disc_eject(!!func_eject && is_disc_mounted);
Emu.GetCallbacks().enable_disc_insert(!!func_insert && !is_disc_mounted);
g_emu_callbacks.enable_disc_eject(!!func_eject && is_disc_mounted);
g_emu_callbacks.enable_disc_insert(!!func_insert && !is_disc_mounted);
return CELL_OK;
}
@@ -278,8 +279,8 @@ error_code disc_change_manager::unregister_callbacks()
eject_callback = vm::null;
insert_callback = vm::null;
Emu.GetCallbacks().enable_disc_eject(false);
Emu.GetCallbacks().enable_disc_insert(false);
g_emu_callbacks.enable_disc_eject(false);
g_emu_callbacks.enable_disc_insert(false);
};
if (is_inserting)
@@ -310,7 +311,7 @@ void disc_change_manager::eject_disc()
}
state = eject_state::busy;
Emu.GetCallbacks().enable_disc_eject(false);
g_emu_callbacks.enable_disc_eject(false);
ensure(eject_callback);
@@ -327,7 +328,7 @@ void disc_change_manager::eject_disc()
dcm.state = eject_state::ejected;
// Re-enable disc insertion only if the callback is still registered
Emu.GetCallbacks().enable_disc_insert(!!dcm.insert_callback);
g_emu_callbacks.enable_disc_insert(!!dcm.insert_callback);
return CELL_OK;
});
@@ -346,7 +347,7 @@ void disc_change_manager::insert_disc(u32 disc_type, std::string title_id)
}
state = eject_state::busy;
Emu.GetCallbacks().enable_disc_insert(false);
g_emu_callbacks.enable_disc_insert(false);
ensure(insert_callback);
@@ -372,7 +373,7 @@ void disc_change_manager::insert_disc(u32 disc_type, std::string title_id)
dcm.state = eject_state::inserted;
// Re-enable disc ejection only if the callback is still registered
Emu.GetCallbacks().enable_disc_eject(!!dcm.eject_callback);
g_emu_callbacks.enable_disc_eject(!!dcm.eject_callback);
dcm.is_inserting = false;
+2 -1
View File
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/PPUThread.h"
@@ -75,7 +76,7 @@ struct msg_info
return nullptr;
}
dlg = Emu.GetCallbacks().get_msg_dialog();
dlg = g_emu_callbacks.get_msg_dialog();
return dlg;
}
+2 -2
View File
@@ -4,7 +4,7 @@
#include "Emu/Cell/lv2/sys_lwcond.h"
#include "Emu/Cell/lv2/sys_spu.h"
#include "Emu/Io/music_handler_base.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Emu/VFS.h"
#include "Emu/RSX/Overlays/overlay_media_list_dialog.h"
#include "cellSearch.h"
@@ -79,7 +79,7 @@ public:
music_state()
{
handler = Emu.GetCallbacks().get_music_handler();
handler = g_emu_callbacks.get_music_handler();
handler->set_event_status_callback([this](u32 status)
{
if (!func)
+2 -1
View File
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/Cell/Modules/sysPrxForUser.h"
@@ -141,7 +142,7 @@ std::shared_ptr<OskDialogBase> _get_osk_dialog(bool create)
}
else
{
osk.dlg = Emu.GetCallbacks().get_osk_dialog();
osk.dlg = g_emu_callbacks.get_osk_dialog();
}
return osk.dlg;
+2 -2
View File
@@ -1,7 +1,7 @@
#include "stdafx.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/VFS.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "cellSysutil.h"
LOG_CHANNEL(cellPhotoDecode);
@@ -160,7 +160,7 @@ error_code cellPhotoDecodeFromFile(vm::cptr<char> srcHddDir, vm::cptr<char> srcH
s32 width{};
s32 height{};
if (!Emu.GetCallbacks().get_scaled_image(path, set_param->width, set_param->height, width, height, static_cast<u8*>(set_param->dstBuffer.get_ptr()), false))
if (!g_emu_callbacks.get_scaled_image(path, set_param->width, set_param->height, width, height, static_cast<u8*>(set_param->dstBuffer.get_ptr()), false))
{
cellPhotoDecode.error("Failed to decode '%s'", path);
return CELL_PHOTO_DECODE_ERROR_DECODE;
+2 -1
View File
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/VFS.h"
@@ -117,7 +118,7 @@ std::string get_available_photo_path(std::string_view filename)
extension = filename.substr(extension_start);
}
return Emu.GetCallbacks().get_photo_path(fmt::format("%s%s", Emu.GetTitle(), extension));
return g_emu_callbacks.get_photo_path(fmt::format("%s%s", Emu.GetTitle(), extension));
}
+3 -2
View File
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/VFS.h"
#include "Emu/IdManager.h"
@@ -321,7 +322,7 @@ static error_code select_and_delete(ppu_thread& ppu)
lv2_obj::sleep(ppu);
// Display a blocking Save Data List asynchronously in the GUI thread.
if (auto save_dialog = Emu.GetCallbacks().get_save_dialog())
if (auto save_dialog = g_emu_callbacks.get_save_dialog())
{
selected = save_dialog->ShowSaveDataList(base_dir, save_entries, focused, SAVEDATA_OP_LIST_DELETE, vm::null, g_fxo->get<savedata_manager>().enable_overlay);
}
@@ -1237,7 +1238,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
lv2_obj::sleep(ppu);
// Display a blocking Save Data List asynchronously in the GUI thread.
if (auto save_dialog = Emu.GetCallbacks().get_save_dialog())
if (auto save_dialog = g_emu_callbacks.get_save_dialog())
{
selected = save_dialog->ShowSaveDataList(base_dir, save_entries, focused, operation, listSet, g_fxo->get<savedata_manager>().enable_overlay);
}
+3 -2
View File
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_utils.hpp"
#include "Emu/Cell/PPUModule.h"
@@ -1434,7 +1435,7 @@ error_code sceNpBasicSendMessageGui(ppu_thread& ppu, vm::cptr<SceNpBasicMessageD
Emu.BlockingCallFromMainThread([=, &result, msg_data = std::move(msg_data), npids = std::move(npids)]() mutable
{
auto send_dlg = Emu.GetCallbacks().get_sendmessage_dialog();
auto send_dlg = g_emu_callbacks.get_sendmessage_dialog();
result = send_dlg->Exec(msg_data, npids);
});
@@ -1618,7 +1619,7 @@ error_code recv_message_gui(ppu_thread& ppu, u16 mainType, u32 recvOptions)
Emu.BlockingCallFromMainThread([=, &result, &recv_result, &chosen_msg_id]()
{
auto recv_dlg = Emu.GetCallbacks().get_recvmessage_dialog();
auto recv_dlg = g_emu_callbacks.get_recvmessage_dialog();
result = recv_dlg->Exec(static_cast<SceNpBasicMessageMainType>(mainType), static_cast<SceNpBasicMessageRecvOptions>(recvOptions), recv_result, chosen_msg_id);
});
+2 -1
View File
@@ -1,4 +1,5 @@
#include "stdafx.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/VFS.h"
@@ -278,7 +279,7 @@ static void show_trophy_notification(const trophy_context_t* ctxt, s32 trophyId)
sceNpTrophy.error("Failed to get info for trophy dialog. Error code 0x%x", +ret);
}
if (auto trophy_notification_dialog = Emu.GetCallbacks().get_trophy_notification_dialog())
if (auto trophy_notification_dialog = g_emu_callbacks.get_trophy_notification_dialog())
{
trophy_notification_dialog->ShowTrophyNotification(details, trophy_icon_data);
}
+2 -1
View File
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "Emu/Memory/vm.h"
#include "Emu/IdManager.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/Audio/audio_utils.h"
@@ -1750,7 +1751,7 @@ void rsxaudio_backend_thread::backend_init(const rsxaudio_state& ra_state, const
if (reset_backend || !backend)
{
backend = nullptr;
backend = Emu.GetCallbacks().get_audio();
backend = g_emu_callbacks.get_audio();
backend->SetWriteCallback(std::bind(&rsxaudio_backend_thread::write_data_callback, this, std::placeholders::_1, std::placeholders::_2));
backend->SetStateCallback(std::bind(&rsxaudio_backend_thread::state_changed_callback, this, std::placeholders::_1));
}
+2 -2
View File
@@ -1,11 +1,11 @@
#include "stdafx.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "GSRender.h"
GSRender::GSRender(utils::serial* ar) noexcept : rsx::thread(ar)
{
if (auto gs_frame = Emu.GetCallbacks().get_gs_frame())
if (auto gs_frame = g_emu_callbacks.get_gs_frame())
{
m_frame = gs_frame.release();
}
@@ -3,6 +3,7 @@
#include "overlay_friends_list_dialog.h"
#include "Emu/NP/np_handler.h"
#include "Emu/NP/rpcn_config.h"
#include "Emu/System.h"
#include "Emu/vfs_config.h"
namespace rsx
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "overlay_home_menu.h"
#include "../overlay_manager.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Utilities/date_time.h"
@@ -5,7 +5,7 @@
#include "Emu/RSX/Overlays/overlay_select.h"
#include "Emu/RSX/Overlays/overlay_slider.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Utilities/Config.h"
#include "overlay_home_icons.h"
@@ -125,7 +125,7 @@ namespace rsx
{
for (size_t index = 0; index < setting->size(); index++)
{
auto translated = Emu.GetCallbacks().get_localized_setting(home_menu_setting<T, cfg::_enum<T>>::m_setting, static_cast<u32>(index));
auto translated = g_emu_callbacks.get_localized_setting(home_menu_setting<T, cfg::_enum<T>>::m_setting, static_cast<u32>(index));
m_options.emplace_back(std::move(translated));
}
}
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "overlay_home_menu_page.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Emu/system_config.h"
namespace rsx
@@ -238,7 +238,7 @@ namespace rsx
if (m_config_changed && *m_config_changed)
{
g_cfg.from_string(g_backup_cfg.to_string());
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
*m_config_changed = false;
refresh();
}
@@ -253,7 +253,7 @@ namespace rsx
show_dialog(get_localized_string(localized_string_id::HOME_MENU_SETTINGS_SAVE), [this]()
{
rsx_log.notice("home_menu_page: saving settings...");
Emu.GetCallbacks().save_emu_settings();
g_emu_callbacks.save_emu_settings();
if (m_config_changed)
{
@@ -1,10 +1,10 @@
#include "stdafx.h"
#include "overlay_home_menu_savestate.h"
#include "overlay_home_menu_components.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/savestate_utils.hpp"
namespace rsx
{
namespace overlays
@@ -3,7 +3,7 @@
#include "overlay_home_menu_page.h"
#include "../overlay_tabs.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Utilities/Config.h"
namespace rsx
@@ -60,7 +60,7 @@ namespace rsx
{
rsx_log.notice("User toggled checkbox in '%s'. Setting '%s' to %d", title, setting->get_name(), value);
setting->set(value);
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
if (m_config_changed) *m_config_changed = true;
refresh();
}
@@ -146,7 +146,7 @@ namespace rsx
if (next_value != previous)
{
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
if (m_config_changed)
{
*m_config_changed = true;
@@ -204,7 +204,7 @@ namespace rsx
{
rsx_log.notice("User toggled signed slider in '%s'. Setting '%s' to %d", title, setting->get_name(), value);
setting->set(value);
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
if (m_config_changed) *m_config_changed = true;
refresh();
}
@@ -258,7 +258,7 @@ namespace rsx
{
rsx_log.notice("User toggled unsigned slider in '%s'. Setting '%s' to %d", title, setting->get_name(), value);
setting->set(value);
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
if (m_config_changed) *m_config_changed = true;
refresh();
}
@@ -303,7 +303,7 @@ namespace rsx
{
rsx_log.notice("User toggled float slider in '%s'. Setting '%s' to %.2f", title, setting->get_name(), value);
setting->set(value);
Emu.GetCallbacks().update_emu_settings();
g_emu_callbacks.update_emu_settings();
if (m_config_changed) *m_config_changed = true;
refresh();
}
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "shader_loading_dialog.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/Cell/Modules/cellMsgDialog.h"
@@ -9,7 +10,7 @@ namespace rsx
{
void shader_loading_dialog::create(const std::string& msg, const std::string& title)
{
dlg = Emu.GetCallbacks().get_msg_dialog();
dlg = g_emu_callbacks.get_msg_dialog();
if (dlg)
{
dlg->type.se_normal = true;
+2 -2
View File
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "overlay_audio.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
namespace rsx
{
@@ -15,7 +15,7 @@ namespace rsx
{
if (audio_path.empty()) return;
m_video_source = ensure(Emu.GetCallbacks().make_video_source());
m_video_source = ensure(g_emu_callbacks.make_video_source());
m_video_source->set_audio_path(audio_path, audio_in_archive);
if (audio_in_archive)
+2 -2
View File
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "overlay_fonts.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Emu/vfs_config.h"
#ifndef _WIN32
@@ -108,7 +108,7 @@ namespace rsx
glyph_load_setup result;
result.font_names.push_back(font_name);
const std::vector<std::string> font_dirs = Emu.GetCallbacks().get_font_dirs();
const std::vector<std::string> font_dirs = g_emu_callbacks.get_font_dirs();
result.lookup_font_dirs.insert(result.lookup_font_dirs.end(), font_dirs.begin(), font_dirs.end());
// Search dev_flash for the font too
result.lookup_font_dirs.push_back(g_cfg_vfs.get_dev_flash() + "data/font/");
@@ -1,6 +1,7 @@
#include "stdafx.h"
#include "overlay_manager.h"
#include "overlay_message_dialog.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/system_utils.hpp"
@@ -187,7 +188,7 @@ namespace rsx
{
if (num_progress_bars > 0)
{
Emu.GetCallbacks().handle_taskbar_progress(0, 1);
g_emu_callbacks.handle_taskbar_progress(0, 1);
}
user_interface::close(use_callback, stop_pad_interception);
@@ -451,7 +452,7 @@ namespace rsx
::at32(progress_bars, index).inc(value);
if (index == static_cast<u32>(taskbar_index) || taskbar_index == -1)
Emu.GetCallbacks().handle_taskbar_progress(1, static_cast<s32>(value));
g_emu_callbacks.handle_taskbar_progress(1, static_cast<s32>(value));
return CELL_OK;
}
@@ -464,7 +465,7 @@ namespace rsx
::at32(progress_bars, index).set_value(value);
if (index == static_cast<u32>(taskbar_index) || taskbar_index == -1)
Emu.GetCallbacks().handle_taskbar_progress(3, static_cast<s32>(value));
g_emu_callbacks.handle_taskbar_progress(3, static_cast<s32>(value));
return CELL_OK;
}
@@ -476,7 +477,7 @@ namespace rsx
::at32(progress_bars, index).set_value(0.f);
Emu.GetCallbacks().handle_taskbar_progress(0, 0);
g_emu_callbacks.handle_taskbar_progress(0, 0);
return CELL_OK;
}
@@ -491,12 +492,12 @@ namespace rsx
if (index == static_cast<u32>(taskbar_index))
{
taskbar_limit = limit;
Emu.GetCallbacks().handle_taskbar_progress(2, taskbar_limit);
g_emu_callbacks.handle_taskbar_progress(2, taskbar_limit);
}
else if (taskbar_index == -1)
{
taskbar_limit += limit;
Emu.GetCallbacks().handle_taskbar_progress(2, taskbar_limit);
g_emu_callbacks.handle_taskbar_progress(2, taskbar_limit);
}
return CELL_OK;
+2 -2
View File
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "overlay_video.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include "Loader/ISO.h"
namespace rsx
@@ -63,7 +63,7 @@ namespace rsx
{
if (video_path.empty()) return;
m_video_source = ensure(Emu.GetCallbacks().make_video_source());
m_video_source = ensure(g_emu_callbacks.make_video_source());
m_video_source->set_update_callback([this]()
{
if (m_video_active)
+2 -1
View File
@@ -5,6 +5,7 @@
#include "Emu/Io/interception.h"
#include "Emu/Io/KeyboardHandler.h"
#include "Emu/RSX/RSXThread.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
LOG_CHANNEL(overlays);
@@ -39,7 +40,7 @@ namespace rsx
void play_sound(sound_effect sound, std::optional<f32> volume)
{
Emu.GetCallbacks().play_sound(get_sound_filepath(sound), volume);
g_emu_callbacks.play_sound(get_sound_filepath(sound), volume);
}
thread_local DECLARE(user_interface::g_thread_bit) = 0;
+56 -53
View File
@@ -2,6 +2,7 @@
#include "VFS.h"
#include "Utilities/bin_patch.h"
#include "Emu/Memory/vm.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_progress.hpp"
#include "Emu/system_utils.hpp"
@@ -73,6 +74,8 @@ stx::manual_typemap<void, 0x20'00000, 128> g_fixed_typemap;
static constinit atomic_t<bool> s_emulator_available{false};
emu_callbacks g_emu_callbacks {};
std::string g_cfg_defaults;
atomic_t<u64> g_watchdog_hold_ctr{0};
@@ -205,7 +208,7 @@ void Emulator::CallFromMainThread(std::function<void()>&& func, atomic_t<u32>* w
}
};
ensure(m_cb.call_from_main_thread)(std::move(final_func), wake_up);
ensure(g_emu_callbacks.call_from_main_thread)(std::move(final_func), wake_up);
}
void Emulator::BlockingCallFromMainThread(std::function<void()>&& func, bool track_emu_state, std::source_location src_loc) const
@@ -248,14 +251,14 @@ void init_fxo_for_exec(utils::serial* ar, bool full = false)
g_fxo->init(false, ar, [](){ Emu.ExecPostponedInitCode(); });
Emu.GetCallbacks().init_gs_render(ar);
Emu.GetCallbacks().init_kb_handler();
Emu.GetCallbacks().init_mouse_handler();
g_emu_callbacks.init_gs_render(ar);
g_emu_callbacks.init_kb_handler();
g_emu_callbacks.init_mouse_handler();
stx::g_launch_retainer = 0;
stx::g_launch_retainer.notify_all();
Emu.GetCallbacks().init_pad_handler(Emu.GetTitleID());
g_emu_callbacks.init_pad_handler(Emu.GetTitleID());
usz pos = 0;
@@ -455,7 +458,7 @@ void Emulator::Init()
const std::string parent = fs::get_parent_dir(path);
const std::string emu_dir_no_delim = emu_dir.substr(0, emu_dir.find_last_not_of(fs::delim) + 1);
if (parent != emu_dir_no_delim && GetCallbacks().resolve_path(parent) != GetCallbacks().resolve_path(emu_dir_no_delim))
if (parent != emu_dir_no_delim && g_emu_callbacks.resolve_path(parent) != g_emu_callbacks.resolve_path(emu_dir_no_delim))
{
sys_log.fatal("Cannot use '%s' for Virtual File System because it does not exist.\nPlease specify an existing and writable directory path in Toolbar -> Manage -> Virtual File System.", path);
return false;
@@ -941,14 +944,14 @@ bool Emulator::BootRsxCapture(const std::string& path)
// PS3 'executable'
m_state = system_state::ready;
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
GetCallbacks().init_gs_render(nullptr);
GetCallbacks().init_kb_handler();
GetCallbacks().init_mouse_handler();
GetCallbacks().init_pad_handler("");
g_emu_callbacks.init_gs_render(nullptr);
g_emu_callbacks.init_kb_handler();
g_emu_callbacks.init_mouse_handler();
g_emu_callbacks.init_pad_handler("");
GetCallbacks().on_run(false);
g_emu_callbacks.on_run(false);
m_state = system_state::starting;
m_state.notify_all();
@@ -1002,14 +1005,14 @@ bool Emulator::BootBigPictureMode()
// No PS3 executable is loaded. GSRender/pad_thread only exist to host the Big Picture Mode overlay.
m_state = system_state::ready;
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
GetCallbacks().init_gs_render(nullptr);
GetCallbacks().init_kb_handler();
GetCallbacks().init_mouse_handler();
GetCallbacks().init_pad_handler("");
g_emu_callbacks.init_gs_render(nullptr);
g_emu_callbacks.init_kb_handler();
g_emu_callbacks.init_mouse_handler();
g_emu_callbacks.init_pad_handler("");
GetCallbacks().on_run(false);
g_emu_callbacks.on_run(false);
m_state = system_state::starting;
m_state.notify_all();
@@ -1081,7 +1084,7 @@ game_boot_result Emulator::BootGame(const std::string& path, const std::string&
if (result != game_boot_result::no_errors)
{
unload_iso();
GetCallbacks().close_gs_frame();
g_emu_callbacks.close_gs_frame();
}
}
else
@@ -1095,7 +1098,7 @@ game_boot_result Emulator::BootGame(const std::string& path, const std::string&
if (result != game_boot_result::no_errors)
{
GetCallbacks().close_gs_frame();
g_emu_callbacks.close_gs_frame();
}
};
}
@@ -1633,7 +1636,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
sys_log.notice("Restored executable path: \'%s\'", m_path);
}
const std::string resolved_path = GetCallbacks().resolve_path(m_path);
const std::string resolved_path = g_emu_callbacks.resolve_path(m_path);
if (!launching_from_disc_archive && is_iso_file(m_path, nullptr, &launching_from_optical_drive))
{
sys_log.notice("Loading iso archive '%s'", m_path);
@@ -1725,7 +1728,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
{
// Get database config if possible. This only happens if the database config hasn't been set by the UI (e.g. if booted with no-gui).
// We only know the title_id for sure at this point, so it doesn't make sense to retrieve it earlier.
m_db_config = Emu.GetCallbacks().get_database_config(m_title_id);
m_db_config = g_emu_callbacks.get_database_config(m_title_id);
}
// We add the database configuration if it is set, unless we are using a mode that specifically selects a different configuration.
@@ -1886,7 +1889,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
if (!launching_from_disc_archive && fs::is_dir(m_path))
{
m_state = system_state::ready;
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
ensure(g_fxo->init<main_ppu_module<lv2_obj>>());
vm::init();
vm::reserve_map(vm::main, 0, 0x1FFF0000, vm::page_64k_size);
@@ -2051,7 +2054,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
{
if (const std::vector<std::string> device_list = fmt::split(g_cfg.audio.microphone_devices.to_string(), {"@@@"}); !device_list.empty())
{
Emu.GetCallbacks().check_microphone_permissions();
g_emu_callbacks.check_microphone_permissions();
}
}
@@ -2382,7 +2385,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
bool install_success = true;
BlockingCallFromMainThread([this, &pkgs, &install_success, launching_from_optical_drive]()
{
if (!GetCallbacks().on_install_pkgs(pkgs, launching_from_optical_drive))
if (!g_emu_callbacks.on_install_pkgs(pkgs, launching_from_optical_drive))
{
install_success = false;
}
@@ -2518,8 +2521,8 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
if (const std::string hdd0_boot = hdd0_game + m_title_id + "/USRDIR/EBOOT.BIN"; !m_ar
&& recursion_count == 0 && disc.empty() && !bdvd_dir.empty() && !m_title_id.empty()
&& (launching_from_disc_archive ||
resolved_path == GetCallbacks().resolve_path(vfs::get("/dev_bdvd/PS3_GAME/USRDIR/EBOOT.BIN")))
&& resolved_path != GetCallbacks().resolve_path(hdd0_boot) && fs::is_file(hdd0_boot)
resolved_path == g_emu_callbacks.resolve_path(vfs::get("/dev_bdvd/PS3_GAME/USRDIR/EBOOT.BIN")))
&& resolved_path != g_emu_callbacks.resolve_path(hdd0_boot) && fs::is_file(hdd0_boot)
&& ppu_exec == elf_error::ok)
{
if (const psf::registry update_sfo = psf::load(hdd0_game + m_title_id + "/PARAM.SFO").sfo;
@@ -2572,7 +2575,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
}
// PS3 executable
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
if (argv.empty())
{
@@ -2607,7 +2610,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
return fmt::merge(result, "/");
};
const std::string resolved_hdd0 = GetCallbacks().resolve_path(hdd0_game) + '/';
const std::string resolved_hdd0 = g_emu_callbacks.resolve_path(hdd0_game) + '/';
if (from_hdd0_game && m_cat == "DG")
{
@@ -2637,7 +2640,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
else if (from_dev_flash)
{
// Firmware executables
argv[0] = "/dev_flash" + resolved_path.substr(GetCallbacks().resolve_path(g_cfg_vfs.get_dev_flash()).size());
argv[0] = "/dev_flash" + resolved_path.substr(g_emu_callbacks.resolve_path(g_cfg_vfs.get_dev_flash()).size());
m_dir = fs::get_parent_dir(argv[0]) + '/';
}
else if (!m_title_id.empty() && m_cat == "HG")
@@ -2653,7 +2656,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
const std::string dir = std::string(fmt::trim_sv(std::string_view(game_dir).substr(fs::get_parent_dir_view(game_dir).size() + 1), fs::delim));
m_dir = "/dev_hdd0/game/" + dir + '/';
argv[0] = m_dir + unescape(resolved_path.substr(GetCallbacks().resolve_path(game_dir).size()));
argv[0] = m_dir + unescape(resolved_path.substr(g_emu_callbacks.resolve_path(game_dir).size()));
sys_log.notice("Boot path: %s", m_dir);
}
else if (g_cfg.vfs.host_root)
@@ -2693,7 +2696,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
// Overlay (OVL) executable (only load it)
else
{
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
g_fxo->init(false);
if (!vm::map(0x3000'0000, 0x1000'0000, 0x200) || !ppu_load_overlay(ppu_exec, false, m_path).first)
@@ -2720,7 +2723,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
{
// PPU PRX
m_ar.reset();
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
g_fxo->init(false);
ppu_load_prx(ppu_prx, false, m_path);
Pause(true);
@@ -2729,7 +2732,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
{
// SPU executable
m_ar.reset();
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
g_fxo->init(false);
spu_load_exec(spu_exec);
Pause(true);
@@ -2738,7 +2741,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
{
// SPU linker file
m_ar.reset();
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
g_fxo->init(false);
spu_load_rel_exec(spu_rel);
Pause(true);
@@ -2747,7 +2750,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
{
// PPU linker file
m_ar.reset();
GetCallbacks().on_ready();
g_emu_callbacks.on_ready();
g_fxo->init(false);
ppu_load_rel_exec(ppu_rel);
Pause(true);
@@ -2783,7 +2786,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool is_disc_patch,
CallFromMainThread([this]()
{
GetCallbacks().on_missing_fw();
g_emu_callbacks.on_missing_fw();
});
return game_boot_result::firmware_missing;
@@ -2808,7 +2811,7 @@ void Emulator::Run(bool start_playtime)
{
ensure(IsReady() || GetStatus(false) == system_state::frozen);
GetCallbacks().on_run(start_playtime);
g_emu_callbacks.on_run(start_playtime);
m_pause_start_time = 0;
m_pause_amend_time = 0;
@@ -2822,12 +2825,12 @@ void Emulator::Run(bool start_playtime)
if (g_cfg.misc.prevent_display_sleep)
{
Emu.GetCallbacks().enable_display_sleep(false);
g_emu_callbacks.enable_display_sleep(false);
}
if (g_cfg.misc.enable_gamemode)
{
Emu.GetCallbacks().enable_gamemode(true);
g_emu_callbacks.enable_gamemode(true);
}
}
@@ -3055,7 +3058,7 @@ bool Emulator::Pause(bool freeze_emulation, bool show_resume_message)
rsx->state += cpu_flag::dbg_global_pause;
}
GetCallbacks().on_pause();
g_emu_callbacks.on_pause();
BlockingCallFromMainThread([this, show_resume_message]()
{
@@ -3112,7 +3115,7 @@ bool Emulator::Pause(bool freeze_emulation, bool show_resume_message)
}
// Always Enable display sleep, not only if it was prevented.
Emu.GetCallbacks().enable_display_sleep(true);
g_emu_callbacks.enable_display_sleep(true);
return true;
}
@@ -3192,7 +3195,7 @@ void Emulator::Resume()
rsx->state -= cpu_flag::dbg_global_pause;
}
GetCallbacks().on_resume();
g_emu_callbacks.on_resume();
sys_log.success("Emulation has been resumed!");
@@ -3209,7 +3212,7 @@ void Emulator::Resume()
if (g_cfg.misc.prevent_display_sleep)
{
Emu.GetCallbacks().enable_display_sleep(false);
g_emu_callbacks.enable_display_sleep(false);
}
}
@@ -3679,7 +3682,7 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
if (i >= (is_being_held_longer ? 5000 : 2000))
{
// Total amount of waiting: about 10s
GetCallbacks().on_emulation_stop_no_response(closed_sucessfully, is_being_held_longer ? 25 : 10);
g_emu_callbacks.on_emulation_stop_no_response(closed_sucessfully, is_being_held_longer ? 25 : 10);
while (thread_ctrl::state() != thread_state::aborting)
{
@@ -3699,7 +3702,7 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
// Total amount of waiting: about 10s
if (g_cfg.savestate.suspend_emu)
{
GetCallbacks().on_save_state_progress(closed_sucessfully, ar_ptr, verbose_message.get(), init_mtx);
g_emu_callbacks.on_save_state_progress(closed_sucessfully, ar_ptr, verbose_message.get(), init_mtx);
}
while (thread_ctrl::state() != thread_state::aborting)
@@ -4231,15 +4234,15 @@ void Emulator::Kill(bool allow_autoexit, bool savestate, savestate_stage* save_s
};
}
GetCallbacks().on_stop();
g_emu_callbacks.on_stop();
// Always Enable display sleep, not only if it was prevented.
Emu.GetCallbacks().enable_display_sleep(true);
g_emu_callbacks.enable_display_sleep(true);
// Calling Gamemode Exit on Stop
if (g_cfg.misc.enable_gamemode)
{
Emu.GetCallbacks().enable_gamemode(false);
g_emu_callbacks.enable_gamemode(false);
}
if (allow_autoexit)
@@ -4324,9 +4327,9 @@ bool Emulator::Quit(bool force_quit)
Emu.CleanUp();
};
if (GetCallbacks().try_to_quit)
if (g_emu_callbacks.try_to_quit)
{
return GetCallbacks().try_to_quit(force_quit, on_exit);
return g_emu_callbacks.try_to_quit(force_quit, on_exit);
}
on_exit();
@@ -4779,8 +4782,8 @@ game_boot_result Emulator::RemoveGameFromYml(const std::string& title_id)
bool Emulator::IsPathInsideDir(std::string_view path, std::string_view dir, bool check_if_exists) const
{
const std::string dir_path = check_if_exists ? GetCallbacks().resolve_path(dir) : GetCallbacks().resolve_path_may_not_exist(dir);
const std::string resolved_path = check_if_exists ? GetCallbacks().resolve_path(path) : GetCallbacks().resolve_path_may_not_exist(path);
const std::string dir_path = check_if_exists ? g_emu_callbacks.resolve_path(dir) : g_emu_callbacks.resolve_path_may_not_exist(dir);
const std::string resolved_path = check_if_exists ? g_emu_callbacks.resolve_path(path) : g_emu_callbacks.resolve_path_may_not_exist(path);
return !dir_path.empty() && !resolved_path.empty() && (resolved_path + '/').starts_with((dir_path.back() == '/') ? dir_path : (dir_path + '/'));
}
+2 -72
View File
@@ -6,6 +6,7 @@
#include "Utilities/bit_set.h"
#include "config_mode.h"
#include "games_config.h"
#include <functional>
#include <memory>
#include <string>
@@ -14,7 +15,6 @@
void init_fxo_for_exec(utils::serial*, bool);
enum class localized_string_id;
enum class video_renderer;
class spu_thread;
@@ -22,11 +22,6 @@ class spu_thread;
template <typename T>
class named_thread;
namespace cfg
{
class _base;
}
enum class system_state : u32
{
stopped,
@@ -66,59 +61,6 @@ constexpr bool is_error(game_boot_result res)
return res != game_boot_result::no_errors;
}
struct EmuCallbacks
{
std::function<void(std::function<void()>, atomic_t<u32>*)> call_from_main_thread;
std::function<void(bool)> on_run; // (start_playtime) continuing or going ingame, so start the clock
std::function<void()> on_pause;
std::function<void()> on_resume;
std::function<void()> on_stop;
std::function<void()> on_ready;
std::function<void()> on_missing_fw;
std::function<void(std::shared_ptr<atomic_t<bool>>, int)> on_emulation_stop_no_response;
std::function<void(std::shared_ptr<atomic_t<bool>>, stx::shared_ptr<utils::serial>, stx::atomic_ptr<std::string>*, std::shared_ptr<void>)> on_save_state_progress;
std::function<void(bool enabled)> enable_disc_eject;
std::function<void(bool enabled)> enable_disc_insert;
std::function<bool(bool, std::function<void()>)> try_to_quit; // (force_quit, on_exit) Try to close RPCS3
std::function<void(s32, s32)> handle_taskbar_progress; // (type, value) type: 0 for reset, 1 for increment, 2 for set_limit, 3 for set_value
std::function<void()> init_kb_handler;
std::function<void()> init_mouse_handler;
std::function<void(std::string_view title_id)> init_pad_handler;
std::function<void()> update_emu_settings;
std::function<void()> save_emu_settings;
std::function<void()> close_gs_frame;
std::function<std::unique_ptr<class GSFrameBase>()> get_gs_frame;
std::function<std::shared_ptr<class camera_handler_base>()> get_camera_handler;
std::function<std::shared_ptr<class music_handler_base>()> get_music_handler;
std::function<void(utils::serial*)> init_gs_render;
std::function<std::shared_ptr<class AudioBackend>()> get_audio;
std::function<std::shared_ptr<class audio_device_enumerator>(u64)> get_audio_enumerator; // (audio_renderer)
std::function<std::shared_ptr<class MsgDialogBase>()> get_msg_dialog;
std::function<std::shared_ptr<class OskDialogBase>()> get_osk_dialog;
std::function<std::unique_ptr<class SaveDialogBase>()> get_save_dialog;
std::function<std::shared_ptr<class SendMessageDialogBase>()> get_sendmessage_dialog;
std::function<std::shared_ptr<class RecvMessageDialogBase>()> get_recvmessage_dialog;
std::function<std::unique_ptr<class TrophyNotificationBase>()> get_trophy_notification_dialog;
std::function<std::string(localized_string_id, const char*)> get_localized_string;
std::function<std::u32string(localized_string_id, const char*)> get_localized_u32string;
std::function<std::string(const cfg::_base*, u32)> get_localized_setting;
std::function<std::string(std::string_view)> get_photo_path;
std::function<void(const std::string&, std::optional<f32>)> play_sound;
std::function<bool(const std::string&, std::string&, s32&, s32&, s32&)> get_image_info; // (filename, sub_type, width, height, CellSearchOrientation)
std::function<bool(const std::string&, s32, s32, s32&, s32&, u8*, bool)> get_scaled_image; // (filename, target_width, target_height, width, height, dst, force_fit)
std::function<std::string(std::string_view)> resolve_path = [](std::string_view arg){ return std::string{arg}; }; // Resolve path using Qt (returns empty string if the file doesn't exist)
std::function<std::string(std::string_view)> resolve_path_may_not_exist = [](std::string_view arg){ return std::string{arg}; }; // Resolve path using Qt
std::function<std::vector<std::string>()> get_font_dirs;
std::function<bool(const std::vector<std::string>&, bool)> on_install_pkgs;
std::function<void(u32)> add_breakpoint;
std::function<bool()> display_sleep_control_supported;
std::function<void(bool)> enable_display_sleep;
std::function<void()> check_microphone_permissions;
std::function<std::unique_ptr<class video_source>()> make_video_source;
std::function<void(bool)> enable_gamemode;
std::function<std::string(const std::string&)> get_database_config;
};
namespace utils
{
struct serial;
@@ -133,8 +75,6 @@ class Emulator final
{
atomic_t<system_state> m_state{system_state::stopped};
EmuCallbacks m_cb;
atomic_t<u64> m_pause_start_time{0}; // set when paused
atomic_t<u64> m_pause_amend_time{0}; // increased when resumed
atomic_t<u64> m_stop_ctr{1}; // Increments when emulation is stopped
@@ -213,18 +153,8 @@ public:
static bool IsAvailable() noexcept;
void SetCallbacks(EmuCallbacks&& cb)
{
m_cb = std::move(cb);
}
void SetGameDir(const std::string& game_dir) { m_game_dir = game_dir; }
const auto& GetCallbacks() const
{
return m_cb;
}
// Call from the GUI thread
void CallFromMainThread(std::function<void()>&& func, atomic_t<u32>* wake_up = nullptr, bool track_emu_state = true, u64 stop_ctr = umax,
std::source_location src_loc = std::source_location::current()) const;
@@ -456,7 +386,7 @@ private:
struct savestate_stage
{
bool prepared = false;
std::vector<std::pair<shared_ptr<named_thread<spu_thread>>, u32>> paused_spus;
std::vector<std::pair<stx::shared_ptr<named_thread<spu_thread>>, u32>> paused_spus;
};
public:
+5 -4
View File
@@ -1,5 +1,6 @@
#include "stdafx.h"
#include "IdManager.h"
#include "emu_callbacks.h"
#include "System.h"
#include "VFS.h"
@@ -70,7 +71,7 @@ bool vfs::mount(std::string_view vpath, std::string_view path, bool is_dir)
if (pos == umax)
{
// Mounting completed; fixup for directories due to resolve_path messing with trailing /
list.back()->path = Emu.GetCallbacks().resolve_path(path);
list.back()->path = g_emu_callbacks.resolve_path(path);
if (list.back()->path.empty())
list.back()->path = std::string(path); // Fallback when resolving failed
if (is_dir && !list.back()->path.ends_with('/'))
@@ -400,7 +401,7 @@ std::string vfs::retrieve(std::string_view path, const vfs_directory* node, std:
std::vector<std::string_view> mount_path_empty;
const std::string rpath = Emu.GetCallbacks().resolve_path_may_not_exist(path);
const std::string rpath = g_emu_callbacks.resolve_path_may_not_exist(path);
if (!rpath.empty())
{
@@ -1065,7 +1066,7 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2
return false;
}
const auto escaped_from = Emu.GetCallbacks().resolve_path(from);
const auto escaped_from = g_emu_callbacks.resolve_path(from);
auto check_path = [&](std::string_view path)
{
@@ -1079,7 +1080,7 @@ bool vfs::host::rename(const std::string& from, const std::string& to, const lv2
return;
}
std::string escaped = Emu.GetCallbacks().resolve_path(file.real_path);
std::string escaped = g_emu_callbacks.resolve_path(file.real_path);
if (check_path(escaped))
{
+68
View File
@@ -0,0 +1,68 @@
#pragma once
#include "util/atomic.hpp"
#include "util/shared_ptr.hpp"
#include <functional>
enum class localized_string_id;
namespace cfg
{
class _base;
}
struct emu_callbacks
{
std::function<void(std::function<void()>, atomic_t<u32>*)> call_from_main_thread;
std::function<void(bool)> on_run; // (start_playtime) continuing or going ingame, so start the clock
std::function<void()> on_pause;
std::function<void()> on_resume;
std::function<void()> on_stop;
std::function<void()> on_ready;
std::function<void()> on_missing_fw;
std::function<void(std::shared_ptr<atomic_t<bool>>, int)> on_emulation_stop_no_response;
std::function<void(std::shared_ptr<atomic_t<bool>>, stx::shared_ptr<utils::serial>, stx::atomic_ptr<std::string>*, std::shared_ptr<void>)> on_save_state_progress;
std::function<void(bool enabled)> enable_disc_eject;
std::function<void(bool enabled)> enable_disc_insert;
std::function<bool(bool, std::function<void()>)> try_to_quit; // (force_quit, on_exit) Try to close RPCS3
std::function<void(s32, s32)> handle_taskbar_progress; // (type, value) type: 0 for reset, 1 for increment, 2 for set_limit, 3 for set_value
std::function<void()> init_kb_handler;
std::function<void()> init_mouse_handler;
std::function<void(std::string_view title_id)> init_pad_handler;
std::function<void()> update_emu_settings;
std::function<void()> save_emu_settings;
std::function<void()> close_gs_frame;
std::function<std::unique_ptr<class GSFrameBase>()> get_gs_frame;
std::function<std::shared_ptr<class camera_handler_base>()> get_camera_handler;
std::function<std::shared_ptr<class music_handler_base>()> get_music_handler;
std::function<void(utils::serial*)> init_gs_render;
std::function<std::shared_ptr<class AudioBackend>()> get_audio;
std::function<std::shared_ptr<class audio_device_enumerator>(u64)> get_audio_enumerator; // (audio_renderer)
std::function<std::shared_ptr<class MsgDialogBase>()> get_msg_dialog;
std::function<std::shared_ptr<class OskDialogBase>()> get_osk_dialog;
std::function<std::unique_ptr<class SaveDialogBase>()> get_save_dialog;
std::function<std::shared_ptr<class SendMessageDialogBase>()> get_sendmessage_dialog;
std::function<std::shared_ptr<class RecvMessageDialogBase>()> get_recvmessage_dialog;
std::function<std::unique_ptr<class TrophyNotificationBase>()> get_trophy_notification_dialog;
std::function<std::string(localized_string_id, const char*)> get_localized_string;
std::function<std::u32string(localized_string_id, const char*)> get_localized_u32string;
std::function<std::string(const cfg::_base*, u32)> get_localized_setting;
std::function<std::string(std::string_view)> get_photo_path;
std::function<void(const std::string&, std::optional<f32>)> play_sound;
std::function<bool(const std::string&, std::string&, s32&, s32&, s32&)> get_image_info; // (filename, sub_type, width, height, CellSearchOrientation)
std::function<bool(const std::string&, s32, s32, s32&, s32&, u8*, bool)> get_scaled_image; // (filename, target_width, target_height, width, height, dst, force_fit)
std::function<std::string(std::string_view)> resolve_path = [](std::string_view arg){ return std::string{arg}; }; // Resolve path using Qt (returns empty string if the file doesn't exist)
std::function<std::string(std::string_view)> resolve_path_may_not_exist = [](std::string_view arg){ return std::string{arg}; }; // Resolve path using Qt
std::function<std::vector<std::string>()> get_font_dirs;
std::function<bool(const std::vector<std::string>&, bool)> on_install_pkgs;
std::function<void(u32)> add_breakpoint;
std::function<bool()> display_sleep_control_supported;
std::function<void(bool)> enable_display_sleep;
std::function<void()> check_microphone_permissions;
std::function<std::unique_ptr<class video_source>()> make_video_source;
std::function<void(bool)> enable_gamemode;
std::function<std::string(const std::string&)> get_database_config;
};
extern emu_callbacks g_emu_callbacks;
+2 -1
View File
@@ -3,6 +3,7 @@
#include "util/types.hpp"
#include "util/sysinfo.hpp"
#include "Utilities/mutex.h"
#include "emu_callbacks.h"
#include "System.h"
#include "system_utils.hpp"
#include "vfs_config.h"
@@ -90,7 +91,7 @@ private:
template <typename game_info_type>
void game_enumeration<game_info_type>::initialize_paths()
{
m_hdd0 = Emu.GetCallbacks().resolve_path(rpcs3::utils::get_hdd0_dir()) + '/';
m_hdd0 = g_emu_callbacks.resolve_path(rpcs3::utils::get_hdd0_dir()) + '/';
m_dev_flash = g_cfg_vfs.get_dev_flash();
m_game_icon_path = fs::get_config_dir() + "/Icons/game_icons/";
}
+3 -3
View File
@@ -1,13 +1,13 @@
#include "stdafx.h"
#include "localized_string.h"
#include "System.h"
#include "emu_callbacks.h"
std::string get_localized_string(localized_string_id id, const char* args)
{
return Emu.GetCallbacks().get_localized_string(id, args);
return g_emu_callbacks.get_localized_string(id, args);
}
std::u32string get_localized_u32string(localized_string_id id, const char* args)
{
return Emu.GetCallbacks().get_localized_u32string(id, args);
return g_emu_callbacks.get_localized_u32string(id, args);
}
+2 -1
View File
@@ -6,6 +6,7 @@
#include "Emu/RSX/Overlays/overlay_message_dialog.h"
#include "Emu/RSX/Overlays/overlay_message.h"
#include "Emu/RSX/Overlays/overlay_compile_notification.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "util/asm.hpp"
@@ -150,7 +151,7 @@ void progress_dialog_server::operator()()
create_native_dialog(text0, &show_overlay_message);
if (!show_overlay_message && !native_dlg && (dlg = Emu.GetCallbacks().get_msg_dialog()))
if (!show_overlay_message && !native_dlg && (dlg = g_emu_callbacks.get_msg_dialog()))
{
dlg->type.se_normal = true;
dlg->type.bg_invisible = true;
+1
View File
@@ -617,6 +617,7 @@
<ClInclude Include="Emu\config_mode.h" />
<ClInclude Include="Emu\CPU\Hypervisor.h" />
<ClInclude Include="Emu\CPU\sse2neon.h" />
<ClInclude Include="Emu\emu_callbacks.h" />
<ClInclude Include="Emu\games_config.h" />
<ClInclude Include="Emu\game_enumeration.h" />
<ClInclude Include="Emu\Io\Buzz.h" />
+3
View File
@@ -3016,6 +3016,9 @@
<ClInclude Include="util\cctype.hpp">
<Filter>Utilities</Filter>
</ClInclude>
<ClInclude Include="Emu\emu_callbacks.h">
<Filter>Emu</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Emu\RSX\Program\GLSLSnippets\GPUDeswizzle.glsl">
+35 -37
View File
@@ -1,5 +1,6 @@
#include "headless_application.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/RSX/Null/NullGSRender.h"
#include "Emu/Cell/Modules/cellMsgDialog.h"
@@ -24,7 +25,7 @@ headless_application::headless_application(int& argc, char** argv) : QCoreApplic
void headless_application::Init()
{
// Create callbacks from the emulator, which reference the handlers.
InitializeCallbacks();
create_callbacks();
// Force init the emulator
InitializeEmulator(m_active_user.empty() ? "00000001" : m_active_user, false, true);
@@ -42,12 +43,11 @@ void headless_application::InitializeConnects() const
connect(this, &headless_application::RequestCallFromMainThread, this, &headless_application::CallFromMainThread);
}
/** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here. */
void headless_application::InitializeCallbacks()
void headless_application::create_callbacks()
{
EmuCallbacks callbacks = CreateCallbacks();
main_application::create_callbacks();
callbacks.try_to_quit = [](bool force_quit, std::function<void()> on_exit) -> bool
g_emu_callbacks.try_to_quit = [](bool force_quit, std::function<void()> on_exit) -> bool
{
if (force_quit)
{
@@ -63,12 +63,12 @@ void headless_application::InitializeCallbacks()
return false;
};
callbacks.call_from_main_thread = [this](std::function<void()> func, atomic_t<u32>* wake_up)
g_emu_callbacks.call_from_main_thread = [this](std::function<void()> func, atomic_t<u32>* wake_up)
{
RequestCallFromMainThread(std::move(func), wake_up);
};
callbacks.init_gs_render = [](utils::serial* ar)
g_emu_callbacks.init_gs_render = [](utils::serial* ar)
{
switch (const video_renderer type = g_cfg.video.renderer)
{
@@ -90,7 +90,7 @@ void headless_application::InitializeCallbacks()
}
};
callbacks.get_camera_handler = []() -> std::shared_ptr<camera_handler_base>
g_emu_callbacks.get_camera_handler = []() -> std::shared_ptr<camera_handler_base>
{
switch (g_cfg.io.camera.get())
{
@@ -110,7 +110,7 @@ void headless_application::InitializeCallbacks()
return nullptr;
};
callbacks.get_music_handler = []() -> std::shared_ptr<music_handler_base>
g_emu_callbacks.get_music_handler = []() -> std::shared_ptr<music_handler_base>
{
switch (g_cfg.audio.music.get())
{
@@ -126,8 +126,8 @@ void headless_application::InitializeCallbacks()
return nullptr;
};
callbacks.close_gs_frame = [](){};
callbacks.get_gs_frame = []() -> std::unique_ptr<GSFrameBase>
g_emu_callbacks.close_gs_frame = [](){};
g_emu_callbacks.get_gs_frame = []() -> std::unique_ptr<GSFrameBase>
{
if (g_cfg.video.renderer != video_renderer::null)
{
@@ -136,17 +136,17 @@ void headless_application::InitializeCallbacks()
return std::unique_ptr<GSFrameBase>();
};
callbacks.get_msg_dialog = []() -> std::shared_ptr<MsgDialogBase> { return std::shared_ptr<MsgDialogBase>(); };
callbacks.get_osk_dialog = []() -> std::shared_ptr<OskDialogBase> { return std::shared_ptr<OskDialogBase>(); };
callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::unique_ptr<SaveDialogBase>(); };
callbacks.get_trophy_notification_dialog = []() -> std::unique_ptr<TrophyNotificationBase> { return std::unique_ptr<TrophyNotificationBase>(); };
g_emu_callbacks.get_msg_dialog = []() -> std::shared_ptr<MsgDialogBase> { return std::shared_ptr<MsgDialogBase>(); };
g_emu_callbacks.get_osk_dialog = []() -> std::shared_ptr<OskDialogBase> { return std::shared_ptr<OskDialogBase>(); };
g_emu_callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::unique_ptr<SaveDialogBase>(); };
g_emu_callbacks.get_trophy_notification_dialog = []() -> std::unique_ptr<TrophyNotificationBase> { return std::unique_ptr<TrophyNotificationBase>(); };
callbacks.on_run = [](bool /*start_playtime*/) {};
callbacks.on_pause = []() {};
callbacks.on_resume = []() {};
callbacks.on_stop = []() {};
callbacks.on_ready = []() {};
callbacks.on_emulation_stop_no_response = [](std::shared_ptr<atomic_t<bool>> closed_successfully, int /*seconds_waiting_already*/)
g_emu_callbacks.on_run = [](bool /*start_playtime*/) {};
g_emu_callbacks.on_pause = []() {};
g_emu_callbacks.on_resume = []() {};
g_emu_callbacks.on_stop = []() {};
g_emu_callbacks.on_ready = []() {};
g_emu_callbacks.on_emulation_stop_no_response = [](std::shared_ptr<atomic_t<bool>> closed_successfully, int /*seconds_waiting_already*/)
{
if (!closed_successfully || !*closed_successfully)
{
@@ -155,32 +155,30 @@ void headless_application::InitializeCallbacks()
}
};
callbacks.on_save_state_progress = [](std::shared_ptr<atomic_t<bool>>, stx::shared_ptr<utils::serial>, stx::atomic_ptr<std::string>*, std::shared_ptr<void>)
g_emu_callbacks.on_save_state_progress = [](std::shared_ptr<atomic_t<bool>>, stx::shared_ptr<utils::serial>, stx::atomic_ptr<std::string>*, std::shared_ptr<void>)
{
};
callbacks.enable_disc_eject = [](bool) {};
callbacks.enable_disc_insert = [](bool) {};
g_emu_callbacks.enable_disc_eject = [](bool) {};
g_emu_callbacks.enable_disc_insert = [](bool) {};
callbacks.on_missing_fw = []() {};
g_emu_callbacks.on_missing_fw = []() {};
callbacks.handle_taskbar_progress = [](s32, s32) {};
g_emu_callbacks.handle_taskbar_progress = [](s32, s32) {};
callbacks.get_localized_string = [](localized_string_id, const char*) -> std::string { return {}; };
callbacks.get_localized_u32string = [](localized_string_id, const char*) -> std::u32string { return {}; };
callbacks.get_localized_setting = [](const cfg::_base*, u32) -> std::string { return {}; };
g_emu_callbacks.get_localized_string = [](localized_string_id, const char*) -> std::string { return {}; };
g_emu_callbacks.get_localized_u32string = [](localized_string_id, const char*) -> std::u32string { return {}; };
g_emu_callbacks.get_localized_setting = [](const cfg::_base*, u32) -> std::string { return {}; };
callbacks.play_sound = [](const std::string&, std::optional<f32>){};
callbacks.add_breakpoint = [](u32 /*addr*/){};
g_emu_callbacks.play_sound = [](const std::string&, std::optional<f32>){};
g_emu_callbacks.add_breakpoint = [](u32 /*addr*/){};
callbacks.display_sleep_control_supported = [](){ return false; };
callbacks.enable_display_sleep = [](bool /*enabled*/){};
g_emu_callbacks.display_sleep_control_supported = [](){ return false; };
g_emu_callbacks.enable_display_sleep = [](bool /*enabled*/){};
callbacks.check_microphone_permissions = [](){};
g_emu_callbacks.check_microphone_permissions = [](){};
callbacks.make_video_source = [](){ return nullptr; };
Emu.SetCallbacks(std::move(callbacks));
g_emu_callbacks.make_video_source = [](){ return nullptr; };
}
/**
+1 -1
View File
@@ -21,7 +21,7 @@ public:
void Init() override;
private:
void InitializeCallbacks();
void create_callbacks() override;
void InitializeConnects() const;
QThread* get_thread() override
+18 -21
View File
@@ -11,6 +11,7 @@
#include "Utilities/Thread.h"
#include "Utilities/File.h"
#include "Input/pad_thread.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/system_utils.hpp"
@@ -131,11 +132,9 @@ void main_application::OnEmuSettingsChange()
}
/** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here. */
EmuCallbacks main_application::CreateCallbacks()
void main_application::create_callbacks()
{
EmuCallbacks callbacks{};
callbacks.update_emu_settings = [this]()
g_emu_callbacks.update_emu_settings = [this]()
{
Emu.CallFromMainThread([&]()
{
@@ -143,7 +142,7 @@ EmuCallbacks main_application::CreateCallbacks()
});
};
callbacks.save_emu_settings = [this]()
g_emu_callbacks.save_emu_settings = [this]()
{
Emu.BlockingCallFromMainThread([&]()
{
@@ -151,7 +150,7 @@ EmuCallbacks main_application::CreateCallbacks()
});
};
callbacks.init_kb_handler = [this]()
g_emu_callbacks.init_kb_handler = [this]()
{
switch (g_cfg.io.keyboard.get())
{
@@ -171,7 +170,7 @@ EmuCallbacks main_application::CreateCallbacks()
}
};
callbacks.init_mouse_handler = [this]()
g_emu_callbacks.init_mouse_handler = [this]()
{
mouse_handler handler = g_cfg.io.mouse;
@@ -213,14 +212,14 @@ EmuCallbacks main_application::CreateCallbacks()
}
};
callbacks.init_pad_handler = [this](std::string_view title_id)
g_emu_callbacks.init_pad_handler = [this](std::string_view title_id)
{
ensure(g_fxo->init<named_thread<pad_thread>>(get_thread(), m_game_window, title_id));
qt_events_aware_op(0, [](){ return !!pad::g_started; });
};
callbacks.get_audio = []() -> std::shared_ptr<AudioBackend>
g_emu_callbacks.get_audio = []() -> std::shared_ptr<AudioBackend>
{
std::shared_ptr<AudioBackend> result;
switch (g_cfg.audio.renderer.get())
@@ -244,7 +243,7 @@ EmuCallbacks main_application::CreateCallbacks()
return result;
};
callbacks.get_audio_enumerator = [](u64 renderer) -> std::shared_ptr<audio_device_enumerator>
g_emu_callbacks.get_audio_enumerator = [](u64 renderer) -> std::shared_ptr<audio_device_enumerator>
{
switch (static_cast<audio_renderer>(renderer))
{
@@ -260,7 +259,7 @@ EmuCallbacks main_application::CreateCallbacks()
}
};
callbacks.get_image_info = [](const std::string& filename, std::string& sub_type, s32& width, s32& height, s32& orientation) -> bool
g_emu_callbacks.get_image_info = [](const std::string& filename, std::string& sub_type, s32& width, s32& height, s32& orientation) -> bool
{
sub_type.clear();
width = 0;
@@ -308,7 +307,7 @@ EmuCallbacks main_application::CreateCallbacks()
return success;
};
callbacks.get_scaled_image = [](const std::string& path, s32 target_width, s32 target_height, s32& width, s32& height, u8* dst, bool force_fit) -> bool
g_emu_callbacks.get_scaled_image = [](const std::string& path, s32 target_width, s32 target_height, s32& width, s32& height, u8* dst, bool force_fit) -> bool
{
width = 0;
height = 0;
@@ -378,13 +377,13 @@ EmuCallbacks main_application::CreateCallbacks()
return success;
};
callbacks.resolve_path = [](std::string_view sv)
g_emu_callbacks.resolve_path = [](std::string_view sv)
{
// May result in an empty string if path does not exist
return QFileInfo(QString::fromUtf8(sv.data(), static_cast<int>(sv.size()))).canonicalFilePath().toStdString();
};
callbacks.resolve_path_may_not_exist = [](std::string_view sv)
g_emu_callbacks.resolve_path_may_not_exist = [](std::string_view sv)
{
const QString path = QString::fromUtf8(sv.data(), static_cast<int>(sv.size()));
QFileInfo fi(path);
@@ -412,7 +411,7 @@ EmuCallbacks main_application::CreateCallbacks()
return result.toStdString();
};
callbacks.get_font_dirs = []()
g_emu_callbacks.get_font_dirs = []()
{
const QStringList locations = QStandardPaths::standardLocations(QStandardPaths::FontsLocation);
std::vector<std::string> font_dirs;
@@ -428,7 +427,7 @@ EmuCallbacks main_application::CreateCallbacks()
return font_dirs;
};
callbacks.on_install_pkgs = [](const std::vector<std::string>& pkgs, bool from_optical_drive)
g_emu_callbacks.on_install_pkgs = [](const std::vector<std::string>& pkgs, bool from_optical_drive)
{
for (const std::string& pkg : pkgs)
{
@@ -441,9 +440,9 @@ EmuCallbacks main_application::CreateCallbacks()
return true;
};
callbacks.enable_gamemode = [](bool enabled){ enable_gamemode(enabled); };
g_emu_callbacks.enable_gamemode = [](bool enabled){ enable_gamemode(enabled); };
callbacks.get_photo_path = [](std::string_view title)
g_emu_callbacks.get_photo_path = [](std::string_view title)
{
const QDateTime date_time = QDateTime::currentDateTime();
const QDate date = date_time.date();
@@ -471,7 +470,7 @@ EmuCallbacks main_application::CreateCallbacks()
return path + suffix;
};
callbacks.get_database_config = [](const std::string& title_id)
g_emu_callbacks.get_database_config = [](const std::string& title_id)
{
sys_log.notice("Trying to retrieve database config for: '%s'", title_id);
@@ -499,6 +498,4 @@ EmuCallbacks main_application::CreateCallbacks()
sys_log.error("Failed to retrieve database config for: '%s'", title_id);
return std::string();
};
return callbacks;
}
+1 -1
View File
@@ -27,7 +27,7 @@ protected:
void OnEmuSettingsChange();
EmuCallbacks CreateCallbacks();
virtual void create_callbacks();
std::shared_ptr<render_creator> m_render_creator;
std::string m_active_user;
+4 -3
View File
@@ -6,6 +6,7 @@
#include "Utilities/date_time.h"
#include "Utilities/File.h"
#include "util/video_provider.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/system_progress.hpp"
@@ -483,7 +484,7 @@ void gs_frame::toggle_recording()
// Play a sound
if (const std::string sound_path = fs::get_config_dir() + "sounds/snd_recording.wav"; fs::is_file(sound_path))
{
Emu.GetCallbacks().play_sound(sound_path, std::nullopt);
g_emu_callbacks.play_sound(sound_path, std::nullopt);
}
else
{
@@ -1074,7 +1075,7 @@ void gs_frame::take_screenshot(std::vector<u8>&& data, u32 sshot_width, u32 ssho
}
}
const std::string cell_sshot_filename = Emu.GetCallbacks().get_photo_path(manager.get_photo_title() + ".png");
const std::string cell_sshot_filename = g_emu_callbacks.get_photo_path(manager.get_photo_title() + ".png");
const std::string cell_sshot_dir = fs::get_parent_dir(cell_sshot_filename);
screenshot_log.notice("Saving cell screenshot to %s", cell_sshot_filename);
@@ -1104,7 +1105,7 @@ void gs_frame::take_screenshot(std::vector<u8>&& data, u32 sshot_width, u32 ssho
{
if (const std::string sound_path = fs::get_config_dir() + "sounds/snd_screenshot.wav"; fs::is_file(sound_path))
{
Emu.GetCallbacks().play_sound(sound_path, std::nullopt);
g_emu_callbacks.play_sound(sound_path, std::nullopt);
}
else
{
+39 -41
View File
@@ -28,6 +28,7 @@
#include "Emu/Cell/Modules/cellSysutil.h"
#include "Emu/Io/Null/null_camera_handler.h"
#include "Emu/Io/Null/null_music_handler.h"
#include "Emu/emu_callbacks.h"
#include "Emu/vfs_config.h"
#include "util/init_mutex.hpp"
#include "util/console.h"
@@ -297,7 +298,7 @@ void gui_application::Init()
}
// Create callbacks from the emulator, which reference the handlers.
InitializeCallbacks();
create_callbacks();
// Force init the emulator
InitializeEmulator(m_active_user, m_show_gui, false);
@@ -619,7 +620,7 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
}
// Clean-up old game window. This should only happen if the renderer changed or there was an unexpected error during boot.
Emu.GetCallbacks().close_gs_frame();
g_emu_callbacks.close_gs_frame();
}
gui_log.notice("gui_application: Creating new game window");
@@ -746,12 +747,11 @@ std::unique_ptr<gs_frame> gui_application::get_gs_frame()
return std::unique_ptr<gs_frame>(frame);
}
/** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here. */
void gui_application::InitializeCallbacks()
void gui_application::create_callbacks()
{
EmuCallbacks callbacks = CreateCallbacks();
main_application::create_callbacks();
callbacks.try_to_quit = [this](bool force_quit, std::function<void()> on_exit) -> bool
g_emu_callbacks.try_to_quit = [this](bool force_quit, std::function<void()> on_exit) -> bool
{
// Close rpcs3 if closed in no-gui mode
if (force_quit || !m_main_window)
@@ -776,12 +776,12 @@ void gui_application::InitializeCallbacks()
return false;
};
callbacks.call_from_main_thread = [this](std::function<void()> func, atomic_t<u32>* wake_up)
g_emu_callbacks.call_from_main_thread = [this](std::function<void()> func, atomic_t<u32>* wake_up)
{
RequestCallFromMainThread(std::move(func), wake_up);
};
callbacks.init_gs_render = [](utils::serial* ar)
g_emu_callbacks.init_gs_render = [](utils::serial* ar)
{
switch (g_cfg.video.renderer.get())
{
@@ -807,7 +807,7 @@ void gui_application::InitializeCallbacks()
}
};
callbacks.get_camera_handler = []() -> std::shared_ptr<camera_handler_base>
g_emu_callbacks.get_camera_handler = []() -> std::shared_ptr<camera_handler_base>
{
switch (g_cfg.io.camera.get())
{
@@ -830,7 +830,7 @@ void gui_application::InitializeCallbacks()
return nullptr;
};
callbacks.get_music_handler = []() -> std::shared_ptr<music_handler_base>
g_emu_callbacks.get_music_handler = []() -> std::shared_ptr<music_handler_base>
{
switch (g_cfg.audio.music.get())
{
@@ -846,7 +846,7 @@ void gui_application::InitializeCallbacks()
return nullptr;
};
callbacks.close_gs_frame = [this]()
g_emu_callbacks.close_gs_frame = [this]()
{
if (m_game_window)
{
@@ -856,28 +856,28 @@ void gui_application::InitializeCallbacks()
m_game_window = nullptr;
}
};
callbacks.get_gs_frame = [this]() -> std::unique_ptr<GSFrameBase> { return get_gs_frame(); };
callbacks.get_msg_dialog = [this]() -> std::shared_ptr<MsgDialogBase> { return m_show_gui ? std::make_shared<msg_dialog_frame>() : nullptr; };
callbacks.get_osk_dialog = [this]() -> std::shared_ptr<OskDialogBase> { return m_show_gui ? std::make_shared<osk_dialog_frame>() : nullptr; };
callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::make_unique<save_data_dialog>(); };
callbacks.get_sendmessage_dialog = []() -> std::shared_ptr<SendMessageDialogBase> { return std::make_shared<sendmessage_dialog_frame>(); };
callbacks.get_recvmessage_dialog = []() -> std::shared_ptr<RecvMessageDialogBase> { return std::make_shared<recvmessage_dialog_frame>(); };
callbacks.get_trophy_notification_dialog = [this]() -> std::unique_ptr<TrophyNotificationBase> { return std::make_unique<trophy_notification_helper>(m_game_window); };
g_emu_callbacks.get_gs_frame = [this]() -> std::unique_ptr<GSFrameBase> { return get_gs_frame(); };
g_emu_callbacks.get_msg_dialog = [this]() -> std::shared_ptr<MsgDialogBase> { return m_show_gui ? std::make_shared<msg_dialog_frame>() : nullptr; };
g_emu_callbacks.get_osk_dialog = [this]() -> std::shared_ptr<OskDialogBase> { return m_show_gui ? std::make_shared<osk_dialog_frame>() : nullptr; };
g_emu_callbacks.get_save_dialog = []() -> std::unique_ptr<SaveDialogBase> { return std::make_unique<save_data_dialog>(); };
g_emu_callbacks.get_sendmessage_dialog = []() -> std::shared_ptr<SendMessageDialogBase> { return std::make_shared<sendmessage_dialog_frame>(); };
g_emu_callbacks.get_recvmessage_dialog = []() -> std::shared_ptr<RecvMessageDialogBase> { return std::make_shared<recvmessage_dialog_frame>(); };
g_emu_callbacks.get_trophy_notification_dialog = [this]() -> std::unique_ptr<TrophyNotificationBase> { return std::make_unique<trophy_notification_helper>(m_game_window); };
callbacks.on_run = [this](bool start_playtime) { OnEmulatorRun(start_playtime); };
callbacks.on_pause = [this]() { OnEmulatorPause(); };
callbacks.on_resume = [this]() { OnEmulatorResume(true); };
callbacks.on_stop = [this]() { OnEmulatorStop(); };
callbacks.on_ready = [this]() { OnEmulatorReady(); };
g_emu_callbacks.on_run = [this](bool start_playtime) { OnEmulatorRun(start_playtime); };
g_emu_callbacks.on_pause = [this]() { OnEmulatorPause(); };
g_emu_callbacks.on_resume = [this]() { OnEmulatorResume(true); };
g_emu_callbacks.on_stop = [this]() { OnEmulatorStop(); };
g_emu_callbacks.on_ready = [this]() { OnEmulatorReady(); };
callbacks.enable_disc_eject = [this](bool enabled)
g_emu_callbacks.enable_disc_eject = [this](bool enabled)
{
Emu.CallFromMainThread([this, enabled]()
{
OnEnableDiscEject(enabled);
});
};
callbacks.enable_disc_insert = [this](bool enabled)
g_emu_callbacks.enable_disc_insert = [this](bool enabled)
{
Emu.CallFromMainThread([this, enabled]()
{
@@ -885,7 +885,7 @@ void gui_application::InitializeCallbacks()
});
};
callbacks.on_missing_fw = [this]()
g_emu_callbacks.on_missing_fw = [this]()
{
if (m_main_window)
{
@@ -893,7 +893,7 @@ void gui_application::InitializeCallbacks()
}
};
callbacks.handle_taskbar_progress = [this](s32 type, s32 value)
g_emu_callbacks.handle_taskbar_progress = [this](s32 type, s32 value)
{
if (m_game_window)
{
@@ -908,23 +908,23 @@ void gui_application::InitializeCallbacks()
}
};
callbacks.get_localized_string = [](localized_string_id id, const char* args) -> std::string
g_emu_callbacks.get_localized_string = [](localized_string_id id, const char* args) -> std::string
{
return localized_emu::get_string(id, args);
};
callbacks.get_localized_u32string = [](localized_string_id id, const char* args) -> std::u32string
g_emu_callbacks.get_localized_u32string = [](localized_string_id id, const char* args) -> std::u32string
{
return localized_emu::get_u32string(id, args);
};
callbacks.get_localized_setting = [this](const cfg::_base* node, u32 enum_index) -> std::string
g_emu_callbacks.get_localized_setting = [this](const cfg::_base* node, u32 enum_index) -> std::string
{
ensure(!!m_emu_settings);
return m_emu_settings->GetLocalizedSetting(node, enum_index);
};
callbacks.play_sound = [this](const std::string& path, std::optional<f32> volume)
g_emu_callbacks.play_sound = [this](const std::string& path, std::optional<f32> volume)
{
Emu.CallFromMainThread([this, path, volume]()
{
@@ -949,7 +949,7 @@ void gui_application::InitializeCallbacks()
if (m_show_gui) // If this is false, we already have a fallback in the main_application.
{
callbacks.on_install_pkgs = [this](const std::vector<std::string>& pkgs, bool from_optical_drive)
g_emu_callbacks.on_install_pkgs = [this](const std::vector<std::string>& pkgs, bool from_optical_drive)
{
ensure(!pkgs.empty());
QStringList pkg_list;
@@ -961,7 +961,7 @@ void gui_application::InitializeCallbacks()
};
}
callbacks.on_emulation_stop_no_response = [](std::shared_ptr<atomic_t<bool>> closed_successfully, int seconds_waiting_already)
g_emu_callbacks.on_emulation_stop_no_response = [](std::shared_ptr<atomic_t<bool>> closed_successfully, int seconds_waiting_already)
{
const std::string terminate_message = tr("Stopping emulator took too long."
"\nSome thread has probably deadlocked. Aborting.").toStdString();
@@ -1016,7 +1016,7 @@ void gui_application::InitializeCallbacks()
});
};
callbacks.on_save_state_progress = [this](std::shared_ptr<atomic_t<bool>> closed_successfully, stx::shared_ptr<utils::serial> ar_ptr, stx::atomic_ptr<std::string>* code_location, std::shared_ptr<void> init_mtx)
g_emu_callbacks.on_save_state_progress = [this](std::shared_ptr<atomic_t<bool>> closed_successfully, stx::shared_ptr<utils::serial> ar_ptr, stx::atomic_ptr<std::string>* code_location, std::shared_ptr<void> init_mtx)
{
Emu.CallFromMainThread([this, closed_successfully, ar_ptr, code_location, init_mtx]
{
@@ -1119,7 +1119,7 @@ void gui_application::InitializeCallbacks()
});
};
callbacks.add_breakpoint = [this](u32 addr)
g_emu_callbacks.add_breakpoint = [this](u32 addr)
{
Emu.BlockingCallFromMainThread([this, addr]()
{
@@ -1127,10 +1127,10 @@ void gui_application::InitializeCallbacks()
});
};
callbacks.display_sleep_control_supported = [](){ return display_sleep_control_supported(); };
callbacks.enable_display_sleep = [](bool enabled){ enable_display_sleep(enabled); };
g_emu_callbacks.display_sleep_control_supported = [](){ return display_sleep_control_supported(); };
g_emu_callbacks.enable_display_sleep = [](bool enabled){ enable_display_sleep(enabled); };
callbacks.check_microphone_permissions = []()
g_emu_callbacks.check_microphone_permissions = []()
{
Emu.BlockingCallFromMainThread([]()
{
@@ -1138,9 +1138,7 @@ void gui_application::InitializeCallbacks()
});
};
callbacks.make_video_source = [](){ return std::make_unique<qt_video_source_wrapper>(); };
Emu.SetCallbacks(std::move(callbacks));
g_emu_callbacks.make_video_source = [](){ return std::make_unique<qt_video_source_wrapper>(); };
}
void gui_application::StartPlaytime(bool start_playtime = true)
+1 -1
View File
@@ -87,7 +87,7 @@ private:
void LoadLanguage(const QString& language_code);
static QStringList GetAvailableLanguageCodes();
void InitializeCallbacks();
void create_callbacks() override;
void InitializeConnects();
void StartPlaytime(bool start_playtime);
+2 -2
View File
@@ -1258,7 +1258,7 @@ bool main_window::HandlePackageInstallation(main_window* mw, QStringList file_pa
// Try to claim operations on ID
for (auto it = paths.begin(); it != paths.end();)
{
std::string resolved_path = Emu.GetCallbacks().resolve_path(it->first);
std::string resolved_path = g_emu_callbacks.resolve_path(it->first);
if (resolved_path.empty() || claimed_paths.contains(resolved_path))
{
@@ -4267,7 +4267,7 @@ void main_window::AddGamesFromDirs(QStringList&& paths)
{
// Try to claim operation on directory path
std::string resolved_path = Emu.GetCallbacks().resolve_path(game->path);
std::string resolved_path = g_emu_callbacks.resolve_path(game->path);
if (!resolved_path.empty() && !claimed_paths.count(resolved_path))
{
+3 -2
View File
@@ -28,6 +28,7 @@
#include "Emu/NP/rpcn_countries.h"
#include "Emu/GameInfo.h"
#include "Emu/emu_callbacks.h"
#include "Emu/System.h"
#include "Emu/system_config.h"
#include "Emu/title.h"
@@ -927,7 +928,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
const auto get_audio_output_devices = [this](bool keep_old = true)
{
const auto [text, value] = get_data(ui->audioOutBox, ui->audioOutBox->currentIndex());
auto dev_enum = Emu.GetCallbacks().get_audio_enumerator(value);
auto dev_enum = g_emu_callbacks.get_audio_enumerator(value);
std::vector<audio_device_enumerator::audio_device> dev_array = dev_enum->get_output_devices();
ui->audioDeviceBox->clear();
@@ -1678,7 +1679,7 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
EnhanceCheckBox(emu_settings_type::PauseOnFocusLoss, ui->pauseOnFocusLoss, tooltips.settings.pause_on_focus_loss);
EnhanceCheckBox(emu_settings_type::StartGameFullscreen, ui->startGameFullscreen, tooltips.settings.start_game_fullscreen);
EnhanceCheckBox(emu_settings_type::PreventDisplaySleep, ui->preventDisplaySleep, tooltips.settings.prevent_display_sleep);
ui->preventDisplaySleep->setEnabled(Emu.GetCallbacks().display_sleep_control_supported());
ui->preventDisplaySleep->setEnabled(g_emu_callbacks.display_sleep_control_supported());
EnhanceCheckBox(emu_settings_type::ShowTrophyPopups, ui->showTrophyPopups, tooltips.settings.show_trophy_popups);
EnhanceCheckBox(emu_settings_type::ShowRpcnPopups, ui->showRpcnPopups, tooltips.settings.show_rpcn_popups);
+2 -1
View File
@@ -2,6 +2,7 @@
#include "trophy_notification_frame.h"
#include "../Emu/IdManager.h"
#include "../Emu/emu_callbacks.h"
#include "../Emu/System.h"
#include "../Emu/RSX/Overlays/overlay_manager.h"
@@ -31,7 +32,7 @@ s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails&
trophy_notification->move(m_game_window->mapToGlobal(QPoint(0, 0)));
trophy_notification->show();
Emu.GetCallbacks().play_sound(fs::get_config_dir() + "sounds/snd_trophy.wav", std::nullopt);
g_emu_callbacks.play_sound(fs::get_config_dir() + "sounds/snd_trophy.wav", std::nullopt);
});
return 0;
+2 -2
View File
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "media_utils.h"
#include "Emu/System.h"
#include "Emu/emu_callbacks.h"
#include <random>
#include <thread>
@@ -168,7 +168,7 @@ namespace utils
if (av_media_type == AVMEDIA_TYPE_UNKNOWN) // Let's use this for image info
{
const bool success = Emu.GetCallbacks().get_image_info(path, info.sub_type, info.width, info.height, info.orientation);
const bool success = g_emu_callbacks.get_image_info(path, info.sub_type, info.width, info.height, info.orientation);
if (!success) media_log.error("get_media_info: failed to get image info for '%s'", path);
return { success, std::move(info) };
}