ControllerEmu: Add new "input override" system

This commit is contained in:
JosJuice
2021-03-21 20:27:00 +01:00
parent cb6d476538
commit cb16d20f2d
27 changed files with 355 additions and 74 deletions

View File

@ -3,6 +3,7 @@
#pragma once
#include <cmath>
#include <string>
#include "InputCommon/ControlReference/ControlReference.h"
@ -24,5 +25,21 @@ public:
for (auto& control : controls)
*buttons |= *(bitmasks++) * control->GetState<bool>();
}
template <typename C>
void GetState(C* const buttons, const C* bitmasks,
const InputOverrideFunction& override_func) const
{
if (!override_func)
return GetState(buttons, bitmasks);
for (auto& control : controls)
{
ControlState state = control->GetState();
if (std::optional<ControlState> state_override = override_func(name, control->name, state))
state = *state_override;
*buttons |= *(bitmasks++) * (std::lround(state) > 0);
}
}
};
} // namespace ControllerEmu