summaryrefslogtreecommitdiffstats
path: root/src/osd/modules/debugger/debugimgui.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2016-06-07 19:21:30 +0200
committer couriersud <couriersud@arcor.de>2016-06-07 19:21:30 +0200
commit62ed8d252eebe4fdad3740b5797ab2ad41829076 (patch)
tree9e84f1640b1d91f09c752662ee321575d956031d /src/osd/modules/debugger/debugimgui.cpp
parentf7ac9783d676221a9b41145924d4d9025552d602 (diff)
parent33db0678932ffb0640b05c6f5b48268d60d0f87b (diff)
Merge remote-tracking branch 'origin/master' into netlist_dev
Diffstat (limited to 'src/osd/modules/debugger/debugimgui.cpp')
-rw-r--r--src/osd/modules/debugger/debugimgui.cpp156
1 files changed, 89 insertions, 67 deletions
diff --git a/src/osd/modules/debugger/debugimgui.cpp b/src/osd/modules/debugger/debugimgui.cpp
index dbd64b939ec..25f6938f4fa 100644
--- a/src/osd/modules/debugger/debugimgui.cpp
+++ b/src/osd/modules/debugger/debugimgui.cpp
@@ -31,6 +31,7 @@ public:
type(0),
ofs_x(0),
ofs_y(0),
+ is_collapsed(false),
exec_cmd(false)
{
this->view = machine.debug_view().alloc_view(type, nullptr, this);
@@ -72,6 +73,7 @@ public:
float view_width;
float view_height;
bool has_focus;
+ bool is_collapsed;
bool exec_cmd; // console only
int src_sel;
char console_input[512];
@@ -259,47 +261,16 @@ void debug_imgui::handle_keys()
{
ImGuiIO& io = ImGui::GetIO();
ui_event event;
+ debug_area* focus_view = nullptr;
- // global keys
- if(m_machine->input().code_pressed_once(KEYCODE_F3))
- {
- if(m_machine->input().code_pressed(KEYCODE_LSHIFT))
- m_machine->schedule_hard_reset();
- else
- {
- m_machine->schedule_soft_reset();
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
- }
- }
+ // find view that has focus (should only be one at a time)
+ for(std::vector<debug_area*>::iterator view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
+ if((*view_ptr)->has_focus)
+ focus_view = *view_ptr;
- if(m_machine->input().code_pressed_once(KEYCODE_F5))
- {
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
- m_running = true;
- }
- if(m_machine->input().code_pressed_once(KEYCODE_F6))
- {
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device();
- m_running = true;
- }
- if(m_machine->input().code_pressed_once(KEYCODE_F7))
- {
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt();
- m_running = true;
- }
- if(m_machine->input().code_pressed_once(KEYCODE_F8))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank();
- if(m_machine->input().code_pressed_once(KEYCODE_F9))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out();
- if(m_machine->input().code_pressed_once(KEYCODE_F10))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over();
- if(m_machine->input().code_pressed_once(KEYCODE_F11))
- debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
- if(m_machine->input().code_pressed_once(KEYCODE_F12))
- {
- debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
- m_hide = true;
- }
+ // check views in main views also (only the disassembler view accepts inputs)
+ if(view_main_disasm->has_focus)
+ focus_view = view_main_disasm;
if(m_machine->input().code_pressed(KEYCODE_LCONTROL))
io.KeyCtrl = true;
@@ -329,21 +300,64 @@ void debug_imgui::handle_keys()
{
case UI_EVENT_CHAR:
m_key_char = event.ch;
+ if(focus_view != nullptr)
+ focus_view->view->process_char(m_key_char);
return;
default:
break;
}
}
- if(ImGui::IsKeyPressed(ITEM_ID_D) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ // global keys
+ if(ImGui::IsKeyPressed(ITEM_ID_F3,false))
+ {
+ if(ImGui::IsKeyDown(ITEM_ID_LSHIFT))
+ m_machine->schedule_hard_reset();
+ else
+ {
+ m_machine->schedule_soft_reset();
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ }
+ }
+
+ if(ImGui::IsKeyPressed(ITEM_ID_F5,false))
+ {
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_running = true;
+ }
+ if(ImGui::IsKeyPressed(ITEM_ID_F6,false))
+ {
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->go_next_device();
+ m_running = true;
+ }
+ if(ImGui::IsKeyPressed(ITEM_ID_F7,false))
+ {
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->go_interrupt();
+ m_running = true;
+ }
+ if(ImGui::IsKeyPressed(ITEM_ID_F8,false))
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->go_vblank();
+ if(ImGui::IsKeyPressed(ITEM_ID_F9,false))
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_out();
+ if(ImGui::IsKeyPressed(ITEM_ID_F10,false))
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step_over();
+ if(ImGui::IsKeyPressed(ITEM_ID_F11,false))
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->single_step();
+ if(ImGui::IsKeyPressed(ITEM_ID_F12,false))
+ {
+ debug_cpu_get_visible_cpu(*m_machine)->debug()->go();
+ m_hide = true;
+ }
+
+ if(ImGui::IsKeyPressed(ITEM_ID_D,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
add_disasm(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_M) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ITEM_ID_M,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
add_memory(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_B) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ITEM_ID_B,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
add_bpoints(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_W) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ITEM_ID_W,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
add_wpoints(++m_win_count);
- if(ImGui::IsKeyPressed(ITEM_ID_L) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
+ if(ImGui::IsKeyPressed(ITEM_ID_L,false) && ImGui::IsKeyDown(ITEM_ID_LCONTROL))
add_log(++m_win_count);
}
@@ -365,38 +379,38 @@ void debug_imgui::handle_keys_views()
return;
// pass keypresses to debug view with focus
- if(m_machine->input().code_pressed_once(KEYCODE_UP))
+ if(ImGui::IsKeyPressed(ITEM_ID_UP))
focus_view->view->process_char(DCH_UP);
- if(m_machine->input().code_pressed_once(KEYCODE_DOWN))
+ if(ImGui::IsKeyPressed(ITEM_ID_DOWN))
focus_view->view->process_char(DCH_DOWN);
- if(m_machine->input().code_pressed_once(KEYCODE_LEFT))
+ if(ImGui::IsKeyPressed(ITEM_ID_LEFT))
{
- if(m_machine->input().code_pressed(KEYCODE_LCONTROL))
+ if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
focus_view->view->process_char(DCH_CTRLLEFT);
else
focus_view->view->process_char(DCH_LEFT);
}
- if(m_machine->input().code_pressed_once(KEYCODE_RIGHT))
+ if(ImGui::IsKeyPressed(ITEM_ID_RIGHT))
{
- if(m_machine->input().code_pressed(KEYCODE_LCONTROL))
+ if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
focus_view->view->process_char(DCH_CTRLRIGHT);
else
focus_view->view->process_char(DCH_RIGHT);
}
- if(m_machine->input().code_pressed_once(KEYCODE_PGUP))
+ if(ImGui::IsKeyPressed(ITEM_ID_PGUP))
focus_view->view->process_char(DCH_PUP);
- if(m_machine->input().code_pressed_once(KEYCODE_PGDN))
+ if(ImGui::IsKeyPressed(ITEM_ID_PGDN))
focus_view->view->process_char(DCH_PDOWN);
- if(m_machine->input().code_pressed_once(KEYCODE_HOME))
+ if(ImGui::IsKeyPressed(ITEM_ID_HOME))
{
- if(m_machine->input().code_pressed(KEYCODE_LCONTROL))
+ if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
focus_view->view->process_char(DCH_CTRLHOME);
else
focus_view->view->process_char(DCH_HOME);
}
- if(m_machine->input().code_pressed_once(KEYCODE_END))
+ if(ImGui::IsKeyPressed(ITEM_ID_END))
{
- if(m_machine->input().code_pressed(KEYCODE_LCONTROL))
+ if(ImGui::IsKeyDown(ITEM_ID_LCONTROL))
focus_view->view->process_char(DCH_CTRLEND);
else
focus_view->view->process_char(DCH_END);
@@ -554,12 +568,15 @@ void debug_imgui::draw_bpoints(debug_area* view_ptr, bool* opened)
ImGui::SetNextWindowSize(ImVec2(view_ptr->width,view_ptr->height + ImGui::GetTextLineHeight()),ImGuiSetCond_Once);
if(ImGui::Begin(view_ptr->title.c_str(),opened))
{
+ view_ptr->is_collapsed = false;
ImGui::BeginChild("##break_output", ImVec2(ImGui::GetWindowWidth() - 16,ImGui::GetWindowHeight() - ImGui::GetTextLineHeight() - ImGui::GetCursorPosY())); // account for title bar and widgets already drawn
draw_view(view_ptr,false);
ImGui::EndChild();
ImGui::End();
}
+ else
+ view_ptr->is_collapsed = true;
}
void debug_imgui::add_bpoints(int id)
@@ -597,12 +614,15 @@ void debug_imgui::draw_log(debug_area* view_ptr, bool* opened)
ImGui::SetNextWindowSize(ImVec2(view_ptr->width,view_ptr->height + ImGui::GetTextLineHeight()),ImGuiSetCond_Once);
if(ImGui::Begin(view_ptr->title.c_str(),opened))
{
+ view_ptr->is_collapsed = false;
ImGui::BeginChild("##log_output", ImVec2(ImGui::GetWindowWidth() - 16,ImGui::GetWindowHeight() - ImGui::GetTextLineHeight() - ImGui::GetCursorPosY())); // account for title bar and widgets already drawn
draw_view(view_ptr,false);
ImGui::EndChild();
ImGui::End();
}
+ else
+ view_ptr->is_collapsed = true;
}
void debug_imgui::add_log(int id)
@@ -631,6 +651,7 @@ void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened)
bool done = false;
bool exp_change = false;
+ view_ptr->is_collapsed = false;
if(ImGui::BeginMenuBar())
{
if(ImGui::BeginMenu("Options"))
@@ -685,6 +706,8 @@ void debug_imgui::draw_disasm(debug_area* view_ptr, bool* opened)
ImGui::End();
}
+ else
+ view_ptr->is_collapsed = true;
}
void debug_imgui::add_disasm(int id)
@@ -715,6 +738,7 @@ void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened)
bool done = false;
bool exp_change = false;
+ view_ptr->is_collapsed = false;
if(ImGui::BeginMenuBar())
{
if(ImGui::BeginMenu("Options"))
@@ -793,6 +817,8 @@ void debug_imgui::draw_memory(debug_area* view_ptr, bool* opened)
ImGui::End();
}
+ else
+ view_ptr->is_collapsed = true;
}
void debug_imgui::add_memory(int id)
@@ -879,20 +905,11 @@ void debug_imgui::draw_console()
}
ImGui::Separator();
// list all extra windows, so we can un-collapse the windows if necessary
- //debug_area* view_ptr;
for(std::vector<debug_area*>::iterator view_ptr = view_list.begin();view_ptr != view_list.end();++view_ptr)
{
- bool collapsed;
- if(ImGui::Begin((*view_ptr)->title.c_str()))
- {
- collapsed = false;
- ImGui::End();
- }
- else
- {
+ bool collapsed = false;
+ if((*view_ptr)->is_collapsed)
collapsed = true;
- ImGui::End();
- }
if(ImGui::MenuItem((*view_ptr)->title.c_str(), nullptr,!collapsed))
ImGui::SetWindowCollapsed((*view_ptr)->title.c_str(),false);
}
@@ -1004,6 +1021,7 @@ void debug_imgui::init_debugger(running_machine &machine)
if(strcmp(downcast<osd_options &>(m_machine->options()).video(),"bgfx") != 0)
fatalerror("Error: ImGui debugger requires the BGFX renderer.\n");
+ // 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;
@@ -1025,6 +1043,10 @@ void debug_imgui::init_debugger(running_machine &machine)
io.KeyMap[ImGuiKey_UpArrow] = ITEM_ID_UP;
io.KeyMap[ImGuiKey_DownArrow] = ITEM_ID_DOWN;
+ // set key delay and repeat rates
+ io.KeyRepeatDelay = 0.400f;
+ io.KeyRepeatRate = 0.050f;
+
font_name = (downcast<osd_options &>(m_machine->options()).debugger_font());
font_size = (downcast<osd_options &>(m_machine->options()).debugger_font_size());