Add various keyboard shortcuts and pass keypresses to the debug view with input focus.

This commit is contained in:
mahlemiut 2016-01-04 00:06:44 +13:00
parent 11bfbc1736
commit 521fc5c927

View File

@ -1398,26 +1398,26 @@ static void CreateMainMenu(running_machine &machine)
/* add input menu items */
menu->item_append("New Memory Window", nullptr, 0, (void *)on_memory_window_activate);
menu->item_append("New Disassembly Window", nullptr, 0, (void *)on_disassembly_window_activate);
menu->item_append("New Error Log Window", nullptr, 0, (void *)on_log_window_activate);
menu->item_append("New Breakpoints Window", nullptr, 0, (void *)on_bp_window_activate);
menu->item_append("New Watchpoints Window", nullptr, 0, (void *)on_wp_window_activate);
menu->item_append("New Memory Window", "[Ctrl+M]", 0, (void *)on_memory_window_activate);
menu->item_append("New Disassembly Window", "[Ctrl+D]", 0, (void *)on_disassembly_window_activate);
menu->item_append("New Error Log Window", "[Ctrl+L]", 0, (void *)on_log_window_activate);
menu->item_append("New Breakpoints Window", "[Ctrl+B]", 0, (void *)on_bp_window_activate);
menu->item_append("New Watchpoints Window", "[Ctrl+W]", 0, (void *)on_wp_window_activate);
menu->item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
menu->item_append("Run", nullptr, 0, (void *)on_run_activate);
menu->item_append("Run and Hide Debugger", nullptr, 0, (void *)on_run_h_activate);
menu->item_append("Run to Next CPU", nullptr, 0, (void *)on_run_cpu_activate);
menu->item_append("Run until Next Interrupt on This CPU", nullptr, 0, (void *)on_run_irq_activate);
menu->item_append("Run until Next VBLANK", nullptr, 0, (void *)on_run_vbl_activate);
menu->item_append("Run", "[F5]", 0, (void *)on_run_activate);
menu->item_append("Run and Hide Debugger", "[F12]", 0, (void *)on_run_h_activate);
menu->item_append("Run to Next CPU", "[F6]", 0, (void *)on_run_cpu_activate);
menu->item_append("Run until Next Interrupt on This CPU", "[F7]", 0, (void *)on_run_irq_activate);
menu->item_append("Run until Next VBLANK", "[F8]", 0, (void *)on_run_vbl_activate);
menu->item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
menu->item_append("Step Into", nullptr, 0, (void *)on_step_into_activate);
menu->item_append("Step Over", nullptr, 0, (void *)on_step_over_activate);
menu->item_append("Step Into", "[F11]", 0, (void *)on_step_into_activate);
menu->item_append("Step Over", "[F10]", 0, (void *)on_step_over_activate);
menu->item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
menu->item_append("Soft Reset", nullptr, 0, (void *)on_soft_reset_activate);
menu->item_append("Hard Reset", nullptr, 0, (void *)on_hard_reset_activate);
menu->item_append("Soft Reset", "[F3]", 0, (void *)on_soft_reset_activate);
menu->item_append("Hard Reset", "[Shift+F3]", 0, (void *)on_hard_reset_activate);
menu->item_append(MENU_SEPARATOR_ITEM, nullptr, 0, nullptr);
if (!dview_is_state(focus_view, VIEW_STATE_FOLLOW_CPU))
menu->item_append("Close Window", nullptr, 0, (void *)on_close_activate);
menu->item_append("Close Window", "[Shift+F4]", 0, (void *)on_close_activate);
menu->item_append("Exit", nullptr, 0, (void *)on_exit_activate);
}
@ -1470,6 +1470,186 @@ static void handle_mouse(running_machine &machine)
}
}
static void handle_keys(running_machine &machine)
{
if (menu != nullptr)
return;
// global keys
if(machine.input().code_pressed_once(KEYCODE_F3))
{
if(machine.input().code_pressed(KEYCODE_LSHIFT))
machine.schedule_hard_reset();
else
{
machine.schedule_soft_reset();
debug_cpu_get_visible_cpu(machine)->debug()->go();
}
}
if(machine.input().code_pressed_once(KEYCODE_F5))
debug_cpu_get_visible_cpu(machine)->debug()->go();
if(machine.input().code_pressed_once(KEYCODE_F6))
debug_cpu_get_visible_cpu(machine)->debug()->go_next_device();
if(machine.input().code_pressed_once(KEYCODE_F7))
debug_cpu_get_visible_cpu(machine)->debug()->go_interrupt();
if(machine.input().code_pressed_once(KEYCODE_F8))
debug_cpu_get_visible_cpu(machine)->debug()->go_vblank();
if(machine.input().code_pressed_once(KEYCODE_F10))
debug_cpu_get_visible_cpu(machine)->debug()->single_step_over();
if(machine.input().code_pressed_once(KEYCODE_F11))
debug_cpu_get_visible_cpu(machine)->debug()->single_step();
if(machine.input().code_pressed_once(KEYCODE_F12))
{
debug_hide_all();
debug_cpu_get_visible_cpu(machine)->debug()->go();
}
// TODO: make common functions to be shared here and with the menu callbacks
if(machine.input().code_pressed_once(KEYCODE_D))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
{
DView *ndv;
render_target *target;
const debug_view_source *source;
target = &machine.render().ui_target();
ndv = dview_alloc(target, machine, DVT_DISASSEMBLY, 0);
ndv->editor.active = TRUE;
ndv->editor.container = &machine.render().ui_container();
source = ndv->view->source();
dview_set_title(ndv, source->name());
ndv->ofs_x = ndv->ofs_y = win_count * TITLE_HEIGHT;
win_count++;
set_focus_view(ndv);
}
}
if(machine.input().code_pressed_once(KEYCODE_M))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
{
DView *ndv;
render_target *target;
const debug_view_source *source;
target = &machine.render().ui_target();
ndv = dview_alloc(target, machine, DVT_MEMORY, 0);
ndv->editor.active = TRUE;
ndv->editor.container = &machine.render().ui_container();
source = ndv->view->source();
dview_set_title(ndv, source->name());
ndv->ofs_x = ndv->ofs_y = win_count * TITLE_HEIGHT;
ndv->bounds.setx(0,500);
win_count++;
set_focus_view(ndv);
}
}
if(machine.input().code_pressed_once(KEYCODE_L))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
{
DView *ndv;
render_target *target;
target = &machine.render().ui_target();
ndv = dview_alloc(target, machine, DVT_LOG, 0);
dview_set_title(ndv, "Log");
ndv->ofs_x = ndv->ofs_y = win_count * TITLE_HEIGHT;
ndv->bounds.setx(0,600);
win_count++;
set_focus_view(ndv);
}
}
if(machine.input().code_pressed_once(KEYCODE_B))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
{
DView *ndv;
render_target *target;
target = &machine.render().ui_target();
ndv = dview_alloc(target, machine, DVT_BREAK_POINTS, 0);
dview_set_title(ndv, "Breakpoints");
ndv->ofs_x = ndv->ofs_y = win_count * TITLE_HEIGHT;
ndv->bounds.setx(0,600);
win_count++;
set_focus_view(ndv);
}
}
if(machine.input().code_pressed_once(KEYCODE_W))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
{
DView *ndv;
render_target *target;
target = &machine.render().ui_target();
ndv = dview_alloc(target, machine, DVT_WATCH_POINTS, 0);
dview_set_title(ndv, "Watchpoints");
ndv->ofs_x = ndv->ofs_y = win_count * TITLE_HEIGHT;
ndv->bounds.setx(0,600);
win_count++;
set_focus_view(ndv);
}
}
if (!dview_is_state(focus_view, VIEW_STATE_FOLLOW_CPU))
{
if(machine.input().code_pressed_once(KEYCODE_F4))
{
if(machine.input().code_pressed(KEYCODE_LSHIFT)) // use shift+F4, as ctrl+F4 is used to toggle keepaspect.
{
DView* dv = focus_view;
set_focus_view(focus_view->next);
win_count--;
dview_free(dv);
}
}
}
// pass keypresses to debug view with focus
if(machine.input().code_pressed_once(KEYCODE_UP))
focus_view->view->process_char(DCH_UP);
if(machine.input().code_pressed_once(KEYCODE_DOWN))
focus_view->view->process_char(DCH_DOWN);
if(machine.input().code_pressed_once(KEYCODE_LEFT))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
focus_view->view->process_char(DCH_CTRLLEFT);
else
focus_view->view->process_char(DCH_LEFT);
}
if(machine.input().code_pressed_once(KEYCODE_RIGHT))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
focus_view->view->process_char(DCH_CTRLRIGHT);
else
focus_view->view->process_char(DCH_RIGHT);
}
if(machine.input().code_pressed_once(KEYCODE_PGUP))
focus_view->view->process_char(DCH_PUP);
if(machine.input().code_pressed_once(KEYCODE_PGDN))
focus_view->view->process_char(DCH_PDOWN);
if(machine.input().code_pressed_once(KEYCODE_HOME))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
focus_view->view->process_char(DCH_CTRLHOME);
else
focus_view->view->process_char(DCH_HOME);
}
if(machine.input().code_pressed_once(KEYCODE_END))
{
if(machine.input().code_pressed(KEYCODE_LCONTROL))
focus_view->view->process_char(DCH_CTRLEND);
else
focus_view->view->process_char(DCH_END);
}
}
/*-------------------------------------------------
handle_editor - handle the editor
@ -1661,6 +1841,7 @@ void debug_internal::wait_for_debugger(device_t &device, bool firststop)
device.machine().osd().update(false);
handle_menus(device.machine());
handle_mouse(device.machine());
handle_keys(device.machine());
//osd_sleep(osd_ticks_per_second()/60);
}