summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-07-13 10:35:35 -0400
committerLioncash <mathew1800@gmail.com>2018-07-13 13:20:35 -0400
commit4c30b9e14dfbebe6a0c1131e3a5a19410b2dcdcd (patch)
treedc24f312b88bc8ea98932e9680289cde30b684f6 /Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
parentef1240b0c73a158c1d80fce5ab9724d0a793a491 (diff)
ControlGroup/Force: Return state data by value
Ensures that an array of sufficient size is always used and doesn't put the responsibility on the caller. It also allows for direct assignment.
Diffstat (limited to 'Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp')
-rw-r--r--Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
index 0c27e30298..c2178ea370 100644
--- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
+++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/Force.cpp
@@ -29,18 +29,23 @@ Force::Force(const std::string& name_) : ControlGroup(name_, GroupType::Force)
numeric_settings.emplace_back(std::make_unique<NumericSetting>(_trans("Dead Zone"), 0, 0, 50));
}
-void Force::GetState(ControlState* axis)
+Force::StateData Force::GetState()
{
+ StateData state_data;
const ControlState deadzone = numeric_settings[0]->GetValue();
for (u32 i = 0; i < 6; i += 2)
{
- ControlState tmpf = 0;
const ControlState state =
controls[i + 1]->control_ref->State() - controls[i]->control_ref->State();
+
+ ControlState tmpf = 0;
if (fabs(state) > deadzone)
tmpf = ((state - (deadzone * sign(state))) / (1 - deadzone));
- *axis++ = tmpf;
+
+ state_data[i / 2] = tmpf;
}
+
+ return state_data;
}
} // namespace ControllerEmu