From 4d2f205f3642c0d8db52af1baf0fc3f1cd4f61c9 Mon Sep 17 00:00:00 2001 From: Megamouse Date: Wed, 10 Dec 2025 19:32:12 +0100 Subject: [PATCH] cellGem: add debug overlay --- rpcs3/Emu/CMakeLists.txt | 1 + rpcs3/Emu/Cell/Modules/cellGem.cpp | 24 ++++ .../Overlays/Debug/overlay_ps_move_debug.cpp | 123 ++++++++++++++++++ .../Overlays/Debug/overlay_ps_move_debug.h | 28 ++++ .../HomeMenu/overlay_home_menu_settings.cpp | 1 + .../RSX/Overlays/overlay_debug_overlay.cpp | 16 ++- .../Emu/RSX/Overlays/overlay_debug_overlay.h | 2 +- rpcs3/Emu/RSX/RSXThread.cpp | 2 +- rpcs3/Emu/localized_string_id.h | 1 + rpcs3/Emu/system_config.h | 1 + rpcs3/emucore.vcxproj | 2 + rpcs3/emucore.vcxproj.filters | 33 +++-- rpcs3/main_application.cpp | 4 +- rpcs3/rpcs3qt/emu_settings_type.h | 2 + rpcs3/rpcs3qt/localized_emu.h | 1 + rpcs3/rpcs3qt/settings_dialog.cpp | 3 + rpcs3/rpcs3qt/settings_dialog.ui | 9 +- rpcs3/rpcs3qt/tooltips.h | 1 + 18 files changed, 236 insertions(+), 18 deletions(-) create mode 100644 rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.cpp create mode 100644 rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.h diff --git a/rpcs3/Emu/CMakeLists.txt b/rpcs3/Emu/CMakeLists.txt index 83e8a28398..5331dc5b0b 100644 --- a/rpcs3/Emu/CMakeLists.txt +++ b/rpcs3/Emu/CMakeLists.txt @@ -481,6 +481,7 @@ target_sources(rpcs3_emu PRIVATE RSX/NV47/HW/nv308a.cpp RSX/NV47/HW/nv406e.cpp RSX/NV47/HW/nv4097.cpp + RSX/Overlays/Debug/overlay_ps_move_debug.cpp RSX/Overlays/FriendsList/overlay_friends_list_dialog.cpp RSX/Overlays/HomeMenu/overlay_home_menu.cpp RSX/Overlays/HomeMenu/overlay_home_menu_components.cpp diff --git a/rpcs3/Emu/Cell/Modules/cellGem.cpp b/rpcs3/Emu/Cell/Modules/cellGem.cpp index 88edf12516..9f1e95f4e3 100644 --- a/rpcs3/Emu/Cell/Modules/cellGem.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGem.cpp @@ -14,6 +14,8 @@ #include "Emu/System.h" #include "Emu/IdManager.h" #include "Emu/RSX/Overlays/overlay_cursor.h" +#include "Emu/RSX/Overlays/overlay_manager.h" +#include "Emu/RSX/Overlays/Debug/overlay_ps_move_debug.h" #include "Input/pad_thread.h" #include "Input/ps_move_config.h" #include "Input/ps_move_tracker.h" @@ -1684,6 +1686,23 @@ static inline void draw_overlay_cursor(u32 gem_num, const gem_config::gem_contro rsx::overlays::set_cursor(rsx::overlays::cursor_offset::cell_gem + gem_num, x, y, color, 2'000'000, false); } +static void show_ps_move_debug_overlay(u32 gem_num, const ps_move_data& md, const CellGemState& state) +{ + if (gem_num != 0 || !g_cfg.misc.use_native_interface) + return; + + if (auto manager = g_fxo->try_get()) + { + if (auto overlay = manager->get()) + { + const gem_config_data::gem_color& rgb = gem_config_data::gem_color::get_default_color(gem_num); + + // Use quaternion from state instead of ps_move_data so that we can also check the fake/mouse move + overlay->show(md, rgb.r, rgb.g, rgb.b, state.quat[0], state.quat[1], state.quat[2], state.quat[3]); + } + } +} + static inline void pos_to_gem_image_state(u32 gem_num, gem_config::gem_controller& controller, vm::ptr& gem_image_state, s32 x_pos, s32 y_pos, s32 x_max, s32 y_max) { const auto& shared_data = g_fxo->get(); @@ -1831,6 +1850,11 @@ static inline void pos_to_gem_state(u32 gem_num, gem_config::gem_controller& con controller.radius_valid = x_pos > 0 && x_pos < x_max && y_pos > 0 && y_pos < y_max; } + if (g_cfg.io.ps_move_debug_overlay) + { + show_ps_move_debug_overlay(gem_num, move_data, *gem_state); + } + if (g_cfg.io.show_move_cursor) { draw_overlay_cursor(gem_num, controller, x_pos, y_pos, x_max, y_max); diff --git a/rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.cpp b/rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.cpp new file mode 100644 index 0000000000..4ecb83c726 --- /dev/null +++ b/rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.cpp @@ -0,0 +1,123 @@ +#include "stdafx.h" +#include "overlay_ps_move_debug.h" + +namespace rsx +{ + namespace overlays + { + ps_move_debug_overlay::ps_move_debug_overlay() + { + m_frame.set_pos(0, 0); + m_frame.set_size(300, 300); + m_frame.back_color.r = 0.0f; + m_frame.back_color.g = 0.0f; + m_frame.back_color.b = 0.0f; + m_frame.back_color.a = 1.0f; + + m_text_view.set_pos(10, 10); + m_text_view.set_padding(0, 0, 0, 0); + m_text_view.set_font("n023055ms.ttf", 6); + m_text_view.align_text(overlay_element::text_align::left); + m_text_view.fore_color = { 0.3f, 1.f, 0.3f, 1.f }; + m_text_view.back_color.a = 0.f; + } + + compiled_resource ps_move_debug_overlay::get_compiled() + { + if (!visible) + { + return {}; + } + + auto result = m_frame.get_compiled(); + result.add(m_text_view.get_compiled()); + + // Move cylinder so its center is at origin + //glTranslatef(0, 0, 0.5f); + + // Apply quaternion rotation + //QMatrix4x4 model; + //model.rotate(QQuaternion(m_quaternion[3], m_quaternion[0], m_quaternion[1], m_quaternion[2])); + //glMultMatrixf(model.constData()); + + // Move back to original position + //glTranslatef(0, 0, -0.5f); + + // Draw controller body + //glColor3ub(200, 200, 200); + //drawCylinder(0.2f, 0.8f, 32); + + // Draw front sphere + //glColor3f(m_rgb[0], m_rgb[1], m_rgb[2]); + //glPushMatrix(); + //glTranslatef(0, 0, 0.8f); // move to front + //drawSphere(0.3f, 32, 32); + //glPopMatrix(); + + // Draw button + //glColor3ub(0, 0, 200); + //glPushMatrix(); + //glTranslatef(0, 0.2f, 0.4f); // slightly in front of the sphere + //drawButton(0.08f, 0.05f, 16); + //glPopMatrix(); + + return result; + } + + void ps_move_debug_overlay::show(const ps_move_data& md, f32 r, f32 g, f32 b, f32 q0, f32 q1, f32 q2, f32 q3) + { + visible = true; + + if (m_rgb[0] == r && m_rgb[1] == g && m_rgb[2] == b && + m_quaternion[0] == q0 && m_quaternion[1] == q1 && m_quaternion[2] == q2 && m_quaternion[3] == q3 && + std::memcmp(static_cast(&md), static_cast(&m_move_data), sizeof(ps_move_data)) == 0) + { + return; + } + + m_move_data = md; + m_rgb = { r, g, b }; + m_quaternion = { q0, q1, q2, q3 }; + + m_text_view.set_text(fmt::format( + "> Quat X: %6.2f Gyro X: %6.2f Accel X: %6.2f Mag X: %6.2f\n" + "> Quat Y: %6.2f Gyro Y: %6.2f Accel Y: %6.2f Mag Y: %6.2f\n" + "> Quat Z: %6.2f Gyro Z: %6.2f Accel Z: %6.2f Mag Z: %6.2f\n" + "> Quat W: %6.2f\n\n" + "> World\n" + "> Vel X: %9.2f\n" + "> Vel Y: %9.2f\n" + "> Vel Z: %9.2f\n" + "> Acc X: %9.2f\n" + "> Acc Y: %9.2f\n" + "> Acc Z: %9.2f\n" + "> AngVel X: %9.2f\n" + "> AngVel Y: %9.2f\n" + "> AngVel Z: %9.2f\n" + "> AngAcc X: %9.2f\n" + "> AngAcc Y: %9.2f\n" + "> AngAcc Z: %9.2f" + , + m_quaternion[0], md.gyro[0], md.accelerometer[0], md.magnetometer[0], + m_quaternion[1], md.gyro[1], md.accelerometer[1], md.magnetometer[1], + m_quaternion[2], md.gyro[2], md.accelerometer[2], md.magnetometer[2], + m_quaternion[3], + md.vel_world[0], + md.vel_world[1], + md.vel_world[2], + md.accel_world[0], + md.accel_world[1], + md.accel_world[2], + md.angvel_world[0], + md.angvel_world[1], + md.angvel_world[2], + md.angaccel_world[0], + md.angaccel_world[1], + md.angaccel_world[2] + )); + m_text_view.auto_resize(); + + refresh(); + } + } // namespace overlays +} // namespace rsx diff --git a/rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.h b/rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.h new file mode 100644 index 0000000000..711d8bd91d --- /dev/null +++ b/rpcs3/Emu/RSX/Overlays/Debug/overlay_ps_move_debug.h @@ -0,0 +1,28 @@ +#pragma once + +#include "../overlays.h" +#include "Emu/Io/pad_types.h" + +namespace rsx +{ + namespace overlays + { + struct ps_move_debug_overlay : public user_interface + { + public: + ps_move_debug_overlay(); + + compiled_resource get_compiled() override; + + void show(const ps_move_data& md, f32 r, f32 g, f32 b, f32 q0, f32 q1, f32 q2, f32 q3); + + private: + overlay_element m_frame; + label m_text_view; + + ps_move_data m_move_data {}; + std::array m_rgb {}; + std::array m_quaternion {}; + }; + } +} diff --git a/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp b/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp index 4ff3bd7eae..5f536af896 100644 --- a/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp +++ b/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp @@ -141,6 +141,7 @@ namespace rsx add_checkbox(&g_cfg.video.debug_overlay, localized_string_id::HOME_MENU_SETTINGS_DEBUG_OVERLAY); add_checkbox(&g_cfg.io.pad_debug_overlay, localized_string_id::HOME_MENU_SETTINGS_DEBUG_INPUT_OVERLAY); add_checkbox(&g_cfg.io.mouse_debug_overlay, localized_string_id::HOME_MENU_SETTINGS_MOUSE_DEBUG_INPUT_OVERLAY); + add_checkbox(&g_cfg.io.ps_move_debug_overlay, localized_string_id::HOME_MENU_SETTINGS_PS_MOVE_DEBUG_INPUT_OVERLAY); add_checkbox(&g_cfg.video.disable_video_output, localized_string_id::HOME_MENU_SETTINGS_DEBUG_DISABLE_VIDEO_OUTPUT); add_float_slider(&g_cfg.video.texture_lod_bias, localized_string_id::HOME_MENU_SETTINGS_DEBUG_TEXTURE_LOD_BIAS, "", 0.25f); diff --git a/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp b/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp index c49dceb144..021baef120 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp @@ -1,6 +1,7 @@ #include "stdafx.h" #include "overlay_manager.h" #include "overlay_debug_overlay.h" +#include "Debug/overlay_ps_move_debug.h" #include "Emu/system_config.h" namespace rsx @@ -41,7 +42,7 @@ namespace rsx visible = true; } - extern void reset_debug_overlay() + extern void reset_debug_overlays() { if (!g_cfg.misc.use_native_interface) return; @@ -49,6 +50,7 @@ namespace rsx if (auto manager = g_fxo->try_get()) { auto overlay = manager->get(); + auto ps_move_overlay = manager->get(); if (g_cfg.video.debug_overlay || g_cfg.io.pad_debug_overlay || g_cfg.io.mouse_debug_overlay) { @@ -61,6 +63,18 @@ namespace rsx { manager->remove(); } + + if (g_cfg.io.ps_move_debug_overlay) + { + if (!ps_move_overlay) + { + ps_move_overlay = manager->create(); + } + } + else if (ps_move_overlay) + { + manager->remove(); + } } } diff --git a/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.h b/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.h index 202aeea2c5..c62595f445 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.h +++ b/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.h @@ -19,7 +19,7 @@ namespace rsx void set_text(std::string&& text); }; - void reset_debug_overlay(); + void reset_debug_overlays(); void set_debug_overlay_text(std::string&& text); } } diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 73c86907f1..950c50851b 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -912,7 +912,7 @@ namespace rsx if (!serialized) method_registers.init(); rsx::overlays::reset_performance_overlay(); - rsx::overlays::reset_debug_overlay(); + rsx::overlays::reset_debug_overlays(); if (!is_initialized) { diff --git a/rpcs3/Emu/localized_string_id.h b/rpcs3/Emu/localized_string_id.h index 399b45c437..1a57197ef8 100644 --- a/rpcs3/Emu/localized_string_id.h +++ b/rpcs3/Emu/localized_string_id.h @@ -267,6 +267,7 @@ enum class localized_string_id HOME_MENU_SETTINGS_DEBUG_OVERLAY, HOME_MENU_SETTINGS_DEBUG_INPUT_OVERLAY, HOME_MENU_SETTINGS_MOUSE_DEBUG_INPUT_OVERLAY, + HOME_MENU_SETTINGS_PS_MOVE_DEBUG_INPUT_OVERLAY, HOME_MENU_SETTINGS_DEBUG_DISABLE_VIDEO_OUTPUT, HOME_MENU_SETTINGS_DEBUG_TEXTURE_LOD_BIAS, HOME_MENU_SCREENSHOT, diff --git a/rpcs3/Emu/system_config.h b/rpcs3/Emu/system_config.h index 2b45ce82a0..5282afe582 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -283,6 +283,7 @@ struct cfg_root : cfg::node cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true }; cfg::_bool pad_debug_overlay{ this, "IO Debug overlay", false, true }; cfg::_bool mouse_debug_overlay{ this, "Mouse Debug overlay", false, true }; + cfg::_bool ps_move_debug_overlay{ this, "PS Move Debug overlay", false, true }; cfg::uint<1, 180> fake_move_rotation_cone_h{ this, "Fake Move Rotation Cone", 10, true }; cfg::uint<1, 180> fake_move_rotation_cone_v{ this, "Fake Move Rotation Cone (Vertical)", 10, true }; diff --git a/rpcs3/emucore.vcxproj b/rpcs3/emucore.vcxproj index 437d79df8a..691dba3042 100644 --- a/rpcs3/emucore.vcxproj +++ b/rpcs3/emucore.vcxproj @@ -133,6 +133,7 @@ + @@ -684,6 +685,7 @@ + diff --git a/rpcs3/emucore.vcxproj.filters b/rpcs3/emucore.vcxproj.filters index 17ccca3792..d5c96cebeb 100644 --- a/rpcs3/emucore.vcxproj.filters +++ b/rpcs3/emucore.vcxproj.filters @@ -142,6 +142,9 @@ {7fb59544-9761-4b4a-bb04-07deb43cf3c2} + + {0421cba0-f378-4c28-bd91-c82557a0d5b7} + @@ -903,9 +906,6 @@ Emu\GPU\RSX\Overlays - - Emu\GPU\RSX\Overlays - Emu\GPU\RSX\Overlays @@ -1252,9 +1252,6 @@ Crypto - - Emu\GPU\RSX\Overlays - Emu\GPU\RSX\Overlays\Network @@ -1396,6 +1393,15 @@ Emu\Io + + Emu\GPU\RSX\Overlays\Debug + + + Emu\GPU\RSX\Overlays\Trophies + + + Emu\GPU\RSX\Overlays\Debug + @@ -2181,9 +2187,6 @@ Emu\GPU\RSX\Overlays - - Emu\GPU\RSX\Overlays - Emu\GPU\RSX\Overlays @@ -2602,9 +2605,6 @@ Emu - - Emu\GPU\RSX\Overlays - Emu\GPU\RSX\Overlays\Network @@ -2806,6 +2806,15 @@ Emu\Io + + Emu\GPU\RSX\Overlays\Debug + + + Emu\GPU\RSX\Overlays\Trophies + + + Emu\GPU\RSX\Overlays\Debug + diff --git a/rpcs3/main_application.cpp b/rpcs3/main_application.cpp index a1bc443cd0..36f0532f39 100644 --- a/rpcs3/main_application.cpp +++ b/rpcs3/main_application.cpp @@ -52,7 +52,7 @@ namespace audio namespace rsx::overlays { extern void reset_performance_overlay(); - extern void reset_debug_overlay(); + extern void reset_debug_overlays(); } extern void qt_events_aware_op(int repeat_duration_ms, std::function wrapped_op); @@ -89,7 +89,7 @@ void main_application::OnEmuSettingsChange() audio::configure_audio(); audio::configure_rsxaudio(); rsx::overlays::reset_performance_overlay(); - rsx::overlays::reset_debug_overlay(); + rsx::overlays::reset_debug_overlays(); } /** RPCS3 emulator has functions it desires to call from the GUI at times. Initialize them in here. */ diff --git a/rpcs3/rpcs3qt/emu_settings_type.h b/rpcs3/rpcs3qt/emu_settings_type.h index 7e69656eac..aec6d2980e 100644 --- a/rpcs3/rpcs3qt/emu_settings_type.h +++ b/rpcs3/rpcs3qt/emu_settings_type.h @@ -171,6 +171,7 @@ enum class emu_settings_type SDLMappings, IoDebugOverlay, MouseDebugOverlay, + MoveDebugOverlay, // Misc ExitRPCS3OnFinish, @@ -381,6 +382,7 @@ inline static const std::map settings_location { emu_settings_type::SDLMappings, { "Input/Output", "Load SDL GameController Mappings" }}, { emu_settings_type::IoDebugOverlay, { "Input/Output", "IO Debug overlay" }}, { emu_settings_type::MouseDebugOverlay, { "Input/Output", "Mouse Debug overlay" }}, + { emu_settings_type::MoveDebugOverlay, { "Input/Output", "PS Move Debug overlay" }}, // Misc { emu_settings_type::ExitRPCS3OnFinish, { "Miscellaneous", "Exit RPCS3 when process finishes" }}, diff --git a/rpcs3/rpcs3qt/localized_emu.h b/rpcs3/rpcs3qt/localized_emu.h index 7d4453a1bd..23ac80c11b 100644 --- a/rpcs3/rpcs3qt/localized_emu.h +++ b/rpcs3/rpcs3qt/localized_emu.h @@ -288,6 +288,7 @@ private: case localized_string_id::HOME_MENU_SETTINGS_DEBUG_OVERLAY: return tr("Debug Overlay", "Debug"); case localized_string_id::HOME_MENU_SETTINGS_DEBUG_INPUT_OVERLAY: return tr("Input Debug Overlay", "Debug"); case localized_string_id::HOME_MENU_SETTINGS_MOUSE_DEBUG_INPUT_OVERLAY: return tr("Mouse Debug Overlay", "Debug"); + case localized_string_id::HOME_MENU_SETTINGS_PS_MOVE_DEBUG_INPUT_OVERLAY: return tr("PSMove Debug Overlay", "Debug"); case localized_string_id::HOME_MENU_SETTINGS_DEBUG_DISABLE_VIDEO_OUTPUT: return tr("Disable Video Output", "Debug"); case localized_string_id::HOME_MENU_SETTINGS_DEBUG_TEXTURE_LOD_BIAS: return tr("Texture LOD Bias Addend", "Debug"); case localized_string_id::HOME_MENU_SCREENSHOT: return tr("Take Screenshot"); diff --git a/rpcs3/rpcs3qt/settings_dialog.cpp b/rpcs3/rpcs3qt/settings_dialog.cpp index 902da72cff..8aab5f482d 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -2475,6 +2475,9 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std m_emu_settings->EnhanceCheckBox(ui->debugOverlayMouse, emu_settings_type::MouseDebugOverlay); SubscribeTooltip(ui->debugOverlayMouse, tooltips.settings.debug_overlay_mouse); + m_emu_settings->EnhanceCheckBox(ui->debugOverlayPsMove, emu_settings_type::MoveDebugOverlay); + SubscribeTooltip(ui->debugOverlayPsMove, tooltips.settings.debug_overlay_ps_move); + // Comboboxes m_emu_settings->EnhanceComboBox(ui->combo_accurate_ppu_128, emu_settings_type::AccuratePPU128Loop, true); diff --git a/rpcs3/rpcs3qt/settings_dialog.ui b/rpcs3/rpcs3qt/settings_dialog.ui index 4556ae9356..8609be15f4 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -265,7 +265,7 @@ - + @@ -4551,6 +4551,13 @@ + + + + Debug Overlay For PSMove Input + + + diff --git a/rpcs3/rpcs3qt/tooltips.h b/rpcs3/rpcs3qt/tooltips.h index 3b84a66270..0831643b99 100644 --- a/rpcs3/rpcs3qt/tooltips.h +++ b/rpcs3/rpcs3qt/tooltips.h @@ -115,6 +115,7 @@ public: const QString debug_overlay = tr("Provides a graphical overlay of various debugging information.\nIf unsure, don't use this option."); const QString debug_overlay_io = tr("Provides a graphical overlay with pad input values for player 1.\nThis is only shown if the debug overlay is disabled.\nIf unsure, don't use this option."); const QString debug_overlay_mouse = tr("Provides a graphical overlay with mouse input values.\nThis is only shown if the other debug overlays are disabled.\nIf unsure, don't use this option."); + const QString debug_overlay_ps_move = tr("Provides a graphical overlay with PSMove input values.\nIf unsure, don't use this option."); const QString log_shader_programs = tr("Dump game shaders to file. Only useful to developers.\nIf unsure, don't use this option."); const QString disable_occlusion_queries = tr("Disables running occlusion queries. Minor to moderate performance boost.\nMight introduce issues with broken occlusion e.g missing geometry and extreme pop-in."); const QString disable_video_output = tr("Disables all video output and PS3 graphical rendering.\nIts only use case is to evaluate performance on CELL for development.");