summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu
diff options
context:
space:
mode:
author AJR <ajrhacker@users.noreply.github.com>2020-12-26 13:38:14 -0500
committer AJR <ajrhacker@users.noreply.github.com>2020-12-26 13:39:34 -0500
commitc04e2cbe0b88d67fed6b0316633cb9cbed4c76aa (patch)
tree2d845a3297d90e110ee4364510ae982b1b0a098f /src/emu
parent43f569e58f26d23032b950ebcbd02f352532ba95 (diff)
natkeyboard: Remove from ioport_manager
Diffstat (limited to 'src/emu')
-rw-r--r--src/emu/debug/debugcmd.cpp4
-rw-r--r--src/emu/emufwd.h2
-rw-r--r--src/emu/ioport.cpp35
-rw-r--r--src/emu/ioport.h2
-rw-r--r--src/emu/machine.cpp4
-rw-r--r--src/emu/machine.h2
6 files changed, 26 insertions, 23 deletions
diff --git a/src/emu/debug/debugcmd.cpp b/src/emu/debug/debugcmd.cpp
index 3aa7544f3ff..7e820bafa84 100644
--- a/src/emu/debug/debugcmd.cpp
+++ b/src/emu/debug/debugcmd.cpp
@@ -3930,7 +3930,7 @@ void debugger_commands::execute_unmount(int ref, const std::vector<std::string>
void debugger_commands::execute_input(int ref, const std::vector<std::string> &params)
{
- m_machine.ioport().natkeyboard().post_coded(params[0].c_str());
+ m_machine.natkeyboard().post_coded(params[0].c_str());
}
@@ -3956,7 +3956,7 @@ void debugger_commands::execute_dumpkbd(int ref, const std::vector<std::string>
}
// loop through all codes
- std::string buffer = m_machine.ioport().natkeyboard().dump();
+ std::string buffer = m_machine.natkeyboard().dump();
// and output it as appropriate
if (file != nullptr)
diff --git a/src/emu/emufwd.h b/src/emu/emufwd.h
index 8d47e42829a..a487af49b21 100644
--- a/src/emu/emufwd.h
+++ b/src/emu/emufwd.h
@@ -78,7 +78,7 @@ class crosshair_manager;
// declared in debug/debugcmd.h
class debugger_commands;
-// declared in debug/debugcmd.h
+// declared in debug/debugcon.h
class debugger_console;
// declared in debug/debugcpu.h
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
diff --git a/src/emu/ioport.h b/src/emu/ioport.h
index 376df1347be..8554455b114 100644
--- a/src/emu/ioport.h
+++ b/src/emu/ioport.h
@@ -1389,7 +1389,6 @@ public:
running_machine &machine() const noexcept { return m_machine; }
const ioport_list &ports() const noexcept { return m_portlist; }
bool safe_to_read() const noexcept { return m_safe_to_read; }
- natural_keyboard &natkeyboard() noexcept { assert(m_natkeyboard != nullptr); return *m_natkeyboard; }
// type helpers
const std::vector<input_type_entry> &types() const noexcept { return m_typelist; }
@@ -1459,7 +1458,6 @@ private:
// specific special global input states
simple_list<digital_joystick> m_joystick_list; // list of digital joysticks
- std::unique_ptr<natural_keyboard> m_natkeyboard; // natural keyboard support
// frame time tracking
attotime m_last_frame_time; // time of the last frame callback
diff --git a/src/emu/machine.cpp b/src/emu/machine.cpp
index 3d9b6c428a2..a7fdddc5fd2 100644
--- a/src/emu/machine.cpp
+++ b/src/emu/machine.cpp
@@ -84,6 +84,7 @@
#include "network.h"
#include "romload.h"
#include "tilemap.h"
+#include "natkeyboard.h"
#include "ui/uimain.h"
#include <ctime>
#include <rapidjson/writer.h>
@@ -218,6 +219,9 @@ void running_machine::start()
if (newbase != 0)
m_base_time = newbase;
+ // initialize natural keyboard support after ports have been initialized
+ m_natkeyboard = std::make_unique<natural_keyboard>(*this);
+
// initialize the streams engine before the sound devices start
m_sound = std::make_unique<sound_manager>(*this);
diff --git a/src/emu/machine.h b/src/emu/machine.h
index ece7e65c025..37a5702c72e 100644
--- a/src/emu/machine.h
+++ b/src/emu/machine.h
@@ -188,6 +188,7 @@ public:
tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; }
debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; }
debugger_manager &debugger() const { assert(m_debugger != nullptr); return *m_debugger; }
+ natural_keyboard &natkeyboard() noexcept { assert(m_natkeyboard != nullptr); return *m_natkeyboard; }
template <class DriverClass> DriverClass *driver_data() const { return &downcast<DriverClass &>(root_device()); }
machine_phase phase() const { return m_current_phase; }
bool paused() const { return m_paused || (m_current_phase != machine_phase::RUNNING); }
@@ -336,6 +337,7 @@ private:
std::unique_ptr<image_manager> m_image; // internal data from image.cpp
std::unique_ptr<rom_load_manager> m_rom_load; // internal data from romload.cpp
std::unique_ptr<debugger_manager> m_debugger; // internal data from debugger.cpp
+ std::unique_ptr<natural_keyboard> m_natkeyboard; // internal data from natkeyboard.cpp
// system state
machine_phase m_current_phase; // current execution phase