Previous 199869 Revisions Next

r20917 Sunday 10th February, 2013 at 21:56:42 UTC by Nathan Woods
Fixing natural keyboard debugger commands (input, dumpkbd)
[src/emu]ioport.c ioport.h
[src/emu/debug]debugcmd.c

trunk/src/emu/ioport.c
r20916r20917
994994   m_queue_chars = ioport_queue_chars_delegate();
995995   m_accept_char = ioport_accept_char_delegate();
996996   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   }
1004997}
1005998
1006999//-------------------------------------------------
r20916r20917
14901483
14911484
14921485//-------------------------------------------------
1493//  execute_input - debugger command to enter
1494//  natural keyboard input
1486//  dump - dumps info to string
14951487//-------------------------------------------------
14961488
1497void natural_keyboard::execute_input(running_machine &machine, int ref, int params, const char *param[])
1489astring natural_keyboard::dump()
14981490{
1499   machine.ioport().natkeyboard().post_coded(param[0]);
1500}
1501
1502
1503//-------------------------------------------------
1504//  execute_dumpkbd - debugger command to natural
1505//  keyboard codes
1506//-------------------------------------------------
1507
1508void 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;
15271491   astring buffer, tempstr;
15281492   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++)
15301496   {
15311497      // 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));
15341500
15351501      // pad with spaces
15361502      while (buffer.len() < left_column_width)
r20916r20917
15401506      for (int field = 0; field < ARRAY_LENGTH(code.field) && code.field[field] != 0; field++)
15411507         buffer.catprintf("%s'%s'", (field > 0) ? ", " : "", code.field[field]->name());
15421508
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');
15481511   }
15491512
1550   // cleanup
1551   if (file != NULL)
1552      fclose(file);
1513   return buffer;
15531514}
15541515
15551516
1556
15571517//**************************************************************************
15581518//  I/O PORT CONDITION
15591519//**************************************************************************
trunk/src/emu/ioport.h
r20916r20917
853853   void frame_update(ioport_port &port, ioport_value &digital);
854854   const char *key_name(astring &string, unicode_char ch);
855855
856   // debugging
857   astring dump();
858
856859private:
857860   // internal keyboard code information
858861   struct keycode_map_entry
r20916r20917
871874   const char *unicode_to_string(astring &buffer, unicode_char ch);
872875   const keycode_map_entry *find_code(unicode_char ch) const;
873876
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
878877   // internal state
879878   running_machine &       m_machine;              // reference to our machine
880879   UINT32                  m_bufbegin;             // index of starting character
trunk/src/emu/debug/debugcmd.c
r20916r20917
148148static void execute_images(running_machine &machine, int ref, int params, const char **param);
149149static void execute_mount(running_machine &machine, int ref, int params, const char **param);
150150static void execute_unmount(running_machine &machine, int ref, int params, const char **param);
151static void execute_input(running_machine &machine, int ref, int params, const char **param);
152static void execute_dumpkbd(running_machine &machine, int ref, int params, const char **param);
151153
152154
153155/***************************************************************************
r20916r20917
371373   debug_console_register_command(machine, "mount",    CMDFLAG_NONE, 0, 2, 2, execute_mount);
372374   debug_console_register_command(machine, "unmount",  CMDFLAG_NONE, 0, 1, 1, execute_unmount);
373375
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
374379   machine.add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(debug_command_exit), &machine));
375380
376381   /* set up the initial debugscript if specified */
r20916r20917
27492754   if (!done)
27502755      debug_console_printf(machine, "There is no image device :%s\n",param[0]);
27512756}
2757
2758
2759/*-------------------------------------------------
2760    execute_input - debugger command to enter
2761    natural keyboard input
2762-------------------------------------------------*/
2763
2764static 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
2775static 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}

Previous 199869 Revisions Next


© 1997-2024 The MAME Team