mirror of
https://github.com/holub/mame
synced 2025-04-23 00:39:36 +03:00
Fixing natural keyboard debugger commands (input, dumpkbd)
This commit is contained in:
parent
cb1234cb49
commit
eb8dbb4fe5
@ -148,6 +148,8 @@ static void execute_hardreset(running_machine &machine, int ref, int params, con
|
||||
static void execute_images(running_machine &machine, int ref, int params, const char **param);
|
||||
static void execute_mount(running_machine &machine, int ref, int params, const char **param);
|
||||
static void execute_unmount(running_machine &machine, int ref, int params, const char **param);
|
||||
static void execute_input(running_machine &machine, int ref, int params, const char **param);
|
||||
static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param);
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
@ -371,6 +373,9 @@ void debug_command_init(running_machine &machine)
|
||||
debug_console_register_command(machine, "mount", CMDFLAG_NONE, 0, 2, 2, execute_mount);
|
||||
debug_console_register_command(machine, "unmount", CMDFLAG_NONE, 0, 1, 1, execute_unmount);
|
||||
|
||||
debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input);
|
||||
debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
|
||||
|
||||
machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine));
|
||||
|
||||
/* set up the initial debugscript if specified */
|
||||
@ -2749,3 +2754,50 @@ static void execute_unmount(running_machine &machine, int ref, int params, const
|
||||
if (!done)
|
||||
debug_console_printf(machine, "There is no image device :%s\n",param[0]);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
execute_input - debugger command to enter
|
||||
natural keyboard input
|
||||
-------------------------------------------------*/
|
||||
|
||||
static void execute_input(running_machine &machine, int ref, int params, const char **param)
|
||||
{
|
||||
machine.ioport().natkeyboard().post_coded(param[0]);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------
|
||||
execute_dumpkbd - debugger command to natural
|
||||
keyboard codes
|
||||
-------------------------------------------------*/
|
||||
|
||||
static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param)
|
||||
{
|
||||
// was there a file specified?
|
||||
const char *filename = (params > 0) ? param[0] : NULL;
|
||||
FILE *file = NULL;
|
||||
if (filename != NULL)
|
||||
{
|
||||
// if so, open it
|
||||
file = fopen(filename, "w");
|
||||
if (file == NULL)
|
||||
{
|
||||
debug_console_printf(machine, "Cannot open \"%s\"\n", filename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// loop through all codes
|
||||
astring buffer = machine.ioport().natkeyboard().dump();
|
||||
|
||||
// and output it as appropriate
|
||||
if (file != NULL)
|
||||
fprintf(file, "%s\n", buffer.cstr());
|
||||
else
|
||||
debug_console_printf(machine, "%s\n", buffer.cstr());
|
||||
|
||||
// cleanup
|
||||
if (file != NULL)
|
||||
fclose(file);
|
||||
}
|
||||
|
@ -994,13 +994,6 @@ natural_keyboard::natural_keyboard(running_machine &machine)
|
||||
m_queue_chars = ioport_queue_chars_delegate();
|
||||
m_accept_char = ioport_accept_char_delegate();
|
||||
m_charqueue_empty = ioport_charqueue_empty_delegate();
|
||||
|
||||
// reigster debugger commands
|
||||
if (machine.debug_flags & DEBUG_FLAG_ENABLED)
|
||||
{
|
||||
debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input);
|
||||
debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd);
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------
|
||||
@ -1490,47 +1483,20 @@ const char *natural_keyboard::key_name(astring &string, unicode_char ch)
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// execute_input - debugger command to enter
|
||||
// natural keyboard input
|
||||
// dump - dumps info to string
|
||||
//-------------------------------------------------
|
||||
|
||||
void natural_keyboard::execute_input(running_machine &machine, int ref, int params, const char *param[])
|
||||
astring natural_keyboard::dump()
|
||||
{
|
||||
machine.ioport().natkeyboard().post_coded(param[0]);
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
// execute_dumpkbd - debugger command to natural
|
||||
// keyboard codes
|
||||
//-------------------------------------------------
|
||||
|
||||
void natural_keyboard::execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[])
|
||||
{
|
||||
// was there a file specified?
|
||||
const char *filename = (params > 0) ? param[0] : NULL;
|
||||
FILE *file = NULL;
|
||||
if (filename != NULL)
|
||||
{
|
||||
// if so, open it
|
||||
file = fopen(filename, "w");
|
||||
if (file == NULL)
|
||||
{
|
||||
debug_console_printf(machine, "Cannot open \"%s\"\n", filename);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// loop through all codes
|
||||
natural_keyboard &natkeyboard = machine.ioport().natkeyboard();
|
||||
dynamic_array<keycode_map_entry> &keycode_map = natkeyboard.m_keycode_map;
|
||||
astring buffer, tempstr;
|
||||
const size_t left_column_width = 24;
|
||||
for (int index = 0; index < keycode_map.count(); index++)
|
||||
|
||||
// loop through all codes
|
||||
for (int index = 0; index < m_keycode_map.count(); index++)
|
||||
{
|
||||
// describe the character code
|
||||
const keycode_map_entry &code = keycode_map[index];
|
||||
buffer.printf("%08X (%s) ", code.ch, natkeyboard.unicode_to_string(tempstr, code.ch));
|
||||
const natural_keyboard::keycode_map_entry &code = m_keycode_map[index];
|
||||
buffer.catprintf("%08X (%s) ", code.ch, unicode_to_string(tempstr, code.ch));
|
||||
|
||||
// pad with spaces
|
||||
while (buffer.len() < left_column_width)
|
||||
@ -1540,20 +1506,14 @@ void natural_keyboard::execute_dumpkbd(running_machine &machine, int ref, int pa
|
||||
for (int field = 0; field < ARRAY_LENGTH(code.field) && code.field[field] != 0; field++)
|
||||
buffer.catprintf("%s'%s'", (field > 0) ? ", " : "", code.field[field]->name());
|
||||
|
||||
// and output it as appropriate
|
||||
if (file != NULL)
|
||||
fprintf(file, "%s\n", buffer.cstr());
|
||||
else
|
||||
debug_console_printf(machine, "%s\n", buffer.cstr());
|
||||
// carriage return
|
||||
buffer.cat('\n');
|
||||
}
|
||||
|
||||
// cleanup
|
||||
if (file != NULL)
|
||||
fclose(file);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************************************
|
||||
// I/O PORT CONDITION
|
||||
//**************************************************************************
|
||||
|
@ -853,6 +853,9 @@ public:
|
||||
void frame_update(ioport_port &port, ioport_value &digital);
|
||||
const char *key_name(astring &string, unicode_char ch);
|
||||
|
||||
// debugging
|
||||
astring dump();
|
||||
|
||||
private:
|
||||
// internal keyboard code information
|
||||
struct keycode_map_entry
|
||||
@ -871,10 +874,6 @@ private:
|
||||
const char *unicode_to_string(astring &buffer, unicode_char ch);
|
||||
const keycode_map_entry *find_code(unicode_char ch) const;
|
||||
|
||||
// debugger helpers
|
||||
static void execute_input(running_machine &machine, int ref, int params, const char *param[]);
|
||||
static void execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[]);
|
||||
|
||||
// internal state
|
||||
running_machine & m_machine; // reference to our machine
|
||||
UINT32 m_bufbegin; // index of starting character
|
||||
|
Loading…
Reference in New Issue
Block a user