diff options
author | Morph <39850852+Morph1984@users.noreply.github.com> | 2022-11-28 19:12:08 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-28 19:12:08 +0100 |
commit | 64ff79f919987685d5328114c4125140fece98d1 (patch) | |
tree | 46cdffe7768f619a621aa50fe82f813d15bd517e /src/common/input.h | |
parent | Merge pull request #9336 from lioncash/themepath (diff) | |
parent | core/hid/emulated_controller: Use ranges version of transform (diff) | |
download | yuzu-64ff79f919987685d5328114c4125140fece98d1.tar yuzu-64ff79f919987685d5328114c4125140fece98d1.tar.gz yuzu-64ff79f919987685d5328114c4125140fece98d1.tar.bz2 yuzu-64ff79f919987685d5328114c4125140fece98d1.tar.lz yuzu-64ff79f919987685d5328114c4125140fece98d1.tar.xz yuzu-64ff79f919987685d5328114c4125140fece98d1.tar.zst yuzu-64ff79f919987685d5328114c4125140fece98d1.zip |
Diffstat (limited to '')
-rw-r--r-- | src/common/input.h | 40 |
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 } } +inline void RegisterInputFactory(const std::string& name, + std::shared_ptr<Factory<InputDevice>> factory) { + RegisterFactory<InputDevice>(name, std::move(factory)); +} + +inline void RegisterOutputFactory(const std::string& name, + std::shared_ptr<Factory<OutputDevice>> factory) { + RegisterFactory<OutputDevice>(name, std::move(factory)); +} + /** * Unregisters an input device factory. * @tparam InputDeviceType the type of input devices the factory can create @@ -395,6 +405,14 @@ void UnregisterFactory(const std::string& name) { } } +inline void UnregisterInputFactory(const std::string& name) { + UnregisterFactory<InputDevice>(name); +} + +inline void UnregisterOutputFactory(const std::string& name) { + UnregisterFactory<OutputDevice>(name); +} + /** * Create an input device from given paramters. * @tparam InputDeviceType the type of input devices to create @@ -416,13 +434,21 @@ std::unique_ptr<InputDeviceType> CreateDeviceFromString(const std::string& param return pair->second->Create(package); } +inline std::unique_ptr<InputDevice> CreateInputDeviceFromString(const std::string& params) { + return CreateDeviceFromString<InputDevice>(params); +} + +inline std::unique_ptr<OutputDevice> CreateOutputDeviceFromString(const std::string& params) { + return CreateDeviceFromString<OutputDevice>(params); +} + /** - * Create an input device from given paramters. + * Create an input device from given parameters. * @tparam InputDeviceType the type of input devices to create - * @param A ParamPackage that contains all parameters for creating the device + * @param package A ParamPackage that contains all parameters for creating the device */ template <typename InputDeviceType> -std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package) { +std::unique_ptr<InputDeviceType> CreateDevice(const ParamPackage& package) { const std::string engine = package.Get("engine", "null"); const auto& factory_list = Impl::FactoryList<InputDeviceType>::list; const auto pair = factory_list.find(engine); @@ -435,4 +461,12 @@ std::unique_ptr<InputDeviceType> CreateDevice(const Common::ParamPackage package return pair->second->Create(package); } +inline std::unique_ptr<InputDevice> CreateInputDevice(const ParamPackage& package) { + return CreateDevice<InputDevice>(package); +} + +inline std::unique_ptr<OutputDevice> CreateOutputDevice(const ParamPackage& package) { + return CreateDevice<OutputDevice>(package); +} + } // namespace Common::Input |