summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/input/input_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/input/input_common.h')
-rw-r--r--src/osd/modules/input/input_common.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/osd/modules/input/input_common.h b/src/osd/modules/input/input_common.h
index 7ea001dad4f..41a9d762838 100644
--- a/src/osd/modules/input/input_common.h
+++ b/src/osd/modules/input/input_common.h
@@ -352,19 +352,35 @@ public:
// allocate the device object
auto devinfo = std::make_unique<TActual>(machine, name, module);
- // Add the device to the machine
- devinfo->m_device = machine.input().device_class(devinfo->deviceclass()).add_device(devinfo->name(), devinfo.get());
+ return add_device_internal(machine, name, module, std::move(devinfo));
+ }
- // append us to the list
- m_list.push_back(std::move(devinfo));
+ template <typename TActual, typename TArg>
+ TActual* create_device1(running_machine &machine, const char *name, input_module &module, TArg arg1)
+ {
+ // allocate the device object
+ auto devinfo = std::make_unique<TActual>(machine, name, module, arg1);
- return (TActual*)m_list.back().get();
+ return add_device_internal(machine, name, module, std::move(devinfo));
}
template <class TActual>
TActual* at(int index)
{
- return (TActual*)m_list.at(index).get();
+ return static_cast<TActual*>(m_list.at(index).get());
+ }
+
+private:
+ template <typename TActual>
+ TActual* add_device_internal(running_machine &machine, const char *name, input_module &module, std::unique_ptr<TActual> allocated)
+ {
+ // Add the device to the machine
+ allocated->m_device = machine.input().device_class(allocated->deviceclass()).add_device(allocated->name(), allocated.get());
+
+ // append us to the list
+ m_list.push_back(std::move(allocated));
+
+ return static_cast<TActual*>(m_list.back().get());
}
};