mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
InputCommon: add a ton of missing consts
fix some related grammar errors only the ButtonManager required code changes
This commit is contained in:
@ -766,7 +766,7 @@ bool InputDevice::PressEvent(int button, int action)
|
||||
if (binding.second->m_bind_type == BIND_BUTTON)
|
||||
m_buttons[binding.second->m_button_type] = action == BUTTON_PRESSED ? true : false;
|
||||
else
|
||||
m_axises[binding.second->m_button_type] = action == BUTTON_PRESSED ? 1.0f : 0.0f;
|
||||
m_axes[binding.second->m_button_type] = action == BUTTON_PRESSED ? 1.0f : 0.0f;
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
@ -780,34 +780,54 @@ void InputDevice::AxisEvent(int axis, float value)
|
||||
if (binding.second->m_bind == axis)
|
||||
{
|
||||
if (binding.second->m_bind_type == BIND_AXIS)
|
||||
m_axises[binding.second->m_button_type] = value;
|
||||
m_axes[binding.second->m_button_type] = value;
|
||||
else
|
||||
m_buttons[binding.second->m_button_type] = value > 0.5f ? true : false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool InputDevice::ButtonValue(int pad_id, ButtonType button)
|
||||
bool InputDevice::ButtonValue(int pad_id, ButtonType button) const
|
||||
{
|
||||
const auto& binding = m_input_binds.find(std::make_pair(pad_id, button));
|
||||
const auto binding = m_input_binds.find(std::make_pair(pad_id, button));
|
||||
if (binding == m_input_binds.end())
|
||||
return false;
|
||||
|
||||
if (binding->second->m_bind_type == BIND_BUTTON)
|
||||
return m_buttons[binding->second->m_button_type];
|
||||
{
|
||||
const auto button = m_buttons.find(binding->second->m_button_type);
|
||||
if (button == m_buttons.end())
|
||||
return false;
|
||||
return button->second;
|
||||
}
|
||||
else
|
||||
return (m_axises[binding->second->m_button_type] * binding->second->m_neg) > 0.5f;
|
||||
{
|
||||
const auto axis = m_axes.find(binding->second->m_button_type);
|
||||
if (axis == m_axes.end())
|
||||
return false;
|
||||
return (axis->second * binding->second->m_neg) > 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
float InputDevice::AxisValue(int pad_id, ButtonType axis)
|
||||
float InputDevice::AxisValue(int pad_id, ButtonType axis) const
|
||||
{
|
||||
const auto& binding = m_input_binds.find(std::make_pair(pad_id, axis));
|
||||
const auto binding = m_input_binds.find(std::make_pair(pad_id, axis));
|
||||
if (binding == m_input_binds.end())
|
||||
return 0.0f;
|
||||
|
||||
if (binding->second->m_bind_type == BIND_AXIS)
|
||||
return m_axises[binding->second->m_button_type] * binding->second->m_neg;
|
||||
{
|
||||
const auto axis = m_axes.find(binding->second->m_button_type);
|
||||
if (axis == m_axes.end())
|
||||
return 0.0f;
|
||||
return axis->second * binding->second->m_neg;
|
||||
}
|
||||
else
|
||||
return m_buttons[binding->second->m_button_type] == BUTTON_PRESSED ? 1.0f : 0.0f;
|
||||
{
|
||||
const auto button = m_buttons.find(binding->second->m_button_type);
|
||||
if (button == m_buttons.end())
|
||||
return 0.0f;
|
||||
return button->second == BUTTON_PRESSED ? 1.0f : 0.0f;
|
||||
}
|
||||
}
|
||||
} // namespace ButtonManager
|
||||
|
@ -210,7 +210,7 @@ private:
|
||||
public:
|
||||
Button() : m_state(BUTTON_RELEASED) {}
|
||||
void SetState(ButtonState state) { m_state = state; }
|
||||
bool Pressed() { return m_state == BUTTON_PRESSED; }
|
||||
bool Pressed() const { return m_state == BUTTON_PRESSED; }
|
||||
~Button() {}
|
||||
};
|
||||
class Axis
|
||||
@ -221,7 +221,7 @@ private:
|
||||
public:
|
||||
Axis() : m_value(0.0f) {}
|
||||
void SetValue(float value) { m_value = value; }
|
||||
float AxisValue() { return m_value; }
|
||||
float AxisValue() const { return m_value; }
|
||||
~Axis() {}
|
||||
};
|
||||
|
||||
@ -244,7 +244,7 @@ class InputDevice
|
||||
private:
|
||||
const std::string m_dev;
|
||||
std::map<ButtonType, bool> m_buttons;
|
||||
std::map<ButtonType, float> m_axises;
|
||||
std::map<ButtonType, float> m_axes;
|
||||
|
||||
// Key is pad_id and ButtonType
|
||||
std::map<std::pair<int, ButtonType>, sBind*> m_input_binds;
|
||||
@ -263,8 +263,8 @@ public:
|
||||
}
|
||||
bool PressEvent(int button, int action);
|
||||
void AxisEvent(int axis, float value);
|
||||
bool ButtonValue(int pad_id, ButtonType button);
|
||||
float AxisValue(int pad_id, ButtonType axis);
|
||||
bool ButtonValue(int pad_id, ButtonType button) const;
|
||||
float AxisValue(int pad_id, ButtonType axis) const;
|
||||
};
|
||||
|
||||
void Init(const std::string&);
|
||||
|
Reference in New Issue
Block a user