Skip to content

Commit 49323d4

Browse files
committed
cellGem: add debug overlay
1 parent 86b2773 commit 49323d4

18 files changed

+240
-18
lines changed

rpcs3/Emu/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ target_sources(rpcs3_emu PRIVATE
486486
RSX/NV47/HW/nv308a.cpp
487487
RSX/NV47/HW/nv406e.cpp
488488
RSX/NV47/HW/nv4097.cpp
489+
RSX/Overlays/Debug/overlay_ps_move_debug.cpp
489490
RSX/Overlays/FriendsList/overlay_friends_list_dialog.cpp
490491
RSX/Overlays/HomeMenu/overlay_home_menu.cpp
491492
RSX/Overlays/HomeMenu/overlay_home_menu_components.cpp

rpcs3/Emu/Cell/Modules/cellGem.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
#include "Emu/System.h"
1515
#include "Emu/IdManager.h"
1616
#include "Emu/RSX/Overlays/overlay_cursor.h"
17+
#include "Emu/RSX/Overlays/overlay_manager.h"
18+
#include "Emu/RSX/Overlays/Debug/overlay_ps_move_debug.h"
1719
#include "Input/pad_thread.h"
1820
#include "Input/ps_move_config.h"
1921
#include "Input/ps_move_tracker.h"
@@ -1783,6 +1785,23 @@ static inline void draw_overlay_cursor(u32 gem_num, const gem_config::gem_contro
17831785
rsx::overlays::set_cursor(rsx::overlays::cursor_offset::cell_gem + gem_num, x, y, color, 2'000'000, false);
17841786
}
17851787

1788+
static void show_ps_move_debug_overlay(u32 gem_num, const ps_move_data& md, const CellGemState& state)
1789+
{
1790+
if (gem_num != 0 || !g_cfg.misc.use_native_interface)
1791+
return;
1792+
1793+
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
1794+
{
1795+
if (auto overlay = manager->get<rsx::overlays::ps_move_debug_overlay>())
1796+
{
1797+
const gem_config_data::gem_color& rgb = gem_config_data::gem_color::get_default_color(gem_num);
1798+
1799+
// Use quaternion from state instead of ps_move_data so that we can also check the fake/mouse move
1800+
overlay->show(md, rgb.r, rgb.g, rgb.b, state.quat[0], state.quat[1], state.quat[2], state.quat[3], state.pad.digitalbuttons, state.pad.analog_T);
1801+
}
1802+
}
1803+
}
1804+
17861805
static inline void pos_to_gem_image_state(u32 gem_num, gem_config::gem_controller& controller, vm::ptr<CellGemImageState>& gem_image_state, s32 x_pos, s32 y_pos, s32 x_max, s32 y_max)
17871806
{
17881807
const auto& shared_data = g_fxo->get<gem_camera_shared>();
@@ -1930,6 +1949,11 @@ static inline void pos_to_gem_state(u32 gem_num, gem_config::gem_controller& con
19301949
controller.radius_valid = x_pos > 0 && x_pos < x_max && y_pos > 0 && y_pos < y_max;
19311950
}
19321951

1952+
if (g_cfg.io.ps_move_debug_overlay)
1953+
{
1954+
show_ps_move_debug_overlay(gem_num, move_data, *gem_state);
1955+
}
1956+
19331957
if (g_cfg.io.show_move_cursor)
19341958
{
19351959
draw_overlay_cursor(gem_num, controller, x_pos, y_pos, x_max, y_max);
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#include "stdafx.h"
2+
#include "overlay_ps_move_debug.h"
3+
4+
namespace rsx
5+
{
6+
namespace overlays
7+
{
8+
ps_move_debug_overlay::ps_move_debug_overlay()
9+
{
10+
m_frame.set_pos(0, 0);
11+
m_frame.set_size(300, 300);
12+
m_frame.back_color.r = 0.0f;
13+
m_frame.back_color.g = 0.0f;
14+
m_frame.back_color.b = 0.0f;
15+
m_frame.back_color.a = 1.0f;
16+
17+
m_text_view.set_pos(10, 10);
18+
m_text_view.set_padding(0, 0, 0, 0);
19+
m_text_view.set_font("n023055ms.ttf", 6);
20+
m_text_view.align_text(overlay_element::text_align::left);
21+
m_text_view.fore_color = { 0.3f, 1.f, 0.3f, 1.f };
22+
m_text_view.back_color.a = 0.f;
23+
}
24+
25+
compiled_resource ps_move_debug_overlay::get_compiled()
26+
{
27+
if (!visible)
28+
{
29+
return {};
30+
}
31+
32+
auto result = m_frame.get_compiled();
33+
result.add(m_text_view.get_compiled());
34+
35+
// Move cylinder so its center is at origin
36+
//glTranslatef(0, 0, 0.5f);
37+
38+
// Apply quaternion rotation
39+
//QMatrix4x4 model;
40+
//model.rotate(QQuaternion(m_quaternion[3], m_quaternion[0], m_quaternion[1], m_quaternion[2]));
41+
//glMultMatrixf(model.constData());
42+
43+
// Move back to original position
44+
//glTranslatef(0, 0, -0.5f);
45+
46+
// Draw controller body
47+
//glColor3ub(200, 200, 200);
48+
//drawCylinder(0.2f, 0.8f, 32);
49+
50+
// Draw front sphere
51+
//glColor3f(m_rgb[0], m_rgb[1], m_rgb[2]);
52+
//glPushMatrix();
53+
//glTranslatef(0, 0, 0.8f); // move to front
54+
//drawSphere(0.3f, 32, 32);
55+
//glPopMatrix();
56+
57+
// Draw button
58+
//glColor3ub(0, 0, 200);
59+
//glPushMatrix();
60+
//glTranslatef(0, 0.2f, 0.4f); // slightly in front of the sphere
61+
//drawButton(0.08f, 0.05f, 16);
62+
//glPopMatrix();
63+
64+
return result;
65+
}
66+
67+
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, u16 digitalbuttons, u16 analog_T)
68+
{
69+
visible = true;
70+
71+
if (m_rgb[0] == r && m_rgb[1] == g && m_rgb[2] == b &&
72+
m_quaternion[0] == q0 && m_quaternion[1] == q1 && m_quaternion[2] == q2 && m_quaternion[3] == q3 &&
73+
std::memcmp(static_cast<const void*>(&md), static_cast<const void*>(&m_move_data), sizeof(ps_move_data)) == 0)
74+
{
75+
return;
76+
}
77+
78+
m_move_data = md;
79+
m_rgb = { r, g, b };
80+
m_quaternion = { q0, q1, q2, q3 };
81+
82+
m_text_view.set_text(fmt::format(
83+
"> Quat X: %6.2f Gyro X: %6.2f Accel X: %6.2f Mag X: %6.2f\n"
84+
"> Quat Y: %6.2f Gyro Y: %6.2f Accel Y: %6.2f Mag Y: %6.2f\n"
85+
"> Quat Z: %6.2f Gyro Z: %6.2f Accel Z: %6.2f Mag Z: %6.2f\n"
86+
"> Quat W: %6.2f\n\n"
87+
"> World\n"
88+
"> Vel X: %9.2f\n"
89+
"> Vel Y: %9.2f\n"
90+
"> Vel Z: %9.2f\n"
91+
"> Acc X: %9.2f\n"
92+
"> Acc Y: %9.2f\n"
93+
"> Acc Z: %9.2f\n"
94+
"> AngVel X: %9.2f\n"
95+
"> AngVel Y: %9.2f\n"
96+
"> AngVel Z: %9.2f\n"
97+
"> AngAcc X: %9.2f\n"
98+
"> AngAcc Y: %9.2f\n"
99+
"> AngAcc Z: %9.2f\n"
100+
"> Buttons : 0x%x\n"
101+
"> Analog T: %d"
102+
,
103+
m_quaternion[0], md.gyro[0], md.accelerometer[0], md.magnetometer[0],
104+
m_quaternion[1], md.gyro[1], md.accelerometer[1], md.magnetometer[1],
105+
m_quaternion[2], md.gyro[2], md.accelerometer[2], md.magnetometer[2],
106+
m_quaternion[3],
107+
md.vel_world[0],
108+
md.vel_world[1],
109+
md.vel_world[2],
110+
md.accel_world[0],
111+
md.accel_world[1],
112+
md.accel_world[2],
113+
md.angvel_world[0],
114+
md.angvel_world[1],
115+
md.angvel_world[2],
116+
md.angaccel_world[0],
117+
md.angaccel_world[1],
118+
md.angaccel_world[2],
119+
digitalbuttons,
120+
analog_T
121+
));
122+
m_text_view.auto_resize();
123+
124+
refresh();
125+
}
126+
} // namespace overlays
127+
} // namespace rsx
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#pragma once
2+
3+
#include "../overlays.h"
4+
#include "Emu/Io/pad_types.h"
5+
6+
namespace rsx
7+
{
8+
namespace overlays
9+
{
10+
struct ps_move_debug_overlay : public user_interface
11+
{
12+
public:
13+
ps_move_debug_overlay();
14+
15+
compiled_resource get_compiled() override;
16+
17+
void show(const ps_move_data& md, f32 r, f32 g, f32 b, f32 q0, f32 q1, f32 q2, f32 q3, u16 digitalbuttons, u16 analog_T);
18+
19+
private:
20+
overlay_element m_frame;
21+
label m_text_view;
22+
23+
ps_move_data m_move_data {};
24+
std::array<f32, 3> m_rgb {};
25+
std::array<f32, 4> m_quaternion {};
26+
};
27+
}
28+
}

rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ namespace rsx
149149
add_checkbox(&g_cfg.video.debug_overlay, localized_string_id::HOME_MENU_SETTINGS_DEBUG_OVERLAY);
150150
add_checkbox(&g_cfg.io.pad_debug_overlay, localized_string_id::HOME_MENU_SETTINGS_DEBUG_INPUT_OVERLAY);
151151
add_checkbox(&g_cfg.io.mouse_debug_overlay, localized_string_id::HOME_MENU_SETTINGS_MOUSE_DEBUG_INPUT_OVERLAY);
152+
add_checkbox(&g_cfg.io.ps_move_debug_overlay, localized_string_id::HOME_MENU_SETTINGS_PS_MOVE_DEBUG_INPUT_OVERLAY);
152153
add_checkbox(&g_cfg.video.disable_video_output, localized_string_id::HOME_MENU_SETTINGS_DEBUG_DISABLE_VIDEO_OUTPUT);
153154
add_float_slider(&g_cfg.video.texture_lod_bias, localized_string_id::HOME_MENU_SETTINGS_DEBUG_TEXTURE_LOD_BIAS, "", 0.25f);
154155

rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "stdafx.h"
22
#include "overlay_manager.h"
33
#include "overlay_debug_overlay.h"
4+
#include "Debug/overlay_ps_move_debug.h"
45
#include "Emu/system_config.h"
56

67
namespace rsx
@@ -41,14 +42,15 @@ namespace rsx
4142
visible = true;
4243
}
4344

44-
extern void reset_debug_overlay()
45+
extern void reset_debug_overlays()
4546
{
4647
if (!g_cfg.misc.use_native_interface)
4748
return;
4849

4950
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
5051
{
5152
auto overlay = manager->get<rsx::overlays::debug_overlay>();
53+
auto ps_move_overlay = manager->get<rsx::overlays::ps_move_debug_overlay>();
5254

5355
if (g_cfg.video.debug_overlay || g_cfg.io.pad_debug_overlay || g_cfg.io.mouse_debug_overlay)
5456
{
@@ -61,6 +63,18 @@ namespace rsx
6163
{
6264
manager->remove<rsx::overlays::debug_overlay>();
6365
}
66+
67+
if (g_cfg.io.ps_move_debug_overlay)
68+
{
69+
if (!ps_move_overlay)
70+
{
71+
ps_move_overlay = manager->create<rsx::overlays::ps_move_debug_overlay>();
72+
}
73+
}
74+
else if (ps_move_overlay)
75+
{
76+
manager->remove<rsx::overlays::ps_move_debug_overlay>();
77+
}
6478
}
6579
}
6680

rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace rsx
1919
void set_text(std::string&& text);
2020
};
2121

22-
void reset_debug_overlay();
22+
void reset_debug_overlays();
2323
void set_debug_overlay_text(std::string&& text);
2424
}
2525
}

