Merge pull request #4899 from lioncash/array

ControlGroup: Use std::array for Force and Tilt groups
This commit is contained in:
Anthony 2017-02-12 01:21:44 -08:00 committed by GitHub
commit 7d36f1a7aa
4 changed files with 4 additions and 8 deletions

View File

@ -5,7 +5,6 @@
#include "InputCommon/ControllerEmu/ControlGroup/Force.h" #include "InputCommon/ControllerEmu/ControlGroup/Force.h"
#include <cmath> #include <cmath>
#include <cstring>
#include <memory> #include <memory>
#include <string> #include <string>
@ -19,8 +18,6 @@ namespace ControllerEmu
{ {
Force::Force(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_FORCE) Force::Force(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_FORCE)
{ {
memset(m_swing, 0, sizeof(m_swing));
controls.emplace_back(std::make_unique<Input>(_trans("Up"))); 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("Down")));
controls.emplace_back(std::make_unique<Input>(_trans("Left"))); controls.emplace_back(std::make_unique<Input>(_trans("Left")));

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <array>
#include <string> #include <string>
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
@ -17,6 +18,6 @@ public:
void GetState(ControlState* axis); void GetState(ControlState* axis);
private: private:
ControlState m_swing[3]; std::array<ControlState, 3> m_swing{};
}; };
} // namespace ControllerEmu } // namespace ControllerEmu

View File

@ -6,7 +6,6 @@
#include <algorithm> #include <algorithm>
#include <cmath> #include <cmath>
#include <cstring>
#include <memory> #include <memory>
#include <string> #include <string>
@ -19,8 +18,6 @@ namespace ControllerEmu
{ {
Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_TILT) Tilt::Tilt(const std::string& name_) : ControlGroup(name_, GROUP_TYPE_TILT)
{ {
memset(m_tilt, 0, sizeof(m_tilt));
controls.emplace_back(std::make_unique<Input>("Forward")); controls.emplace_back(std::make_unique<Input>("Forward"));
controls.emplace_back(std::make_unique<Input>("Backward")); controls.emplace_back(std::make_unique<Input>("Backward"));
controls.emplace_back(std::make_unique<Input>("Left")); controls.emplace_back(std::make_unique<Input>("Left"));

View File

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <array>
#include <string> #include <string>
#include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h" #include "InputCommon/ControllerEmu/ControlGroup/ControlGroup.h"
@ -17,6 +18,6 @@ public:
void GetState(ControlState* x, ControlState* y, bool step = true); void GetState(ControlState* x, ControlState* y, bool step = true);
private: private:
ControlState m_tilt[2]; std::array<ControlState, 2> m_tilt{};
}; };
} // namespace ControllerEmu } // namespace ControllerEmu