diff options
Diffstat (limited to 'src/osd/modules/debugger/debugimgui.cpp')
-rw-r--r-- | src/osd/modules/debugger/debugimgui.cpp | 119 |
1 files changed, 68 insertions, 51 deletions
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp index 5f087f70a2e..6221b435f2f 100644 --- a/src/osd/modules/debugger/debugimgui.cpp +++ b/src/osd/modules/debugger/debugimgui.cpp @@ -203,6 +203,7 @@ private: file_entry* m_selected_file; int m_format_sel; char m_path[1024]; // path text field buffer + std::unordered_map<input_item_id,ImGuiKey> m_mapping; }; // globals @@ -350,10 +351,11 @@ void debug_imgui::handle_keys() for(input_item_id id = ITEM_ID_A; id <= ITEM_ID_CANCEL; ++id) { - if(m_machine->input().code_pressed(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id))) - io.KeysDown[id] = true; - else - io.KeysDown[id] = false; + if(m_machine->input().code_pressed(input_code(DEVICE_CLASS_KEYBOARD, 0, ITEM_CLASS_SWITCH, ITEM_MODIFIER_NONE, id))) { + if (m_mapping.count(id)) io.AddKeyEvent(m_mapping[id], true); + } else { + if (m_mapping.count(id)) io.AddKeyEvent(m_mapping[id], false); + } } m_key_char = 0; @@ -372,9 +374,9 @@ void debug_imgui::handle_keys() } // global keys - if(ImGui::IsKeyPressed(ITEM_ID_F3,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F3,false)) { - if(ImGui::IsKeyDown(ITEM_ID_LSHIFT)) + if(ImGui::IsKeyDown(ImGuiKey_LeftShift)) m_machine->schedule_hard_reset(); else { @@ -383,44 +385,44 @@ void debug_imgui::handle_keys() } } - if(ImGui::IsKeyPressed(ITEM_ID_F5,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F5,false)) { m_machine->debugger().console().get_visible_cpu()->debug()->go(); m_running = true; } - if(ImGui::IsKeyPressed(ITEM_ID_F6,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F6,false)) { m_machine->debugger().console().get_visible_cpu()->debug()->go_next_device(); m_running = true; } - if(ImGui::IsKeyPressed(ITEM_ID_F7,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F7,false)) { m_machine->debugger().console().get_visible_cpu()->debug()->go_interrupt(); m_running = true; } - if(ImGui::IsKeyPressed(ITEM_ID_F8,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F8,false)) m_machine->debugger().console().get_visible_cpu()->debug()->go_vblank(); - if(ImGui::IsKeyPressed(ITEM_ID_F9,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F9,false)) m_machine->debugger().console().get_visible_cpu()->debug()->single_step_out(); - if(ImGui::IsKeyPressed(ITEM_ID_F10,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F10,false)) m_machine->debugger().console().get_visible_cpu()->debug()->single_step_over(); - if(ImGui::IsKeyPressed(ITEM_ID_F11,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F11,false)) m_machine->debugger().console().get_visible_cpu()->debug()->single_step(); - if(ImGui::IsKeyPressed(ITEM_ID_F12,false)) + if(ImGui::IsKeyPressed(ImGuiKey_F12,false)) { m_machine->debugger().console().get_visible_cpu()->debug()->go(); m_hide = true; } - if(ImGui::IsKeyPressed(ITEM_ID_D,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyPressed(ImGuiKey_D,false) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) add_disasm(++m_win_count); - if(ImGui::IsKeyPressed(ITEM_ID_M,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyPressed(ImGuiKey_M,false) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) add_memory(++m_win_count); - if(ImGui::IsKeyPressed(ITEM_ID_B,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyPressed(ImGuiKey_B,false) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) add_bpoints(++m_win_count); - if(ImGui::IsKeyPressed(ITEM_ID_W,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyPressed(ImGuiKey_W,false) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) add_wpoints(++m_win_count); - if(ImGui::IsKeyPressed(ITEM_ID_L,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyPressed(ImGuiKey_L,false) && ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) add_log(++m_win_count); } @@ -443,38 +445,38 @@ void debug_imgui::handle_keys_views() return; // pass keypresses to debug view with focus - if(ImGui::IsKeyPressed(ITEM_ID_UP)) + if(ImGui::IsKeyPressed(ImGuiKey_UpArrow)) focus_view->view->process_char(DCH_UP); - if(ImGui::IsKeyPressed(ITEM_ID_DOWN)) + if(ImGui::IsKeyPressed(ImGuiKey_DownArrow)) focus_view->view->process_char(DCH_DOWN); - if(ImGui::IsKeyPressed(ITEM_ID_LEFT)) + if(ImGui::IsKeyPressed(ImGuiKey_LeftArrow)) { - if(ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) focus_view->view->process_char(DCH_CTRLLEFT); else focus_view->view->process_char(DCH_LEFT); } - if(ImGui::IsKeyPressed(ITEM_ID_RIGHT)) + if(ImGui::IsKeyPressed(ImGuiKey_RightArrow)) { - if(ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) focus_view->view->process_char(DCH_CTRLRIGHT); else focus_view->view->process_char(DCH_RIGHT); } - if(ImGui::IsKeyPressed(ITEM_ID_PGUP)) + if(ImGui::IsKeyPressed(ImGuiKey_PageUp)) focus_view->view->process_char(DCH_PUP); - if(ImGui::IsKeyPressed(ITEM_ID_PGDN)) + if(ImGui::IsKeyPressed(ImGuiKey_PageDown)) focus_view->view->process_char(DCH_PDOWN); - if(ImGui::IsKeyPressed(ITEM_ID_HOME)) + if(ImGui::IsKeyPressed(ImGuiKey_Home)) { - if(ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) focus_view->view->process_char(DCH_CTRLHOME); else focus_view->view->process_char(DCH_HOME); } - if(ImGui::IsKeyPressed(ITEM_ID_END)) + if(ImGui::IsKeyPressed(ImGuiKey_End)) { - if(ImGui::IsKeyDown(ITEM_ID_LCONTROL)) + if(ImGui::IsKeyDown(ImGuiKey_LeftCtrl)) focus_view->view->process_char(DCH_CTRLEND); else focus_view->view->process_char(DCH_END); @@ -551,6 +553,8 @@ int debug_imgui::history_set(ImGuiInputTextCallbackData* data) if(history_pos < view_main_console->console_history.size()) history_pos++; break; + default: + break; } if(history_pos == view_main_console->console_history.size()) @@ -1464,26 +1468,39 @@ void debug_imgui::init_debugger(running_machine &machine) m_has_images = true; // map keys to ImGui inputs - io.KeyMap[ImGuiKey_A] = ITEM_ID_A; - io.KeyMap[ImGuiKey_C] = ITEM_ID_C; - io.KeyMap[ImGuiKey_V] = ITEM_ID_V; - io.KeyMap[ImGuiKey_X] = ITEM_ID_X; - io.KeyMap[ImGuiKey_C] = ITEM_ID_C; - io.KeyMap[ImGuiKey_Y] = ITEM_ID_Y; - io.KeyMap[ImGuiKey_Z] = ITEM_ID_Z; - io.KeyMap[ImGuiKey_Backspace] = ITEM_ID_BACKSPACE; - io.KeyMap[ImGuiKey_Delete] = ITEM_ID_DEL; - io.KeyMap[ImGuiKey_Tab] = ITEM_ID_TAB; - io.KeyMap[ImGuiKey_PageUp] = ITEM_ID_PGUP; - io.KeyMap[ImGuiKey_PageDown] = ITEM_ID_PGDN; - io.KeyMap[ImGuiKey_Home] = ITEM_ID_HOME; - io.KeyMap[ImGuiKey_End] = ITEM_ID_END; - io.KeyMap[ImGuiKey_Escape] = ITEM_ID_ESC; - io.KeyMap[ImGuiKey_Enter] = ITEM_ID_ENTER; - io.KeyMap[ImGuiKey_LeftArrow] = ITEM_ID_LEFT; - io.KeyMap[ImGuiKey_RightArrow] = ITEM_ID_RIGHT; - io.KeyMap[ImGuiKey_UpArrow] = ITEM_ID_UP; - io.KeyMap[ImGuiKey_DownArrow] = ITEM_ID_DOWN; + m_mapping[ITEM_ID_A] = ImGuiKey_A; + m_mapping[ITEM_ID_C] = ImGuiKey_C; + m_mapping[ITEM_ID_V] = ImGuiKey_V; + m_mapping[ITEM_ID_X] = ImGuiKey_X; + m_mapping[ITEM_ID_Y] = ImGuiKey_Y; + m_mapping[ITEM_ID_Z] = ImGuiKey_Z; + m_mapping[ITEM_ID_D] = ImGuiKey_D; + m_mapping[ITEM_ID_M] = ImGuiKey_M; + m_mapping[ITEM_ID_B] = ImGuiKey_B; + m_mapping[ITEM_ID_W] = ImGuiKey_W; + m_mapping[ITEM_ID_L] = ImGuiKey_L; + m_mapping[ITEM_ID_BACKSPACE] = ImGuiKey_Backspace; + m_mapping[ITEM_ID_DEL] = ImGuiKey_Delete; + m_mapping[ITEM_ID_TAB] = ImGuiKey_Tab; + m_mapping[ITEM_ID_PGUP] = ImGuiKey_PageUp; + m_mapping[ITEM_ID_PGDN] = ImGuiKey_PageDown; + m_mapping[ITEM_ID_HOME] = ImGuiKey_Home; + m_mapping[ITEM_ID_END] = ImGuiKey_End; + m_mapping[ITEM_ID_ESC] = ImGuiKey_Escape; + m_mapping[ITEM_ID_ENTER] = ImGuiKey_Enter; + m_mapping[ITEM_ID_LEFT] = ImGuiKey_LeftArrow; + m_mapping[ITEM_ID_RIGHT] = ImGuiKey_RightArrow; + m_mapping[ITEM_ID_UP] = ImGuiKey_UpArrow; + m_mapping[ITEM_ID_DOWN] = ImGuiKey_DownArrow; + m_mapping[ITEM_ID_F3] = ImGuiKey_F3; + m_mapping[ITEM_ID_F5] = ImGuiKey_F5; + m_mapping[ITEM_ID_F6] = ImGuiKey_F6; + m_mapping[ITEM_ID_F7] = ImGuiKey_F7; + m_mapping[ITEM_ID_F8] = ImGuiKey_F8; + m_mapping[ITEM_ID_F9] = ImGuiKey_F9; + m_mapping[ITEM_ID_F10] = ImGuiKey_F10; + m_mapping[ITEM_ID_F11] = ImGuiKey_F11; + m_mapping[ITEM_ID_F12] = ImGuiKey_F12; // set key delay and repeat rates io.KeyRepeatDelay = 0.400f; |