Add scaling factors for input actions
This commit is contained in:
@@ -11,33 +11,54 @@
|
||||
|
||||
namespace OpenVulkano::Input
|
||||
{
|
||||
struct KeyBinding
|
||||
{
|
||||
InputKey key;
|
||||
float scale;
|
||||
|
||||
KeyBinding(InputKey keyBinding, float scaleFactor)
|
||||
: key(keyBinding), scale(scaleFactor)
|
||||
{}
|
||||
};
|
||||
|
||||
struct AxisButtonBinding
|
||||
{
|
||||
InputKey positive;
|
||||
InputKey negative;
|
||||
float scale;
|
||||
|
||||
AxisButtonBinding(InputKey pos, InputKey neg, float scaleFactor)
|
||||
: positive(pos), negative(neg), scale(scaleFactor)
|
||||
{}
|
||||
};
|
||||
|
||||
class InputAction final : public BaseInputAction
|
||||
{
|
||||
std::vector<InputKey> keys;
|
||||
std::vector<std::pair<InputKey, InputKey>> axisButtons;
|
||||
std::vector<KeyBinding> keys;
|
||||
std::vector<AxisButtonBinding> axisButtons;
|
||||
|
||||
public:
|
||||
InputAction(const std::string& name) : BaseInputAction(name)
|
||||
{}
|
||||
|
||||
[[nodiscard]] const std::vector<InputKey>& GetKeys() const
|
||||
[[nodiscard]] const std::vector<KeyBinding>& GetKeys() const
|
||||
{
|
||||
return keys;
|
||||
}
|
||||
|
||||
[[nodiscard]] const std::vector<std::pair<InputKey, InputKey>>& GetAxisButtons() const
|
||||
[[nodiscard]] const std::vector<AxisButtonBinding>& GetAxisButtons() const
|
||||
{
|
||||
return axisButtons;
|
||||
}
|
||||
|
||||
void BindKey(InputKey key)
|
||||
void BindKey(InputKey key, float scale = 1)
|
||||
{
|
||||
keys.push_back(key);
|
||||
keys.emplace_back(key, scale);
|
||||
}
|
||||
|
||||
void BindAxisButtons(InputKey keyPositive, InputKey keyNegative)
|
||||
void BindAxisButtons(InputKey keyPositive, InputKey keyNegative, float scale = 1)
|
||||
{
|
||||
axisButtons.emplace_back(keyPositive, keyNegative);
|
||||
axisButtons.emplace_back(keyPositive, keyNegative, scale);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user