diff --git a/CMakeLists.txt b/CMakeLists.txt index a21c3d12ac..043e3a35d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1989,6 +1989,7 @@ set(GPU_SOURCES GPU/Debugger/State.h GPU/Debugger/Stepping.cpp GPU/Debugger/Stepping.h + GPU/Debugger/Watch.h GPU/ge_constants.h GPU/GeConstants.cpp GPU/GPUDefinitions.h diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 946f5a31a7..46a96fce2f 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -1842,11 +1842,11 @@ void ImWatchWindow::Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface * watches_.push_back(WatchInfo("untitled", "[0x88000000]", mipsDebug)); } - if (ImGui::BeginTable("watches", 4, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH)) { - ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("Expression", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed); - ImGui::TableSetupColumn("Actions", ImGuiTableColumnFlags_WidthFixed); + if (ImGui::BeginTable("watches", 4, ImGuiTableFlags_RowBg | ImGuiTableFlags_BordersH | ImGuiTableFlags_Resizable)) { + ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed, 120.0f); + ImGui::TableSetupColumn("Expression", ImGuiTableColumnFlags_WidthFixed, 120.0f); + ImGui::TableSetupColumn("Value", ImGuiTableColumnFlags_WidthFixed, 100.0f); + ImGui::TableSetupColumn("Actions", ImGuiTableColumnFlags_WidthFixed, 50.0f); ImGui::TableHeadersRow(); @@ -1857,11 +1857,39 @@ void ImWatchWindow::Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface * ImGui::TableNextColumn(); ImGui::TextUnformatted(watch.name.c_str()); ImGui::TableNextColumn(); - ImGui::TextUnformatted(watch.originalExpression.c_str()); + if (editingWatchIndex_ == i && editingColumn_ == 1) { + ImGui::SetNextItemWidth(-1.0f); // Full width + if (setEditFocus_) { + ImGui::FocusItem(); + setEditFocus_ = false; + } + bool confirmed = ImGui::InputText("##edit", editBuffer_, ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_AutoSelectAll); + // Filter for only enter presses + confirmed = confirmed && ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_KeypadEnter); + if (confirmed || ImGui::IsItemDeactivated()) { + watch.SetExpression(editBuffer_, mipsDebug); + editingWatchIndex_ = -1; + } + } else { + ImGui::SetNextItemWidth(-1.0f); // Full width + ImGui::TextUnformatted(watch.originalExpression.c_str()); + auto cellRect = ImGui::TableGetCellBgRect(ImGui::GetCurrentTable(), 1); + bool cellHovered = ImGui::IsMouseHoveringRect(cellRect.Min, cellRect.Max); + if (cellHovered && ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)) { + editingWatchIndex_ = i; + editingColumn_ = 1; + truncate_cpy(editBuffer_, watch.originalExpression.c_str()); + setEditFocus_ = true; + } + } ImGui::TableNextColumn(); if (watch.evaluateFailed) { ImGui::TextUnformatted("(Error)"); } else { + bool changed = watch.currentValue != watch.lastValue; + if (changed) { + //ImGui::PushStyleColor(ImGuiCol_Text, ImDebuggerColor_Diff); + } const uint32_t value = watch.currentValue; float valuef = 0.0f; switch (watch.format) { @@ -1884,11 +1912,27 @@ void ImWatchWindow::Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface * } break; } + if (changed) { + //ImGui::PopStyleColor(ImGuiCol_Text); + } } ImGui::TableNextColumn(); if (ImGui::SmallButton("X")) { watches_.erase(watches_.begin() + i); } + ImGui::SameLine(); + if (ImGui::Button("Type")) { + ImGui::OpenPopup("watchType"); + } + if (ImGui::BeginPopup("watchType")) { + ImGui::Text("Watch type"); + if (ImGui::MenuItem("Hex", nullptr, watch.format == WatchFormat::HEX)) { watch.format = WatchFormat::HEX; } + if (ImGui::MenuItem("Int", nullptr, watch.format == WatchFormat::INT)) { watch.format = WatchFormat::INT; } + if (ImGui::MenuItem("Float", nullptr, watch.format == WatchFormat::FLOAT)) { watch.format = WatchFormat::FLOAT; } + if (ImGui::MenuItem("Str", nullptr, watch.format == WatchFormat::STR)) { watch.format = WatchFormat::STR; } + ImGui::EndPopup(); + } + ImGui::PopID(); } diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 81ed7b507f..e898325338 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -134,9 +134,6 @@ public: std::unique_ptr track_; std::string error_; std::string data_; - - int editingWatchIndex_ = -1; - int editingColumn_ = 0; }; class ImWatchWindow { @@ -145,6 +142,11 @@ public: void Draw(ImConfig &cfg, ImControl &control, MIPSDebugInterface *mipsDebug); private: std::vector watches_; + + char editBuffer_[256]; + int editingWatchIndex_ = -1; + int editingColumn_ = 0; + bool setEditFocus_ = false; }; enum class ImCmd { diff --git a/Windows/HidInputDevice.cpp b/Windows/HidInputDevice.cpp index 7e3665f914..53809e4e92 100644 --- a/Windows/HidInputDevice.cpp +++ b/Windows/HidInputDevice.cpp @@ -386,7 +386,7 @@ HANDLE OpenFirstHIDController(HIDControllerType *subType, int *reportSize, int * *reportSize = caps.InputReportByteLength; *outReportSize = caps.OutputReportByteLength; - INFO_LOG(Log::UI, "Initializing gamepad. out report size=%d", outReportSize); + INFO_LOG(Log::UI, "Initializing gamepad. out report size=%d", *outReportSize); bool result; switch (*subType) { case HIDControllerType::DS5: