diff --git a/rpcs3/Emu/Cell/Modules/cellMouse.cpp b/rpcs3/Emu/Cell/Modules/cellMouse.cpp index 8bf550a633..750b463c0c 100644 --- a/rpcs3/Emu/Cell/Modules/cellMouse.cpp +++ b/rpcs3/Emu/Cell/Modules/cellMouse.cpp @@ -1,8 +1,9 @@ #include "stdafx.h" #include "Emu/IdManager.h" +#include "Emu/system_config.h" #include "Emu/Cell/PPUModule.h" - #include "Emu/Io/MouseHandler.h" +#include "Emu/RSX/Overlays/overlay_debug_overlay.h" #include "cellMouse.h" @@ -13,6 +14,54 @@ extern bool is_input_allowed(); LOG_CHANNEL(cellMouse); +void show_debug_overlay(const CellMouseData& data, const MouseData* _mouse) +{ + // The cell mouse can be set empty without any new mouse input. + // Only update our mouse input if there is new data. + static MouseData mouse {}; + if (_mouse) + { + mouse = *_mouse; + } + + std::string text = fmt::format( + "> Name: Raw Value Pixel\n" + ">\n" + "> Update: %5d %5d\n" + "> Wheel: %5d %5d\n" + "> Tilt: %5d %5d\n" + "> X: %5d %5d %5d\n" + "> Y: %5d %5d %5d\n" + ">\n" + "> Buttons: 0x%04x 0x%04x\n" + "> Button 1: %5d %5d\n" + "> Button 2: %5d %5d\n" + "> Button 3: %5d %5d\n" + "> Button 4: %5d %5d\n" + "> Button 5: %5d %5d\n" + "> Button 6: %5d %5d\n" + "> Button 7: %5d %5d\n" + "> Button 8: %5d %5d\n" + , + mouse.update, data.update, + mouse.wheel, data.wheel, + mouse.tilt, data.tilt, + mouse.x_axis, data.x_axis, mouse.pixel_x, + mouse.y_axis, data.y_axis, mouse.pixel_y, + mouse.buttons, data.buttons, + !!(mouse.buttons & CELL_MOUSE_BUTTON_1), !!(data.buttons & CELL_MOUSE_BUTTON_1), + !!(mouse.buttons & CELL_MOUSE_BUTTON_2), !!(data.buttons & CELL_MOUSE_BUTTON_2), + !!(mouse.buttons & CELL_MOUSE_BUTTON_3), !!(data.buttons & CELL_MOUSE_BUTTON_3), + !!(mouse.buttons & CELL_MOUSE_BUTTON_4), !!(data.buttons & CELL_MOUSE_BUTTON_4), + !!(mouse.buttons & CELL_MOUSE_BUTTON_5), !!(data.buttons & CELL_MOUSE_BUTTON_5), + !!(mouse.buttons & CELL_MOUSE_BUTTON_6), !!(data.buttons & CELL_MOUSE_BUTTON_6), + !!(mouse.buttons & CELL_MOUSE_BUTTON_7), !!(data.buttons & CELL_MOUSE_BUTTON_7), + !!(mouse.buttons & CELL_MOUSE_BUTTON_8), !!(data.buttons & CELL_MOUSE_BUTTON_8) + ); + + rsx::overlays::set_debug_overlay_text(std::move(text)); +} + template<> void fmt_class_string::format(std::string& out, u64 arg) { @@ -214,10 +263,16 @@ error_code cellMouseGetData(u32 port_no, vm::ptr data) if (data_list.empty() || current_info.is_null_handler || (current_info.info & CELL_MOUSE_INFO_INTERCEPTED) || !is_input_allowed()) { data_list.clear(); + + if (port_no == 0 && g_cfg.io.mouse_debug_overlay && !g_cfg.io.pad_debug_overlay && !g_cfg.video.debug_overlay) + { + show_debug_overlay(*data, nullptr); + } + return CELL_OK; } - const MouseData current_data = data_list.front(); + const MouseData& current_data = data_list.front(); data->update = current_data.update; data->buttons = current_data.buttons; data->x_axis = current_data.x_axis; @@ -225,6 +280,11 @@ error_code cellMouseGetData(u32 port_no, vm::ptr data) data->wheel = current_data.wheel; data->tilt = current_data.tilt; + if (port_no == 0 && g_cfg.io.mouse_debug_overlay && !g_cfg.io.pad_debug_overlay && !g_cfg.video.debug_overlay) + { + show_debug_overlay(*data, ¤t_data); + } + data_list.pop_front(); return CELL_OK; @@ -264,20 +324,31 @@ error_code cellMouseGetDataList(u32 port_no, vm::ptr data) if (list.empty() || current_info.is_null_handler || (current_info.info & CELL_MOUSE_INFO_INTERCEPTED) || !is_input_allowed()) { list.clear(); + + if (port_no == 0 && g_cfg.io.mouse_debug_overlay && !g_cfg.io.pad_debug_overlay && !g_cfg.video.debug_overlay) + { + show_debug_overlay(data->list[0], nullptr); + } + return CELL_OK; } data->list_num = std::min(CELL_MOUSE_MAX_DATA_LIST_NUM, static_cast(list.size())); - int i = 0; - for (auto it = list.begin(); it != list.end() && i < CELL_MOUSE_MAX_DATA_LIST_NUM; ++it, ++i) + for (size_t i = 0; i < list.size() && i < CELL_MOUSE_MAX_DATA_LIST_NUM; ++i) { - data->list[i].update = it->update; - data->list[i].buttons = it->buttons; - data->list[i].x_axis = it->x_axis; - data->list[i].y_axis = it->y_axis; - data->list[i].wheel = it->wheel; - data->list[i].tilt = it->tilt; + const MouseData& current_data = list[i]; + data->list[i].update = current_data.update; + data->list[i].buttons = current_data.buttons; + data->list[i].x_axis = current_data.x_axis; + data->list[i].y_axis = current_data.y_axis; + data->list[i].wheel = current_data.wheel; + data->list[i].tilt = current_data.tilt; + + if (port_no == 0 && g_cfg.io.mouse_debug_overlay && !g_cfg.io.pad_debug_overlay && !g_cfg.video.debug_overlay) + { + show_debug_overlay(data->list[i], ¤t_data); + } } list.clear(); diff --git a/rpcs3/Emu/Cell/Modules/cellPad.cpp b/rpcs3/Emu/Cell/Modules/cellPad.cpp index be9194fd84..a1b345badd 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPad.cpp @@ -721,7 +721,7 @@ error_code cellPadGetData(u32 port_no, vm::ptr data) pad_get_data(port_no, data.get_ptr()); - if (g_cfg.io.debug_overlay && !g_cfg.video.debug_overlay && port_no == 0) + if (g_cfg.io.pad_debug_overlay && !g_cfg.video.debug_overlay && port_no == 0) { show_debug_overlay(*data, *pad, config); } diff --git a/rpcs3/Emu/Io/MouseHandler.cpp b/rpcs3/Emu/Io/MouseHandler.cpp index c80d7556dc..9fd37463cd 100644 --- a/rpcs3/Emu/Io/MouseHandler.cpp +++ b/rpcs3/Emu/Io/MouseHandler.cpp @@ -71,6 +71,8 @@ void MouseHandlerBase::Button(u32 index, u8 button, bool pressed) MouseData new_data{}; new_data.update = CELL_MOUSE_DATA_UPDATE; new_data.buttons = mouse.buttons; + new_data.pixel_x = mouse.x_pos; + new_data.pixel_y = mouse.y_pos; datalist.push_back(std::move(new_data)); } @@ -100,6 +102,8 @@ void MouseHandlerBase::Scroll(u32 index, s8 x, s8 y) new_data.buttons = mouse.buttons; new_data.wheel = y; new_data.tilt = x; + new_data.pixel_x = mouse.x_pos; + new_data.pixel_y = mouse.y_pos; datalist.push_back(std::move(new_data)); } @@ -137,6 +141,8 @@ void MouseHandlerBase::Move(u32 index, s32 x_pos_new, s32 y_pos_new, s32 x_max, new_data.x_axis = static_cast(std::clamp(x_delta, -127, 128)); new_data.y_axis = static_cast(std::clamp(y_delta, -127, 128)); + new_data.pixel_x = x_pos_new; + new_data.pixel_y = y_pos_new; mouse.x_max = x_max; mouse.y_max = y_max; diff --git a/rpcs3/Emu/Io/MouseHandler.h b/rpcs3/Emu/Io/MouseHandler.h index 8a88241523..6a77f44d0e 100644 --- a/rpcs3/Emu/Io/MouseHandler.h +++ b/rpcs3/Emu/Io/MouseHandler.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #include #include "Utilities/StrFmt.h" #include "Utilities/mutex.h" @@ -96,6 +96,9 @@ struct MouseData s8 y_axis = 0; s8 wheel = 0; s8 tilt = 0; + + s32 pixel_x = 0; + s32 pixel_y = 0; }; struct MouseTabletData @@ -104,8 +107,8 @@ struct MouseTabletData u8 data[MOUSE_MAX_CODES]{}; }; -using MouseTabletDataList = std::list; -using MouseDataList = std::list; +using MouseTabletDataList = std::deque; +using MouseDataList = std::deque; struct Mouse { 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 119f411a24..c153712443 100644 --- a/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp +++ b/rpcs3/Emu/RSX/Overlays/HomeMenu/overlay_home_menu_settings.cpp @@ -133,7 +133,8 @@ namespace rsx : home_menu_settings_page(x, y, width, height, use_separators, parent, get_localized_string(localized_string_id::HOME_MENU_SETTINGS_DEBUG)) { add_checkbox(&g_cfg.video.debug_overlay, localized_string_id::HOME_MENU_SETTINGS_DEBUG_OVERLAY); - add_checkbox(&g_cfg.io.debug_overlay, localized_string_id::HOME_MENU_SETTINGS_DEBUG_INPUT_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.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 d616737b16..c49dceb144 100644 --- a/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlay_debug_overlay.cpp @@ -50,7 +50,7 @@ namespace rsx { auto overlay = manager->get(); - if (g_cfg.video.debug_overlay || g_cfg.io.debug_overlay) + if (g_cfg.video.debug_overlay || g_cfg.io.pad_debug_overlay || g_cfg.io.mouse_debug_overlay) { if (!overlay) { @@ -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.debug_overlay && !g_cfg.io.debug_overlay)) + if (!g_cfg.misc.use_native_interface || (!g_cfg.video.debug_overlay && !g_cfg.io.pad_debug_overlay && !g_cfg.io.mouse_debug_overlay)) return; if (auto manager = g_fxo->try_get()) diff --git a/rpcs3/Emu/localized_string_id.h b/rpcs3/Emu/localized_string_id.h index 408403fd1f..ce0139943d 100644 --- a/rpcs3/Emu/localized_string_id.h +++ b/rpcs3/Emu/localized_string_id.h @@ -264,6 +264,7 @@ enum class localized_string_id HOME_MENU_SETTINGS_DEBUG, HOME_MENU_SETTINGS_DEBUG_OVERLAY, HOME_MENU_SETTINGS_DEBUG_INPUT_OVERLAY, + HOME_MENU_SETTINGS_MOUSE_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 21f1e550bc..326ed991d6 100644 --- a/rpcs3/Emu/system_config.h +++ b/rpcs3/Emu/system_config.h @@ -285,7 +285,8 @@ 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 }; + cfg::_bool pad_debug_overlay{ this, "IO Debug overlay", false, true }; + cfg::_bool mouse_debug_overlay{ this, "Mouse 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/rpcs3qt/emu_settings_type.h b/rpcs3/rpcs3qt/emu_settings_type.h index 68a158df7a..62d2fbee1a 100644 --- a/rpcs3/rpcs3qt/emu_settings_type.h +++ b/rpcs3/rpcs3qt/emu_settings_type.h @@ -168,6 +168,7 @@ enum class emu_settings_type MidiDevices, SDLMappings, IoDebugOverlay, + MouseDebugOverlay, // Misc ExitRPCS3OnFinish, @@ -357,24 +358,25 @@ inline static const std::map settings_location { emu_settings_type::MusicHandler, { "Audio", "Music Handler"}}, // Input / Output - { emu_settings_type::BackgroundInput, { "Input/Output", "Background input enabled"}}, - { emu_settings_type::ShowMoveCursor, { "Input/Output", "Show move cursor"}}, - { emu_settings_type::LockOvlIptToP1, { "Input/Output", "Lock overlay input to player one"}}, - { emu_settings_type::PadHandlerMode, { "Input/Output", "Pad handler mode"}}, - { emu_settings_type::PadConnection, { "Input/Output", "Keep pads connected" }}, - { emu_settings_type::KeyboardHandler, { "Input/Output", "Keyboard"}}, - { emu_settings_type::MouseHandler, { "Input/Output", "Mouse"}}, - { emu_settings_type::Camera, { "Input/Output", "Camera"}}, - { emu_settings_type::CameraType, { "Input/Output", "Camera type"}}, - { emu_settings_type::CameraFlip, { "Input/Output", "Camera flip"}}, - { emu_settings_type::CameraID, { "Input/Output", "Camera ID"}}, - { emu_settings_type::Move, { "Input/Output", "Move" }}, - { emu_settings_type::Buzz, { "Input/Output", "Buzz emulated controller" }}, - { emu_settings_type::Turntable, { "Input/Output", "Turntable emulated controller" }}, - { 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" }}, + { emu_settings_type::BackgroundInput, { "Input/Output", "Background input enabled"}}, + { emu_settings_type::ShowMoveCursor, { "Input/Output", "Show move cursor"}}, + { emu_settings_type::LockOvlIptToP1, { "Input/Output", "Lock overlay input to player one"}}, + { emu_settings_type::PadHandlerMode, { "Input/Output", "Pad handler mode"}}, + { emu_settings_type::PadConnection, { "Input/Output", "Keep pads connected" }}, + { emu_settings_type::KeyboardHandler, { "Input/Output", "Keyboard"}}, + { emu_settings_type::MouseHandler, { "Input/Output", "Mouse"}}, + { emu_settings_type::Camera, { "Input/Output", "Camera"}}, + { emu_settings_type::CameraType, { "Input/Output", "Camera type"}}, + { emu_settings_type::CameraFlip, { "Input/Output", "Camera flip"}}, + { emu_settings_type::CameraID, { "Input/Output", "Camera ID"}}, + { emu_settings_type::Move, { "Input/Output", "Move" }}, + { emu_settings_type::Buzz, { "Input/Output", "Buzz emulated controller" }}, + { emu_settings_type::Turntable, { "Input/Output", "Turntable emulated controller" }}, + { 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" }}, + { emu_settings_type::MouseDebugOverlay, { "Input/Output", "Mouse 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 1beab0f082..930cf0a1f3 100644 --- a/rpcs3/rpcs3qt/localized_emu.h +++ b/rpcs3/rpcs3qt/localized_emu.h @@ -285,6 +285,7 @@ private: case localized_string_id::HOME_MENU_SETTINGS_DEBUG: return tr("Debug"); 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_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 61052d3379..4ce035722d 100644 --- a/rpcs3/rpcs3qt/settings_dialog.cpp +++ b/rpcs3/rpcs3qt/settings_dialog.cpp @@ -2522,6 +2522,9 @@ settings_dialog::settings_dialog(std::shared_ptr gui_settings, std m_emu_settings->EnhanceCheckBox(ui->debugOverlayIO, emu_settings_type::IoDebugOverlay); SubscribeTooltip(ui->debugOverlayIO, tooltips.settings.debug_overlay_io); + m_emu_settings->EnhanceCheckBox(ui->debugOverlayMouse, emu_settings_type::MouseDebugOverlay); + SubscribeTooltip(ui->debugOverlayMouse, tooltips.settings.debug_overlay_mouse); + // 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 1e8e5a8eef..4c19e65d66 100644 --- a/rpcs3/rpcs3qt/settings_dialog.ui +++ b/rpcs3/rpcs3qt/settings_dialog.ui @@ -4547,6 +4547,13 @@ + + + + Debug Overlay For Mouse Input + + + diff --git a/rpcs3/rpcs3qt/tooltips.h b/rpcs3/rpcs3qt/tooltips.h index 3eea425bb3..6a4745236d 100644 --- a/rpcs3/rpcs3qt/tooltips.h +++ b/rpcs3/rpcs3qt/tooltips.h @@ -113,7 +113,8 @@ public: 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 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 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.");