Skip to content
Permalink
Browse files

Merge pull request #3128 from lioncash/unique

ControllerEmu: Use make_unique over raw new
  • Loading branch information...
shuffle2 committed Oct 4, 2015
2 parents 569d25d + fa05710 commit 6d4128ddcccc0ff04ace8bc1f35f022afeae5e0b
Showing with 34 additions and 33 deletions.
  1. +34 −33 Source/Core/InputCommon/ControllerEmu.cpp
@@ -2,6 +2,7 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.

#include <memory>
#include "Common/Common.h"
#include "InputCommon/ControllerEmu.h"

@@ -156,79 +157,79 @@ 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<Input>(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<Input>(_trans("Modifier")));
settings.emplace_back(std::make_unique<Setting>(_trans("Radius"), default_radius, 0, 100));
settings.emplace_back(std::make_unique<Setting>(_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<Setting>(_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<Setting>(_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<Setting>(_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<Input>("Left"));
controls.emplace_back(std::make_unique<Input>("Right"));

settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
settings.emplace_back(std::make_unique<Setting>(_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<Input>(_trans("Up")));
controls.emplace_back(std::make_unique<Input>(_trans("Down")));
controls.emplace_back(std::make_unique<Input>(_trans("Left")));
controls.emplace_back(std::make_unique<Input>(_trans("Right")));
controls.emplace_back(std::make_unique<Input>(_trans("Forward")));
controls.emplace_back(std::make_unique<Input>(_trans("Backward")));

settings.emplace_back(new Setting(_trans("Dead Zone"), 0, 0, 50));
settings.emplace_back(std::make_unique<Setting>(_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<Input>("Forward"));
controls.emplace_back(std::make_unique<Input>("Backward"));
controls.emplace_back(std::make_unique<Input>("Left"));
controls.emplace_back(std::make_unique<Input>("Right"));

controls.emplace_back(new Input(_trans("Modifier")));
controls.emplace_back(std::make_unique<Input>(_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<Setting>(_trans("Dead Zone"), 0, 0, 50));
settings.emplace_back(std::make_unique<Setting>(_trans("Circle Stick"), 0));
settings.emplace_back(std::make_unique<Setting>(_trans("Angle"), 0.9, 0, 180));
}

ControllerEmu::Cursor::Cursor(const std::string& _name)
: ControlGroup(_name, GROUP_TYPE_CURSOR)
, 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")));

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));
controls.emplace_back(std::make_unique<Input>(named_direction));
controls.emplace_back(std::make_unique<Input>("Forward"));
controls.emplace_back(std::make_unique<Input>("Backward"));
controls.emplace_back(std::make_unique<Input>(_trans("Hide")));

settings.emplace_back(std::make_unique<Setting>(_trans("Center"), 0.5));
settings.emplace_back(std::make_unique<Setting>(_trans("Width"), 0.5));
settings.emplace_back(std::make_unique<Setting>(_trans("Height"), 0.5));
}

void ControllerEmu::LoadDefaults(const ControllerInterface &ciface)

0 comments on commit 6d4128d

Please sign in to comment.
You can’t perform that action at this time.