mirror of
https://github.com/holub/mame
synced 2025-04-22 08:22:15 +03:00
Fix for UI Paste with the Default Serial Terminal (#6648)
* This fixes the ability for one to use UI Paste with the Default Serial Terminal. Without this fix, 8 characters @^&()\:" cannot be pasted from the UI.
This commit is contained in:
parent
c7251935a7
commit
8ff84bc0c9
@ -661,7 +661,6 @@ INPUT_PORTS_START(matrix_dk)
|
||||
INPUT_PORTS_END
|
||||
|
||||
INPUT_PORTS_START(matrix_ch)
|
||||
// FIXME: natural keyboard doesn't play nicely with PORT_CONDITION, but it's an issue with natural keyboard itself
|
||||
PORT_INCLUDE(matrix_common)
|
||||
|
||||
PORT_START("CFG")
|
||||
|
@ -644,32 +644,33 @@ void natural_keyboard::build_codes(ioport_manager &manager)
|
||||
{
|
||||
if (((code < UCHAR_SHIFT_BEGIN) || (code > UCHAR_SHIFT_END)) && (code != 0))
|
||||
{
|
||||
// prefer lowest shift state
|
||||
keycode_map::iterator const found(m_keycode_map.find(code));
|
||||
if ((m_keycode_map.end() == found) || (found->second.shift > curshift))
|
||||
keycode_map_entry newcode;
|
||||
std::fill(std::begin(newcode.field), std::end(newcode.field), nullptr);
|
||||
newcode.shift = curshift;
|
||||
newcode.condition = field.condition();
|
||||
|
||||
unsigned fieldnum = 0;
|
||||
for (unsigned i = 0, bits = curshift; (i < SHIFT_COUNT) && bits; ++i, bits >>= 1)
|
||||
{
|
||||
keycode_map_entry newcode;
|
||||
std::fill(std::begin(newcode.field), std::end(newcode.field), nullptr);
|
||||
newcode.shift = curshift;
|
||||
if (BIT(bits, 0))
|
||||
newcode.field[fieldnum++] = shift[i];
|
||||
}
|
||||
|
||||
unsigned fieldnum = 0;
|
||||
for (unsigned i = 0, bits = curshift; (i < SHIFT_COUNT) && bits; ++i, bits >>= 1)
|
||||
{
|
||||
if (BIT(bits, 0))
|
||||
newcode.field[fieldnum++] = shift[i];
|
||||
}
|
||||
newcode.field[fieldnum] = &field;
|
||||
if (m_keycode_map.end() == found)
|
||||
{
|
||||
keycode_map_list map_list;
|
||||
map_list.emplace_back(newcode);
|
||||
m_keycode_map.emplace(code, map_list);
|
||||
}
|
||||
else
|
||||
found->second.emplace_back(newcode);
|
||||
|
||||
newcode.field[fieldnum] = &field;
|
||||
if (m_keycode_map.end() == found)
|
||||
m_keycode_map.emplace(code, newcode);
|
||||
else
|
||||
found->second = newcode;
|
||||
|
||||
if (LOG_NATURAL_KEYBOARD)
|
||||
{
|
||||
machine().logerror("natural_keyboard: code=%u (%s) port=%p field.name='%s'\n",
|
||||
code, unicode_to_string(code), (void *)&port, field.name());
|
||||
}
|
||||
if (LOG_NATURAL_KEYBOARD)
|
||||
{
|
||||
machine().logerror("natural_keyboard: code=%u (%s) port=%p field.name='%s'\n",
|
||||
code, unicode_to_string(code), (void *)&port, field.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -879,7 +880,13 @@ std::string natural_keyboard::unicode_to_string(char32_t ch) const
|
||||
const natural_keyboard::keycode_map_entry *natural_keyboard::find_code(char32_t ch) const
|
||||
{
|
||||
keycode_map::const_iterator const found(m_keycode_map.find(ch));
|
||||
return (m_keycode_map.end() != found) ? &found->second : nullptr;
|
||||
if (m_keycode_map.end() == found) return nullptr;
|
||||
for(const keycode_map_entry &entry : found->second)
|
||||
{
|
||||
if (entry.condition.eval())
|
||||
return &entry;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -901,13 +908,16 @@ void natural_keyboard::dump(std::ostream &str) const
|
||||
// pad with spaces
|
||||
util::stream_format(str, "%-*s", left_column_width, description);
|
||||
|
||||
// identify the keys used
|
||||
for (std::size_t field = 0; (code.second.field.size() > field) && code.second.field[field]; ++field)
|
||||
util::stream_format(str, "%s'%s'", first ? "" : ", ", code.second.field[field]->name());
|
||||
for (auto &entry : code.second)
|
||||
{
|
||||
// identify the keys used
|
||||
for (std::size_t field = 0; (entry.field.size() > field) && entry.field[field]; ++field)
|
||||
util::stream_format(str, "%s'%s'", first ? "" : ", ", entry.field[field]->name());
|
||||
|
||||
// carriage return
|
||||
str << '\n';
|
||||
first = false;
|
||||
// carriage return
|
||||
str << '\n';
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +74,10 @@ private:
|
||||
{
|
||||
std::array<ioport_field *, SHIFT_COUNT + 1> field;
|
||||
unsigned shift;
|
||||
ioport_condition condition;
|
||||
};
|
||||
typedef std::unordered_map<char32_t, keycode_map_entry> keycode_map;
|
||||
typedef std::list<keycode_map_entry> keycode_map_list;
|
||||
typedef std::unordered_map<char32_t, keycode_map_list> keycode_map;
|
||||
|
||||
// internal helpers
|
||||
void build_codes(ioport_manager &manager);
|
||||
|
Loading…
Reference in New Issue
Block a user