Skip to content

Commit

Permalink
cellPad: draw debug overlay for basic input debugging of port 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse committed Sep 6, 2024
1 parent 977a682 commit 10b113c
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 3 deletions.
68 changes: 68 additions & 0 deletions rpcs3/Emu/Cell/Modules/cellPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "Emu/Cell/lv2/sys_process.h"
#include "Emu/Cell/lv2/sys_sync.h"
#include "Emu/Io/pad_types.h"
#include "Emu/RSX/Overlays/overlay_debug_overlay.h"
#include "Input/pad_thread.h"
#include "Input/product_info.h"
#include "cellPad.h"
Expand Down Expand Up @@ -73,6 +74,67 @@ void pad_info::save(utils::serial& ar)
sys_io_serialize(ar);
}

void show_debug_overlay(const CellPadData& data)
{
const u16 d1 = data.button[CELL_PAD_BTN_OFFSET_DIGITAL1];
const u16 d2 = data.button[CELL_PAD_BTN_OFFSET_DIGITAL2];

std::string text = fmt::format(
"> D-Pad Up: %3d : %3d\n"
"> D-Pad Down: %3d : %3d\n"
"> D-Pad Left: %3d : %3d\n"
"> D-Pad Right: %3d : %3d\n"
"> Cross: %3d : %3d\n"
"> Square: %3d : %3d\n"
"> Circle: %3d : %3d\n"
"> Triangle: %3d : %3d\n"
"> Start: %3d\n"
"> Select: %3d\n"
"> PS: %3d\n"
"> L1: %3d : %3d\n"
"> L2: %3d : %3d\n"
"> L3: %3d\n"
"> R1: %3d : %3d\n"
"> R2: %3d : %3d\n"
"> R3: %3d\n"
"> LS X: %3d\n"
"> LS Y: %3d\n"
"> RS X: %3d\n"
"> RS Y: %3d\n"
"> Sensor X: %3d\n"
"> Sensor Y: %3d\n"
"> Sensor Z: %3d\n"
"> Sensor G: %3d\n",
!!(d1 & CELL_PAD_CTRL_UP), data.button[CELL_PAD_BTN_OFFSET_PRESS_UP],
!!(d1 & CELL_PAD_CTRL_DOWN), data.button[CELL_PAD_BTN_OFFSET_PRESS_DOWN],
!!(d1 & CELL_PAD_CTRL_LEFT), data.button[CELL_PAD_BTN_OFFSET_PRESS_LEFT],
!!(d1 & CELL_PAD_CTRL_RIGHT), data.button[CELL_PAD_BTN_OFFSET_PRESS_RIGHT],
!!(d2 & CELL_PAD_CTRL_CROSS), data.button[CELL_PAD_BTN_OFFSET_PRESS_CROSS],
!!(d2 & CELL_PAD_CTRL_SQUARE), data.button[CELL_PAD_BTN_OFFSET_PRESS_SQUARE],
!!(d2 & CELL_PAD_CTRL_CIRCLE), data.button[CELL_PAD_BTN_OFFSET_PRESS_CIRCLE],
!!(d2 & CELL_PAD_CTRL_TRIANGLE), data.button[CELL_PAD_BTN_OFFSET_PRESS_TRIANGLE],
!!(d1 & CELL_PAD_CTRL_START),
!!(d1 & CELL_PAD_CTRL_SELECT),
!!(d1 & CELL_PAD_CTRL_PS),
!!(d2 & CELL_PAD_CTRL_L1), data.button[CELL_PAD_BTN_OFFSET_PRESS_L1],
!!(d2 & CELL_PAD_CTRL_L2), data.button[CELL_PAD_BTN_OFFSET_PRESS_L2],
!!(d1 & CELL_PAD_CTRL_L3),
!!(d2 & CELL_PAD_CTRL_R1), data.button[CELL_PAD_BTN_OFFSET_PRESS_R1],
!!(d2 & CELL_PAD_CTRL_R2), data.button[CELL_PAD_BTN_OFFSET_PRESS_R2],
!!(d1 & CELL_PAD_CTRL_R3),
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_X],
data.button[CELL_PAD_BTN_OFFSET_ANALOG_LEFT_Y],
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_X],
data.button[CELL_PAD_BTN_OFFSET_ANALOG_RIGHT_Y],
data.button[CELL_PAD_BTN_OFFSET_SENSOR_X],
data.button[CELL_PAD_BTN_OFFSET_SENSOR_Y],
data.button[CELL_PAD_BTN_OFFSET_SENSOR_Z],
data.button[CELL_PAD_BTN_OFFSET_SENSOR_G]
);

rsx::overlays::set_debug_overlay_text(std::move(text));
}

