summaryrefslogtreecommitdiff
path: root/src/common/input.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/input.h')
-rw-r--r--src/common/input.h40
1 files changed, 37 insertions, 3 deletions
diff --git a/src/common/input.h b/src/common/input.h
index cb30b7254..449e0193f 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -383,6 +383,16 @@ void RegisterFactory(const std::string& name, std::shared_ptr<Factory<InputDevic
383 } 383 }
384} 384}
385 385
386inline void RegisterInputFactory(const std::string& name,
387 std::shared_ptr<Factory<InputDevice>> factory) {
388 RegisterFactory<InputDevice>(name, std::move(factory));
389}
390
391inline void RegisterOutputFactory(const std::string& name,
392 std::shared_ptr<Factory<OutputDevice>> factory) {
393 RegisterFactory<OutputDevice>(name, std::move(factory));
394}
395
386/** 396/**
387 * Unregisters an input device factory. 397 * Unregisters an input device factory.
388 * @tparam InputDeviceType the type of input devices the factory can create 398 * @tparam InputDeviceType the type of input devices the factory can create
@@ -395,6 +405,14 @@ void UnregisterFactory(const std::string& name) {
395 } 405 }
396} 406}
397 407
408inline void UnregisterInputFactory(const std::string& name) {
409 UnregisterFactory<InputDevice>(name);
410}
411
412inline void UnregisterOutputFactory(const std::string& name) {
413 UnregisterFactory<OutputDevice>(name);
414}
415
398/** 416/**
399 * Create an input device from given paramters. 417 * Create an input device from given paramters.
400 * @tparam InputDeviceType the type of input devices to create 418 * @tparam InputDeviceType the type of input devices to create
@@ -416,13 +434,21 @@ std::unique_ptr<InputDeviceType> CreateDeviceFromString(const std::string& param
416 return pair->second->Create(package); 434 return pair->second->Create(package);
417} 435}
418 436
437inline std::unique_ptr<InputDevice> CreateInputDeviceFromString(const std::string& params) {
438 return CreateDeviceFromString<InputDevice>(params);
439}
440
441inline std::unique_ptr<OutputDevice> CreateOutputDeviceFromString(const std::string& params) {
442 return CreateDeviceFromString<OutputDevice>(params);
443}
444
419/** 445/**
420 * Create an input device from given paramters. 446 * Create an input device from given parameters.
421 * @tparam InputDeviceType the type of input devices to create 447 * @tparam InputDeviceType the type of input devices to create
422 * @param A ParamPackage that contains all parameters for creating the device 448 * @param package A ParamPackage that contains all parameters for creating the device
423 */ 449 */
424template <typename InputDeviceType> 450template <typename InputDeviceType>
425std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package) { 451std::unique_ptr<InputDeviceType> CreateDevice(const ParamPackage& package) {
426 const std::string engine = package.Get("engine", "null"); 452 const std::string engine = package.Get("engine", "null");
427 const auto& factory_list = Impl::FactoryList<InputDeviceType>::list; 453 const auto& factory_list = Impl::FactoryList<InputDeviceType>::list;
428 const auto pair = factory_list.find(engine); 454 const auto pair = factory_list.find(engine);
@@ -435,4 +461,12 @@ std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package
435 return pair->second->Create(package); 461 return pair->second->Create(package);
436} 462}
437 463
464inline std::unique_ptr<InputDevice> CreateInputDevice(const ParamPackage& package) {
465 return CreateDevice<InputDevice>(package);
466}
467
468inline std::unique_ptr<OutputDevice> CreateOutputDevice(const ParamPackage& package) {
469 return CreateDevice<OutputDevice>(package);
470}
471
438} // namespace Common::Input 472} // namespace Common::Input