Previous 15994 Revisions Next

r2752 Sunday 25th May, 2008 at 19:37:28 UTC by Nathan Woods
Fixed default keyboard key names
[src/emu]inptport.c
[src/mess]inputx.c inputx.h

src/emu/inptport.c
r2751r2752
210210   UINT8                  last;            /* were we pressed last time? */
211211   UINT8                  toggle;            /* current toggle state */
212212   UINT8                  joydir;            /* digital joystick direction index */
213   char *                  name;            /* overridden name */
213214};
214215
215216
r2751r2752
738739const char *input_field_name(const input_field_config *field)
739740{
740741   /* if we have a non-default name, use that */
742   if ((field->state != NULL) && (field->state->name != NULL))
743      return field->state->name;
741744   if (field->name != NULL)
742745      return field->name;
743746
r2751r2752
15071510            *changedinfotail = init_field_callback_info(field);
15081511            changedinfotail = &(*changedinfotail)->next;
15091512         }
1513
1514#ifdef MESS
1515         /* MESS-specific code to name keyboard key names */
1516         if ((field->type == IPT_KEYBOARD) && (field->name == NULL))
1517         {
1518            astring *name = mess_get_keyboard_key_name(field);
1519            if (name != NULL)
1520            {
1521               field->state->name = auto_strdup(astring_c(name));
1522               astring_free(name);
1523            }
1524         }
1525#endif /* MESS */
15101526      }
15111527   }
15121528
src/mess/inputx.c
r2751r2752
982982
983983
984984
985void inputx_handle_mess_extensions(input_field_config *ipt)
985/*-------------------------------------------------
986    mess_get_keyboard_key_name - builds the name of
987   a key based on natural keyboard characters
988-------------------------------------------------*/
989
990astring *mess_get_keyboard_key_name(const input_field_config *field)
986991{
987   char buf[256];
988   int i, pos;
992   astring *result = astring_alloc();
993   int i;
989994   unicode_char ch;
990995
991   /* process MESS specific extensions to all ports */
992   while(ipt->type != IPT_END)
996
997   /* loop through each character on the field*/
998   for (i = 0; i < ARRAY_LENGTH(field->chars) && (field->chars[i] != '\0'); i++)
993999   {
994      /* is this a keyboard port with the default name? */
995      if (ipt->type == IPT_KEYBOARD && (ipt->name == IP_NAME_DEFAULT))
996      {
997         buf[0] = '\0';
998         pos = 0;
1000      ch = get_keyboard_code(field, i);
1001      astring_printf(result, "%s%-*s ", astring_c(result), MAX(SPACE_COUNT - 1, 0), inputx_key_name(ch));
1002   }
9991003
1000         for (i = 0; i < ARRAY_LENGTH(ipt->chars) && ipt->chars[i]; i++)
1001         {
1002            ch = get_keyboard_code(ipt, i);
1003            pos += snprintf(&buf[pos], ARRAY_LENGTH(buf) - pos, "%-*s ", MAX(SPACE_COUNT - 1, 0), inputx_key_name(ch));
1004         }
1004   /* trim extra spaces */
1005   astring_trimspace(result);
10051006
1006         /* trim extra spaces */
1007         rtrim(buf);
1007   /* special case */
1008   if (astring_len(result) == 0)
1009      astring_cpyc(result, "Unnamed Key");
10081010
1009         /* specify the key name */
1010         if (buf[0] != '\0')
1011            ipt->name = auto_strdup(buf);
1012         else
1013            ipt->name = "Unnamed Key";
1014      }
1015      ipt++;
1016   }
1011   return result;
10171012}
10181013
10191014
10201015
1016/*-------------------------------------------------
1017    inputx_key_name - returns the name of a
1018   specific key
1019-------------------------------------------------*/
1020
10211021const char *inputx_key_name(unicode_char ch)
10221022{
10231023   static char buf[UTF8_CHAR_MAX + 1];
src/mess/inputx.h
r2751r2752
5252/* these are called by the core; they should not be called from FEs */
5353void inputx_init(running_machine *machine);
5454void mess_input_port_update_hook(running_machine *machine, const input_port_config *port, input_port_value *digital);
55/*void inputx_handle_mess_extensions(input_port_entry *ipt);*/
55astring *mess_get_keyboard_key_name(const input_field_config *field);
5656
5757/* called by drivers to setup natural keyboard support */
5858void inputx_setup_natural_keyboard(

Previous 15994 Revisions Next


© 1998-2018 The MESS Team