Changing some arrays to use std::array<> in natkeyboard

This commit is contained in:
npwoods 2019-09-10 06:41:15 -04:00
parent d5b3dca0ad
commit 35e5616ca8
2 changed files with 6 additions and 9 deletions

View File

@ -609,7 +609,7 @@ void natural_keyboard::build_codes(ioport_manager &manager)
{
// find all shift keys
unsigned mask = 0;
ioport_field *shift[SHIFT_COUNT];
std::array<ioport_field *, SHIFT_COUNT> shift;
std::fill(std::begin(shift), std::end(shift), nullptr);
for (auto const &port : manager.ports())
{
@ -663,7 +663,6 @@ void natural_keyboard::build_codes(ioport_manager &manager)
newcode.field[fieldnum++] = shift[i];
}
assert(fieldnum < ARRAY_LENGTH(newcode.field));
newcode.field[fieldnum] = &field;
if (m_keycode_map.end() == found)
m_keycode_map.emplace(code, newcode);
@ -802,8 +801,6 @@ void natural_keyboard::timer(void *ptr, int param)
{
do
{
assert(m_fieldnum < ARRAY_LENGTH(code->field));
ioport_field *const field = code->field[m_fieldnum];
if (field)
{
@ -814,8 +811,8 @@ void natural_keyboard::timer(void *ptr, int param)
field->set_value(!field->digital_value());
}
}
while (code->field[m_fieldnum] && (++m_fieldnum < ARRAY_LENGTH(code->field)) && m_status_keydown);
advance = (m_fieldnum >= ARRAY_LENGTH(code->field)) || !code->field[m_fieldnum];
while (code->field[m_fieldnum] && (++m_fieldnum < code->field.size()) && m_status_keydown);
advance = (m_fieldnum >= code->field.size()) || !code->field[m_fieldnum];
}
else
{
@ -909,7 +906,7 @@ void natural_keyboard::dump(std::ostream &str) const
util::stream_format(str, "%-*s", left_column_width, description);
// identify the keys used
for (std::size_t field = 0; (ARRAY_LENGTH(code.second.field) > field) && code.second.field[field]; ++field)
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());
// carriage return

View File

@ -72,8 +72,8 @@ private:
// internal keyboard code information
struct keycode_map_entry
{
ioport_field * field[SHIFT_COUNT + 1];
unsigned shift;
std::array<ioport_field *, SHIFT_COUNT + 1> field;
unsigned shift;
};
typedef std::unordered_map<char32_t, keycode_map_entry> keycode_map;