summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatarGravatar Nathan Woods <npwoods@mess.org>2013-02-10 21:56:42 +0000
committerGravatarGravatar Nathan Woods <npwoods@mess.org>2013-02-10 21:56:42 +0000
commiteb8dbb4fe5d63d37ac6598a569775278307dea5e (patch) (github)
tree88a7161354834f823aca33791e7b0e98a147cf95
parentcb1234cb4984083191071dcc4032ea8eb9df52a5 (diff)
downloadmame-eb8dbb4fe5d63d37ac6598a569775278307dea5e.tar.bz2
mame-eb8dbb4fe5d63d37ac6598a569775278307dea5e.zip
Fixing natural keyboard debugger commands (input, dumpkbd)
-rw-r--r--src/emu/debug/debugcmd.c52
-rw-r--r--src/emu/ioport.c60
-rw-r--r--src/emu/ioport.h7
3 files changed, 65 insertions, 54 deletions
diff --git a/src/emu/debug/debugcmd.c b/src/emu/debug/debugcmd.c
index e864126a34f..335fd819025 100644
--- a/src/emu/debug/debugcmd.c
+++ b/src/emu/debug/debugcmd.c
@@ -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);
+}
diff --git a/src/emu/ioport.c b/src/emu/ioport.c
index 5466136ac3f..5a2b487f9a9 100644
--- a/src/emu/ioport.c
+++ b/src/emu/ioport.c
@@ -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
-//-------------------------------------------------
-
-void natural_keyboard::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
+// dump - dumps info to string
//-------------------------------------------------
-void natural_keyboard::execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[])
+astring natural_keyboard::dump()
{
- // 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
//**************************************************************************
diff --git a/src/emu/ioport.h b/src/emu/ioport.h
index 436ecacc989..c9af4c6b0ea 100644
--- a/src/emu/ioport.h
+++ b/src/emu/ioport.h
@@ -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