From fa05710f2f87e714e8592a75d3bc17b1f82b40f3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 3 Oct 2015 15:37:25 -0400 Subject: [PATCH] ControllerEmu: Use make_unique over raw new --- Source/Core/InputCommon/ControllerEmu.cpp | 65 ++++++++++++----------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/Source/Core/InputCommon/ControllerEmu.cpp b/Source/Core/InputCommon/ControllerEmu.cpp index 6a00eb5156..ff706c8168 100644 --- a/Source/Core/InputCommon/ControllerEmu.cpp +++ b/Source/Core/InputCommon/ControllerEmu.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include #include "Common/Common.h" #include "InputCommon/ControllerEmu.h" @@ -151,64 +152,64 @@ ControllerEmu::AnalogStick::AnalogStick(const char* const _name, const char* con : ControlGroup(_name, _ui_name, GROUP_TYPE_STICK) { for (auto& named_direction : named_directions) - controls.emplace_back(new Input(named_direction)); + controls.emplace_back(std::make_unique(named_direction)); - controls.emplace_back(new Input(_trans("Modifier"))); - settings.emplace_back(new Setting(_trans("Radius"), default_radius, 0, 100)); - settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); + controls.emplace_back(std::make_unique(_trans("Modifier"))); + settings.emplace_back(std::make_unique(_trans("Radius"), default_radius, 0, 100)); + settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } ControllerEmu::Buttons::Buttons(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_BUTTONS) { - settings.emplace_back(new Setting(_trans("Threshold"), 0.5)); + settings.emplace_back(std::make_unique(_trans("Threshold"), 0.5)); } ControllerEmu::MixedTriggers::MixedTriggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_MIXED_TRIGGERS) { - settings.emplace_back(new Setting(_trans("Threshold"), 0.9)); + settings.emplace_back(std::make_unique(_trans("Threshold"), 0.9)); } ControllerEmu::Triggers::Triggers(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_TRIGGERS) { - settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); + settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } ControllerEmu::Slider::Slider(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_SLIDER) { - controls.emplace_back(new Input("Left")); - controls.emplace_back(new Input("Right")); + controls.emplace_back(std::make_unique("Left")); + controls.emplace_back(std::make_unique("Right")); - settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); + settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } ControllerEmu::Force::Force(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_FORCE) { memset(m_swing, 0, sizeof(m_swing)); - controls.emplace_back(new Input(_trans("Up"))); - controls.emplace_back(new Input(_trans("Down"))); - controls.emplace_back(new Input(_trans("Left"))); - controls.emplace_back(new Input(_trans("Right"))); - controls.emplace_back(new Input(_trans("Forward"))); - controls.emplace_back(new Input(_trans("Backward"))); + controls.emplace_back(std::make_unique(_trans("Up"))); + controls.emplace_back(std::make_unique(_trans("Down"))); + controls.emplace_back(std::make_unique(_trans("Left"))); + controls.emplace_back(std::make_unique(_trans("Right"))); + controls.emplace_back(std::make_unique(_trans("Forward"))); + controls.emplace_back(std::make_unique(_trans("Backward"))); - settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); + settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); } ControllerEmu::Tilt::Tilt(const std::string& _name) : ControlGroup(_name, GROUP_TYPE_TILT) { memset(m_tilt, 0, sizeof(m_tilt)); - controls.emplace_back(new Input("Forward")); - controls.emplace_back(new Input("Backward")); - controls.emplace_back(new Input("Left")); - controls.emplace_back(new Input("Right")); + controls.emplace_back(std::make_unique("Forward")); + controls.emplace_back(std::make_unique("Backward")); + controls.emplace_back(std::make_unique("Left")); + controls.emplace_back(std::make_unique("Right")); - controls.emplace_back(new Input(_trans("Modifier"))); + controls.emplace_back(std::make_unique(_trans("Modifier"))); - settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50)); - settings.emplace_back(new Setting(_trans("Circle Stick"), 0)); - settings.emplace_back(new Setting(_trans("Angle"), 0.9, 0, 180)); + settings.emplace_back(std::make_unique(_trans("Dead Zone"), 0, 0, 50)); + settings.emplace_back(std::make_unique(_trans("Circle Stick"), 0)); + settings.emplace_back(std::make_unique(_trans("Angle"), 0.9, 0, 180)); } ControllerEmu::Cursor::Cursor(const std::string& _name) @@ -216,14 +217,14 @@ ControllerEmu::Cursor::Cursor(const std::string& _name) , m_z(0) { for (auto& named_direction : named_directions) - controls.emplace_back(new Input(named_direction)); - controls.emplace_back(new Input("Forward")); - controls.emplace_back(new Input("Backward")); - controls.emplace_back(new Input(_trans("Hide"))); + controls.emplace_back(std::make_unique(named_direction)); + controls.emplace_back(std::make_unique("Forward")); + controls.emplace_back(std::make_unique("Backward")); + controls.emplace_back(std::make_unique(_trans("Hide"))); - settings.emplace_back(new Setting(_trans("Center"), 0.5)); - settings.emplace_back(new Setting(_trans("Width"), 0.5)); - settings.emplace_back(new Setting(_trans("Height"), 0.5)); + settings.emplace_back(std::make_unique(_trans("Center"), 0.5)); + settings.emplace_back(std::make_unique(_trans("Width"), 0.5)); + settings.emplace_back(std::make_unique(_trans("Height"), 0.5)); } void ControllerEmu::LoadDefaults(const ControllerInterface &ciface)