UWP: Better keyboard key names (nw)

This commit is contained in:
Brad Hughes 2016-11-15 14:04:28 -05:00
parent c2cc79d2ea
commit 13a496efd7
3 changed files with 15 additions and 14 deletions

View File

@ -270,17 +270,15 @@ int keyboard_trans_table::vkey_for_mame_code(input_code code) const
#if defined(OSD_UWP)
input_item_id keyboard_trans_table::map_vkey_to_itemid(Windows::System::VirtualKey vkey) const
const char* keyboard_trans_table::ui_label_for_mame_key(input_item_id itemid) const
{
int tablenum;
// scan the table for a match
for (tablenum = 0; tablenum < m_table_size; tablenum++)
if (m_table[tablenum].virtual_key == vkey)
return m_table[tablenum].mame_key;
for (int tablenum = 0; tablenum < m_table_size; tablenum++)
if (m_table[tablenum].mame_key == itemid)
return m_table[tablenum].ui_name;
// default to an "other" switch
return ITEM_ID_OTHER_SWITCH;
// We didn't find one
return nullptr;
}
#endif

View File

@ -402,7 +402,7 @@ public:
int vkey_for_mame_code(input_code code) const;
#elif defined(OSD_UWP)
input_item_id map_di_scancode_to_itemid(int di_scancode) const;
input_item_id map_vkey_to_itemid(Windows::System::VirtualKey vkey) const;
const char* ui_label_for_mame_key(input_item_id code) const;
#endif
static keyboard_trans_table& instance()

View File

@ -235,16 +235,19 @@ internal:
void Configure()
{
keyboard_trans_table &table = keyboard_trans_table::instance();
char keyname[256];
// populate it
for (int keynum = 0; keynum < MAX_KEYS; keynum++)
{
input_item_id itemid = table.map_di_scancode_to_itemid(keynum);
//if (GetKeyNameTextA(((keynum & 0x7f) << 16) | ((keynum & 0x80) << 17), keyname, ARRAY_LENGTH(keyname)) == 0)
snprintf(keyname, ARRAY_LENGTH(keyname), "Scan%03d", keynum);
const char *keyname = table.ui_label_for_mame_key(itemid);
char temp[256];
if (keyname == nullptr)
{
snprintf(temp, ARRAY_LENGTH(temp), "Scan%03d", keynum);
keyname = temp;
}
// add the item to the device
this->InputDevice->add_item(keyname, itemid, generic_button_get_state<std::uint8_t>, &keyboard.state[keynum]);