extern void send_sys_io_connect_event(usz index, u32 state);

bool cellPad_NotifyStateChange(usz index, u64 /*state*/, bool locked, bool is_blocking = true)
Expand Down Expand Up @@ -626,6 +688,12 @@ error_code cellPadGetData(u32 port_no, vm::ptr<CellPadData> data)
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

pad_get_data(port_no, data.get_ptr());

if (g_cfg.io.debug_overlay && !g_cfg.video.overlay && port_no == 0)
{
show_debug_overlay(*data);
}

return CELL_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace rsx
{
auto overlay = manager->get<rsx::overlays::debug_overlay>();

if (g_cfg.video.overlay)
if (g_cfg.video.overlay || g_cfg.io.debug_overlay)
{
if (!overlay)
{
Expand All @@ -66,7 +66,7 @@ namespace rsx

extern void set_debug_overlay_text(std::string&& text)
{
if (!g_cfg.misc.use_native_interface || !g_cfg.video.overlay)
if (!g_cfg.misc.use_native_interface || (!g_cfg.video.overlay && !g_cfg.io.debug_overlay))
return;

if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
Expand Down
1 change: 1 addition & 0 deletions rpcs3/Emu/system_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ struct cfg_root : cfg::node
cfg::_bool lock_overlay_input_to_player_one{this, "Lock overlay input to player one", false, true};
cfg::string midi_devices{this, "Emulated Midi devices", "ßßß@@@ßßß@@@ßßß@@@"};
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
cfg::_bool debug_overlay{ this, "IO Debug overlay", false, true };

} io{ this };

Expand Down
2 changes: 2 additions & 0 deletions rpcs3/rpcs3qt/emu_settings_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ enum class emu_settings_type
GHLtar,
MidiDevices,
SDLMappings,
IoDebugOverlay,

// Misc
ExitRPCS3OnFinish,
Expand Down Expand Up @@ -354,6 +355,7 @@ inline static const QMap<emu_settings_type, cfg_location> settings_location =
{ emu_settings_type::GHLtar, { "Input/Output", "GHLtar emulated controller" }},
{ emu_settings_type::MidiDevices, { "Input/Output", "Emulated Midi devices" }},
{ emu_settings_type::SDLMappings, { "Input/Output", "Load SDL GameController Mappings" }},
{ emu_settings_type::IoDebugOverlay, { "Input/Output", "IO Debug overlay" }},

// Misc
{ emu_settings_type::ExitRPCS3OnFinish, { "Miscellaneous", "Exit RPCS3 when process finishes" }},
Expand Down
4 changes: 4 additions & 0 deletions rpcs3/rpcs3qt/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,10 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
m_emu_settings->EnhanceCheckBox(ui->perfReport, emu_settings_type::PerformanceReport);
SubscribeTooltip(ui->perfReport, tooltips.settings.enable_performance_report);

// Checkboxes: IO debug options
m_emu_settings->EnhanceCheckBox(ui->debugOverlayIO, emu_settings_type::IoDebugOverlay);
SubscribeTooltip(ui->debugOverlayIO, tooltips.settings.debug_overlay_io);

// Comboboxes

m_emu_settings->EnhanceComboBox(ui->combo_accurate_ppu_128, emu_settings_type::AccuratePPU128Loop, true);
Expand Down
34 changes: 33 additions & 1 deletion rpcs3/rpcs3qt/settings_dialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -4364,7 +4364,7 @@
</item>
<item>
<widget class="QWidget" name="debug_more_stuff" native="true">
<layout class="QVBoxLayout" name="debug_more_stuff_layout">
<layout class="QVBoxLayout" name="debug_more_stuff_layout" stretch="0,0,0,0,1">
<property name="leftMargin">
<number>0</number>
</property>
Expand Down Expand Up @@ -4424,6 +4424,38 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="gb_debug_io">
<property name="title">
<string>I/O</string>
</property>
<layout class="QVBoxLayout" name="gb_debug_io_layout">
<item>
<widget class="QCheckBox" name="debugOverlayIO">
<property name="text">
<string>Debug Overlay For Pad Input</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacerDebugMore">
<property name="orientation">
Expand Down
1 change: 1 addition & 0 deletions rpcs3/rpcs3qt/tooltips.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class Tooltips : public QObject
const QString force_high_pz = tr("Only useful when debugging differences in GPU hardware.\nNot necessary for average users.\nIf unsure, don't use this option.");
const QString debug_output = tr("Enables the selected API's inbuilt debugging functionality.\nWill cause severe performance degradation especially with Vulkan.\nOnly useful to developers.\nIf unsure, don't use this option.");
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 other debug overlay is disabled.\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.");
Expand Down

0 comments on commit 10b113c

Please sign in to comment.