diff --git a/apps/openmw/mwinput/bindingsmanager.cpp b/apps/openmw/mwinput/bindingsmanager.cpp index 18fac6ae29..851e33a87c 100644 --- a/apps/openmw/mwinput/bindingsmanager.cpp +++ b/apps/openmw/mwinput/bindingsmanager.cpp @@ -171,16 +171,16 @@ namespace MWInput , mDragDrop(false) { std::string file = userFileExists ? userFile : ""; - mInputBinder = new InputControlSystem(file); - mListener = new BindingsListener(mInputBinder, this); - mInputBinder->setDetectingBindingListener(mListener); + mInputBinder = std::make_unique(file); + mListener = std::make_unique(mInputBinder.get(), this); + mInputBinder->setDetectingBindingListener(mListener.get()); loadKeyDefaults(); loadControllerDefaults(); for (int i = 0; i < A_Last; ++i) { - mInputBinder->getChannel(i)->addListener(mListener); + mInputBinder->getChannel(i)->addListener(mListener.get()); } } @@ -192,7 +192,6 @@ namespace MWInput BindingsManager::~BindingsManager() { mInputBinder->save(mUserFile); - delete mInputBinder; } void BindingsManager::update(float dt) @@ -315,7 +314,7 @@ namespace MWInput && mInputBinder->getMouseButtonBinding(control, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS && mInputBinder->getMouseWheelBinding(control, ICS::Control::INCREASE) == ICS::InputControlSystem::MouseWheelClick::UNASSIGNED)) { - clearAllKeyBindings(mInputBinder, control); + clearAllKeyBindings(mInputBinder.get(), control); if (defaultKeyBindings.find(i) != defaultKeyBindings.end() && (force || !mInputBinder->isKeyBound(defaultKeyBindings[i]))) @@ -402,7 +401,7 @@ namespace MWInput if (!controlExists || force || (mInputBinder->getJoystickAxisBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS::InputControlSystem::UNASSIGNED && mInputBinder->getJoystickButtonBinding(control, sFakeDeviceId, ICS::Control::INCREASE) == ICS_MAX_DEVICE_BUTTONS)) { - clearAllControllerBindings(mInputBinder, control); + clearAllControllerBindings(mInputBinder.get(), control); if (defaultButtonBindings.find(i) != defaultButtonBindings.end() && (force || !mInputBinder->isJoystickButtonBound(sFakeDeviceId, defaultButtonBindings[i]))) diff --git a/apps/openmw/mwinput/bindingsmanager.hpp b/apps/openmw/mwinput/bindingsmanager.hpp index 7a44a1a335..74416d3c7f 100644 --- a/apps/openmw/mwinput/bindingsmanager.hpp +++ b/apps/openmw/mwinput/bindingsmanager.hpp @@ -1,6 +1,7 @@ #ifndef MWINPUT_MWBINDINGSMANAGER_H #define MWINPUT_MWBINDINGSMANAGER_H +#include #include #include @@ -64,8 +65,8 @@ namespace MWInput private: void setupSDLKeyMappings(); - InputControlSystem* mInputBinder; - BindingsListener* mListener; + std::unique_ptr mInputBinder; + std::unique_ptr mListener; std::string mUserFile;