From 6b11ebfb9f45d11ab2780473edcf1de7c55171bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 22 Nov 2024 23:20:24 +0100 Subject: [PATCH] ImDebugger: Fix a bunch of keyboard shortcuts --- UI/ImDebugger/ImDebugger.h | 8 ++ UI/ImDebugger/ImDisasmView.cpp | 154 ++++++++++++++++----------------- UI/ImDebugger/ImDisasmView.h | 2 +- UI/ImDebugger/ImGe.h | 5 ++ 4 files changed, 89 insertions(+), 80 deletions(-) diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 28c67bc511..5e70c02383 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -73,6 +73,14 @@ struct ImConfig { int selectedFramebuffer = -1; }; +enum ImUiCmd { + TRIGGER_FIND_POPUP = 0, +}; + +struct ImUiCommand { + ImUiCmd cmd; +}; + struct ImDebugger { void Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebug); diff --git a/UI/ImDebugger/ImDisasmView.cpp b/UI/ImDebugger/ImDisasmView.cpp index 611bdd12ca..36a47931c7 100644 --- a/UI/ImDebugger/ImDisasmView.cpp +++ b/UI/ImDebugger/ImDisasmView.cpp @@ -267,7 +267,7 @@ std::set ImDisasmView::getSelectedLineArguments() { return args; } -void ImDisasmView::drawArguments(ImDrawList *drawList, Rect rc, const DisassemblyLineInfo &line, int x, int y, ImColor textColor, const std::set ¤tArguments) { +void ImDisasmView::drawArguments(ImDrawList *drawList, Rect rc, const DisassemblyLineInfo &line, float x, float y, ImColor textColor, const std::set ¤tArguments) { if (line.params.empty()) { return; } @@ -559,74 +559,86 @@ void ImDisasmView::editBreakpoint() { void ImDisasmView::ProcessKeyboardShortcuts() { u32 windowEnd = manager.getNthNextAddress(windowStart_, visibleRows_); keyTaken = true; - if (ImGui::IsKeyPressed(ImGuiKey_PageDown)) { - windowStart_ = manager.getNthNextAddress(windowStart_, visibleRows_); - } - if (ImGui::IsKeyPressed(ImGuiKey_PageUp)) { - windowStart_ = manager.getNthPreviousAddress(windowStart_, visibleRows_); - } - if (ImGui::IsKeyPressed(ImGuiKey_F3)) { - SearchNext(!ImGui::IsKeyPressed(ImGuiKey_LeftShift)); - } - if (ImGui::IsKeyPressed(ImGuiKey_X)) { - disassembleToFile(); + + ImGuiIO& io = ImGui::GetIO(); + + if (io.KeyMods & ImGuiMod_Ctrl) { + if (ImGui::IsKeyPressed(ImGuiKey_F)) { + // Toggle the find popup + ImGui::OpenPopup("disSearch"); + } + if (ImGui::IsKeyPressed(ImGuiKey_C) || ImGui::IsKeyPressed(ImGuiKey_Insert)) { + CopyInstructions(selectRangeStart_, selectRangeEnd_, CopyInstructionsMode::DISASM); + } + if (ImGui::IsKeyPressed(ImGuiKey_X)) { + // disassembleToFile(); + } + if (ImGui::IsKeyPressed(ImGuiKey_A)) { + // assembleOpcode(curAddress, ""); + } + if (ImGui::IsKeyPressed(ImGuiKey_G)) { + // Goto. should just focus on the goto input? + // u32 addr; + // if (executeExpressionWindow(wnd, debugger, addr) == false) return; + // gotoAddr(addr); + } + if (ImGui::IsKeyPressed(ImGuiKey_E)) { + editBreakpoint(); + } + if (ImGui::IsKeyPressed(ImGuiKey_D)) { + toggleBreakpoint(true); + } + if (ImGui::IsKeyPressed(ImGuiKey_UpArrow)) { + ScrollRelative(-1); + ScanVisibleFunctions(); + } + if (ImGui::IsKeyPressed(ImGuiKey_DownArrow)) { + ScrollRelative(1); + ScanVisibleFunctions(); + } + if (ImGui::IsKeyPressed(ImGuiKey_PageDown)) { + setCurAddress(manager.getNthPreviousAddress(windowEnd, 1), (io.KeyMods & ImGuiMod_Shift) != 0); + } + if (ImGui::IsKeyPressed(ImGuiKey_PageUp)) { + setCurAddress(windowStart_, ImGui::IsKeyDown(ImGuiKey_LeftShift)); + } + } else { + if (ImGui::IsKeyPressed(ImGuiKey_PageDown)) { + windowStart_ = manager.getNthNextAddress(windowStart_, visibleRows_); + } + if (ImGui::IsKeyPressed(ImGuiKey_PageUp)) { + windowStart_ = manager.getNthPreviousAddress(windowStart_, visibleRows_); + } + if (ImGui::IsKeyPressed(ImGuiKey_F3)) { + SearchNext(!ImGui::IsKeyPressed(ImGuiKey_LeftShift)); + } + if (ImGui::IsKeyPressed(ImGuiKey_DownArrow)) { + setCurAddress(manager.getNthNextAddress(curAddress_, 1), (io.KeyMods & ImGuiMod_Shift) != 0); + scrollAddressIntoView(); + } + if (ImGui::IsKeyPressed(ImGuiKey_UpArrow)) { + setCurAddress(manager.getNthPreviousAddress(curAddress_, 1), (io.KeyMods & ImGuiMod_Shift) != 0); + scrollAddressIntoView(); + } + if (ImGui::IsKeyPressed(ImGuiKey_RightArrow)) { + FollowBranch(); + } + if (ImGui::IsKeyPressed(ImGuiKey_LeftArrow)) { + if (jumpStack_.empty()) { + gotoPC(); + } else { + u32 addr = jumpStack_[jumpStack_.size() - 1]; + jumpStack_.pop_back(); + gotoAddr(addr); + } + return; + } } /* if (KeyDownAsync(VK_CONTROL)) { - switch (tolower(wParam & 0xFFFF)) { - case 'f': - case 's': - search(false); - break; - case 'c': - case VK_INSERT: - CopyInstructions(selectRangeStart, selectRangeEnd, CopyInstructionsMode::DISASM); - break; - case 'x': - disassembleToFile(); - break; - case 'a': - assembleOpcode(curAddress, ""); - break; - case 'g': - { - u32 addr; - if (executeExpressionWindow(wnd, debugger, addr) == false) return; - gotoAddr(addr); - } - break; - case 'e': // edit breakpoint - editBreakpoint(); - break; - case 'd': // toogle breakpoint enabled - toggleBreakpoint(true); - break; - case VK_UP: - scrollWindow(-1); - ScanVisibleFunctions(); - break; - case VK_DOWN: - scrollWindow(1); - ScanVisibleFunctions(); - break; - case VK_NEXT: - setCurAddress(manager.getNthPreviousAddress(windowEnd, 1), KeyDownAsync(VK_SHIFT)); - break; - case VK_PRIOR: - setCurAddress(windowStart_, KeyDownAsync(VK_SHIFT)); - break; - } } else { switch (wParam & 0xFFFF) { - case VK_DOWN: - setCurAddress(manager.getNthNextAddress(curAddress, 1), KeyDownAsync(VK_SHIFT)); - scrollAddressIntoView(); - break; - case VK_UP: - setCurAddress(manager.getNthPreviousAddress(curAddress, 1), KeyDownAsync(VK_SHIFT)); - scrollAddressIntoView(); - break; case VK_NEXT: if (manager.getNthNextAddress(curAddress, 1) != windowEnd && curAddressIsVisible()) { setCurAddress(manager.getNthPreviousAddress(windowEnd, 1), KeyDownAsync(VK_SHIFT)); @@ -645,28 +657,12 @@ void ImDisasmView::ProcessKeyboardShortcuts() { scrollAddressIntoView(); } break; - case VK_LEFT: - if (jumpStack.empty()) - { - gotoPC(); - } else { - u32 addr = jumpStack[jumpStack.size() - 1]; - jumpStack.pop_back(); - gotoAddr(addr); - } - return; - case VK_RIGHT: - FollowBranch(); - return; case VK_TAB: displaySymbols_ = !displaySymbols_; break; case VK_SPACE: debugger->toggleBreakpoint(curAddress); break; - case VK_F3: - search(true); - break; default: keyTaken = false; return; diff --git a/UI/ImDebugger/ImDisasmView.h b/UI/ImDebugger/ImDisasmView.h index 84f36529a5..5143b22af5 100644 --- a/UI/ImDebugger/ImDisasmView.h +++ b/UI/ImDebugger/ImDisasmView.h @@ -134,7 +134,7 @@ private: void CopyInstructions(u32 startAddr, u32 endAddr, CopyInstructionsMode mode); void NopInstructions(u32 startAddr, u32 endAddr); std::set getSelectedLineArguments(); - void drawArguments(ImDrawList *list, ImDisasmView::Rect rc, const DisassemblyLineInfo &line, int x, int y, ImColor textColor, const std::set ¤tArguments); + void drawArguments(ImDrawList *list, ImDisasmView::Rect rc, const DisassemblyLineInfo &line, float x, float y, ImColor textColor, const std::set ¤tArguments); DisassemblyManager manager; u32 curAddress_ = 0; diff --git a/UI/ImDebugger/ImGe.h b/UI/ImDebugger/ImGe.h index f8d71901c3..958465ba17 100644 --- a/UI/ImDebugger/ImGe.h +++ b/UI/ImDebugger/ImGe.h @@ -7,3 +7,8 @@ struct ImConfig; class FramebufferManagerCommon; void DrawFramebuffersWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager); + +class ImGeDebugger { +public: + +};