diff options
Diffstat (limited to 'src/emu/ioport.cpp')
-rw-r--r-- | src/emu/ioport.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/src/emu/ioport.cpp b/src/emu/ioport.cpp index fbc3bfe7fbc..ede3de5bafe 100644 --- a/src/emu/ioport.cpp +++ b/src/emu/ioport.cpp @@ -1732,9 +1732,6 @@ time_t ioport_manager::initialize() break; } - // initialize natural keyboard - m_natkeyboard = std::make_unique<natural_keyboard>(machine()); - // register callbacks for when we load configurations machine().configuration().config_register("input", config_load_delegate(&ioport_manager::load_config, this), config_save_delegate(&ioport_manager::save_config, this)); @@ -2128,6 +2125,7 @@ void ioport_manager::load_config(config_type cfg_type, util::xml::data_node cons { std::vector<bool> kbd_enable_set; bool keyboard_enabled = false, missing_enabled = false; + natural_keyboard &natkbd = machine().natkeyboard(); for (util::xml::data_node const *kbdnode = parentnode->get_child("keyboard"); kbdnode; kbdnode = kbdnode->get_next_sibling("keyboard")) { char const *const tag = kbdnode->get_attribute_string("tag", nullptr); @@ -2135,48 +2133,48 @@ void ioport_manager::load_config(config_type cfg_type, util::xml::data_node cons if (tag && (0 <= enabled)) { size_t i; - for (i = 0; natkeyboard().keyboard_count() > i; ++i) + for (i = 0; natkbd.keyboard_count() > i; ++i) { - if (!strcmp(natkeyboard().keyboard_device(i).tag(), tag)) + if (!strcmp(natkbd.keyboard_device(i).tag(), tag)) { if (kbd_enable_set.empty()) - kbd_enable_set.resize(natkeyboard().keyboard_count(), false); + kbd_enable_set.resize(natkbd.keyboard_count(), false); kbd_enable_set[i] = true; if (enabled) { - if (!natkeyboard().keyboard_is_keypad(i)) + if (!natkbd.keyboard_is_keypad(i)) keyboard_enabled = true; - natkeyboard().enable_keyboard(i); + natkbd.enable_keyboard(i); } else { - natkeyboard().disable_keyboard(i); + natkbd.disable_keyboard(i); } break; } } - missing_enabled = missing_enabled || (enabled && (natkeyboard().keyboard_count() <= i)); + missing_enabled = missing_enabled || (enabled && (natkbd.keyboard_count() <= i)); } } // if keyboard enable configuration was loaded, patch it up for principle of least surprise if (!kbd_enable_set.empty()) { - for (size_t i = 0; natkeyboard().keyboard_count() > i; ++i) + for (size_t i = 0; natkbd.keyboard_count() > i; ++i) { - if (!natkeyboard().keyboard_is_keypad(i)) + if (!natkbd.keyboard_is_keypad(i)) { if (!keyboard_enabled && missing_enabled) { - natkeyboard().enable_keyboard(i); + natkbd.enable_keyboard(i); keyboard_enabled = true; } else if (!kbd_enable_set[i]) { if (keyboard_enabled) - natkeyboard().disable_keyboard(i); + natkbd.disable_keyboard(i); else - natkeyboard().enable_keyboard(i); + natkbd.enable_keyboard(i); keyboard_enabled = true; } } @@ -2422,11 +2420,12 @@ void ioport_manager::save_default_inputs(util::xml::data_node &parentnode) void ioport_manager::save_game_inputs(util::xml::data_node &parentnode) { // save keyboard enable/disable state - for (size_t i = 0; natkeyboard().keyboard_count() > i; ++i) + natural_keyboard &natkbd = machine().natkeyboard(); + for (size_t i = 0; natkbd.keyboard_count() > i; ++i) { util::xml::data_node *const kbdnode = parentnode.add_child("keyboard", nullptr); - kbdnode->set_attribute("tag", natkeyboard().keyboard_device(i).tag()); - kbdnode->set_attribute_int("enabled", natkeyboard().keyboard_enabled(i)); + kbdnode->set_attribute("tag", natkbd.keyboard_device(i).tag()); + kbdnode->set_attribute_int("enabled", natkbd.keyboard_enabled(i)); } // iterate over ports |