rpcs3/Emu/RSX/RSXThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ namespace rsx
929929
if (!serialized) method_registers.init();
930930

931931
rsx::overlays::reset_performance_overlay();
932-
rsx::overlays::reset_debug_overlay();
932+
rsx::overlays::reset_debug_overlays();
933933

934934
if (!is_initialized)
935935
{

rpcs3/Emu/localized_string_id.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ enum class localized_string_id
267267
HOME_MENU_SETTINGS_DEBUG_OVERLAY,
268268
HOME_MENU_SETTINGS_DEBUG_INPUT_OVERLAY,
269269
HOME_MENU_SETTINGS_MOUSE_DEBUG_INPUT_OVERLAY,
270+
HOME_MENU_SETTINGS_PS_MOVE_DEBUG_INPUT_OVERLAY,
270271
HOME_MENU_SETTINGS_DEBUG_DISABLE_VIDEO_OUTPUT,
271272
HOME_MENU_SETTINGS_DEBUG_TEXTURE_LOD_BIAS,
272273
HOME_MENU_SCREENSHOT,

rpcs3/Emu/system_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ struct cfg_root : cfg::node
285285
cfg::_bool load_sdl_mappings{ this, "Load SDL GameController Mappings", true };
286286
cfg::_bool pad_debug_overlay{ this, "IO Debug overlay", false, true };
287287
cfg::_bool mouse_debug_overlay{ this, "Mouse Debug overlay", false, true };
288+
cfg::_bool ps_move_debug_overlay{ this, "PS Move Debug overlay", false, true };
288289
cfg::uint<1, 180> fake_move_rotation_cone_h{ this, "Fake Move Rotation Cone", 10, true };
289290
cfg::uint<1, 180> fake_move_rotation_cone_v{ this, "Fake Move Rotation Cone (Vertical)", 10, true };
290291

0 commit comments

Comments
 (0)