src/emu/inptport.c
| r2751 | r2752 | |
| 210 | 210 | UINT8 last; /* were we pressed last time? */ |
| 211 | 211 | UINT8 toggle; /* current toggle state */ |
| 212 | 212 | UINT8 joydir; /* digital joystick direction index */ |
| 213 | char * name; /* overridden name */ |
| 213 | 214 | }; |
| 214 | 215 | |
| 215 | 216 | |
| r2751 | r2752 | |
| 738 | 739 | const char *input_field_name(const input_field_config *field) |
| 739 | 740 | { |
| 740 | 741 | /* if we have a non-default name, use that */ |
| 742 | if ((field->state != NULL) && (field->state->name != NULL)) |
| 743 | return field->state->name; |
| 741 | 744 | if (field->name != NULL) |
| 742 | 745 | return field->name; |
| 743 | 746 | |
| r2751 | r2752 | |
| 1507 | 1510 | *changedinfotail = init_field_callback_info(field); |
| 1508 | 1511 | changedinfotail = &(*changedinfotail)->next; |
| 1509 | 1512 | } |
| 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 */ |
| 1510 | 1526 | } |
| 1511 | 1527 | } |
| 1512 | 1528 | |
src/mess/inputx.c
| r2751 | r2752 | |
| 982 | 982 | |
| 983 | 983 | |
| 984 | 984 | |
| 985 | | void 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 | |
| 990 | astring *mess_get_keyboard_key_name(const input_field_config *field) |
| 986 | 991 | { |
| 987 | | char buf[256]; |
| 988 | | int i, pos; |
| 992 | astring *result = astring_alloc(); |
| 993 | int i; |
| 989 | 994 | unicode_char ch; |
| 990 | 995 | |
| 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++) |
| 993 | 999 | { |
| 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 | } |
| 999 | 1003 | |
| 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); |
| 1005 | 1006 | |
| 1006 | | /* trim extra spaces */ |
| 1007 | | rtrim(buf); |
| 1007 | /* special case */ |
| 1008 | if (astring_len(result) == 0) |
| 1009 | astring_cpyc(result, "Unnamed Key"); |
| 1008 | 1010 | |
| 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; |
| 1017 | 1012 | } |
| 1018 | 1013 | |
| 1019 | 1014 | |
| 1020 | 1015 | |
| 1016 | /*------------------------------------------------- |
| 1017 | inputx_key_name - returns the name of a |
| 1018 | specific key |
| 1019 | -------------------------------------------------*/ |
| 1020 | |
| 1021 | 1021 | const char *inputx_key_name(unicode_char ch) |
| 1022 | 1022 | { |
| 1023 | 1023 | static char buf[UTF8_CHAR_MAX + 1]; |
src/mess/inputx.h
| r2751 | r2752 | |
| 52 | 52 | /* these are called by the core; they should not be called from FEs */ |
| 53 | 53 | void inputx_init(running_machine *machine); |
| 54 | 54 | void 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);*/ |
| 55 | astring *mess_get_keyboard_key_name(const input_field_config *field); |
| 56 | 56 | |
| 57 | 57 | /* called by drivers to setup natural keyboard support */ |
| 58 | 58 | void inputx_setup_natural_keyboard( |