trunk/src/emu/ioport.c
| r20916 | r20917 | |
| 994 | 994 | m_queue_chars = ioport_queue_chars_delegate(); |
| 995 | 995 | m_accept_char = ioport_accept_char_delegate(); |
| 996 | 996 | m_charqueue_empty = ioport_charqueue_empty_delegate(); |
| 997 | | |
| 998 | | // reigster debugger commands |
| 999 | | if (machine.debug_flags & DEBUG_FLAG_ENABLED) |
| 1000 | | { |
| 1001 | | debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input); |
| 1002 | | debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd); |
| 1003 | | } |
| 1004 | 997 | } |
| 1005 | 998 | |
| 1006 | 999 | //------------------------------------------------- |
| r20916 | r20917 | |
| 1490 | 1483 | |
| 1491 | 1484 | |
| 1492 | 1485 | //------------------------------------------------- |
| 1493 | | // execute_input - debugger command to enter |
| 1494 | | // natural keyboard input |
| 1486 | // dump - dumps info to string |
| 1495 | 1487 | //------------------------------------------------- |
| 1496 | 1488 | |
| 1497 | | void natural_keyboard::execute_input(running_machine &machine, int ref, int params, const char *param[]) |
| 1489 | astring natural_keyboard::dump() |
| 1498 | 1490 | { |
| 1499 | | machine.ioport().natkeyboard().post_coded(param[0]); |
| 1500 | | } |
| 1501 | | |
| 1502 | | |
| 1503 | | //------------------------------------------------- |
| 1504 | | // execute_dumpkbd - debugger command to natural |
| 1505 | | // keyboard codes |
| 1506 | | //------------------------------------------------- |
| 1507 | | |
| 1508 | | void natural_keyboard::execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[]) |
| 1509 | | { |
| 1510 | | // was there a file specified? |
| 1511 | | const char *filename = (params > 0) ? param[0] : NULL; |
| 1512 | | FILE *file = NULL; |
| 1513 | | if (filename != NULL) |
| 1514 | | { |
| 1515 | | // if so, open it |
| 1516 | | file = fopen(filename, "w"); |
| 1517 | | if (file == NULL) |
| 1518 | | { |
| 1519 | | debug_console_printf(machine, "Cannot open \"%s\"\n", filename); |
| 1520 | | return; |
| 1521 | | } |
| 1522 | | } |
| 1523 | | |
| 1524 | | // loop through all codes |
| 1525 | | natural_keyboard &natkeyboard = machine.ioport().natkeyboard(); |
| 1526 | | dynamic_array<keycode_map_entry> &keycode_map = natkeyboard.m_keycode_map; |
| 1527 | 1491 | astring buffer, tempstr; |
| 1528 | 1492 | const size_t left_column_width = 24; |
| 1529 | | for (int index = 0; index < keycode_map.count(); index++) |
| 1493 | |
| 1494 | // loop through all codes |
| 1495 | for (int index = 0; index < m_keycode_map.count(); index++) |
| 1530 | 1496 | { |
| 1531 | 1497 | // describe the character code |
| 1532 | | const keycode_map_entry &code = keycode_map[index]; |
| 1533 | | buffer.printf("%08X (%s) ", code.ch, natkeyboard.unicode_to_string(tempstr, code.ch)); |
| 1498 | const natural_keyboard::keycode_map_entry &code = m_keycode_map[index]; |
| 1499 | buffer.catprintf("%08X (%s) ", code.ch, unicode_to_string(tempstr, code.ch)); |
| 1534 | 1500 | |
| 1535 | 1501 | // pad with spaces |
| 1536 | 1502 | while (buffer.len() < left_column_width) |
| r20916 | r20917 | |
| 1540 | 1506 | for (int field = 0; field < ARRAY_LENGTH(code.field) && code.field[field] != 0; field++) |
| 1541 | 1507 | buffer.catprintf("%s'%s'", (field > 0) ? ", " : "", code.field[field]->name()); |
| 1542 | 1508 | |
| 1543 | | // and output it as appropriate |
| 1544 | | if (file != NULL) |
| 1545 | | fprintf(file, "%s\n", buffer.cstr()); |
| 1546 | | else |
| 1547 | | debug_console_printf(machine, "%s\n", buffer.cstr()); |
| 1509 | // carriage return |
| 1510 | buffer.cat('\n'); |
| 1548 | 1511 | } |
| 1549 | 1512 | |
| 1550 | | // cleanup |
| 1551 | | if (file != NULL) |
| 1552 | | fclose(file); |
| 1513 | return buffer; |
| 1553 | 1514 | } |
| 1554 | 1515 | |
| 1555 | 1516 | |
| 1556 | | |
| 1557 | 1517 | //************************************************************************** |
| 1558 | 1518 | // I/O PORT CONDITION |
| 1559 | 1519 | //************************************************************************** |
trunk/src/emu/ioport.h
| r20916 | r20917 | |
| 853 | 853 | void frame_update(ioport_port &port, ioport_value &digital); |
| 854 | 854 | const char *key_name(astring &string, unicode_char ch); |
| 855 | 855 | |
| 856 | // debugging |
| 857 | astring dump(); |
| 858 | |
| 856 | 859 | private: |
| 857 | 860 | // internal keyboard code information |
| 858 | 861 | struct keycode_map_entry |
| r20916 | r20917 | |
| 871 | 874 | const char *unicode_to_string(astring &buffer, unicode_char ch); |
| 872 | 875 | const keycode_map_entry *find_code(unicode_char ch) const; |
| 873 | 876 | |
| 874 | | // debugger helpers |
| 875 | | static void execute_input(running_machine &machine, int ref, int params, const char *param[]); |
| 876 | | static void execute_dumpkbd(running_machine &machine, int ref, int params, const char *param[]); |
| 877 | | |
| 878 | 877 | // internal state |
| 879 | 878 | running_machine & m_machine; // reference to our machine |
| 880 | 879 | UINT32 m_bufbegin; // index of starting character |
trunk/src/emu/debug/debugcmd.c
| r20916 | r20917 | |
| 148 | 148 | static void execute_images(running_machine &machine, int ref, int params, const char **param); |
| 149 | 149 | static void execute_mount(running_machine &machine, int ref, int params, const char **param); |
| 150 | 150 | static void execute_unmount(running_machine &machine, int ref, int params, const char **param); |
| 151 | static void execute_input(running_machine &machine, int ref, int params, const char **param); |
| 152 | static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param); |
| 151 | 153 | |
| 152 | 154 | |
| 153 | 155 | /*************************************************************************** |
| r20916 | r20917 | |
| 371 | 373 | debug_console_register_command(machine, "mount", CMDFLAG_NONE, 0, 2, 2, execute_mount); |
| 372 | 374 | debug_console_register_command(machine, "unmount", CMDFLAG_NONE, 0, 1, 1, execute_unmount); |
| 373 | 375 | |
| 376 | debug_console_register_command(machine, "input", CMDFLAG_NONE, 0, 1, 1, execute_input); |
| 377 | debug_console_register_command(machine, "dumpkbd", CMDFLAG_NONE, 0, 0, 1, execute_dumpkbd); |
| 378 | |
| 374 | 379 | machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine)); |
| 375 | 380 | |
| 376 | 381 | /* set up the initial debugscript if specified */ |
| r20916 | r20917 | |
| 2749 | 2754 | if (!done) |
| 2750 | 2755 | debug_console_printf(machine, "There is no image device :%s\n",param[0]); |
| 2751 | 2756 | } |
| 2757 | |
| 2758 | |
| 2759 | /*------------------------------------------------- |
| 2760 | execute_input - debugger command to enter |
| 2761 | natural keyboard input |
| 2762 | -------------------------------------------------*/ |
| 2763 | |
| 2764 | static void execute_input(running_machine &machine, int ref, int params, const char **param) |
| 2765 | { |
| 2766 | machine.ioport().natkeyboard().post_coded(param[0]); |
| 2767 | } |
| 2768 | |
| 2769 | |
| 2770 | /*------------------------------------------------- |
| 2771 | execute_dumpkbd - debugger command to natural |
| 2772 | keyboard codes |
| 2773 | -------------------------------------------------*/ |
| 2774 | |
| 2775 | static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param) |
| 2776 | { |
| 2777 | // was there a file specified? |
| 2778 | const char *filename = (params > 0) ? param[0] : NULL; |
| 2779 | FILE *file = NULL; |
| 2780 | if (filename != NULL) |
| 2781 | { |
| 2782 | // if so, open it |
| 2783 | file = fopen(filename, "w"); |
| 2784 | if (file == NULL) |
| 2785 | { |
| 2786 | debug_console_printf(machine, "Cannot open \"%s\"\n", filename); |
| 2787 | return; |
| 2788 | } |
| 2789 | } |
| 2790 | |
| 2791 | // loop through all codes |
| 2792 | astring buffer = machine.ioport().natkeyboard().dump(); |
| 2793 | |
| 2794 | // and output it as appropriate |
| 2795 | if (file != NULL) |
| 2796 | fprintf(file, "%s\n", buffer.cstr()); |
| 2797 | else |
| 2798 | debug_console_printf(machine, "%s\n", buffer.cstr()); |
| 2799 | |
| 2800 | // cleanup |
| 2801 | if (file != NULL) |
| 2802 | fclose(file); |
| 2803 | } |