Qt: Handle inverted+negated axes when mapping

arm-build
Stenzek 12 hours ago
parent ec7c83a58e
commit be970bcfe4
No known key found for this signature in database

@ -2270,7 +2270,8 @@ void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::T
} }
const float abs_value = std::abs(value); const float abs_value = std::abs(value);
const bool reverse_threshold = (key.source_subtype == InputSubclass::ControllerAxis && initial_value > 0.5f); const bool reverse_threshold =
(key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f);
for (InputBindingKey& other_key : s_state.input_binding_new_bindings) for (InputBindingKey& other_key : s_state.input_binding_new_bindings)
{ {
@ -2305,7 +2306,7 @@ void FullscreenUI::BeginInputBinding(SettingsInterface* bsi, InputBindingInfo::T
if ((reverse_threshold ? (abs_value < 0.5f) : (abs_value >= 0.5f))) if ((reverse_threshold ? (abs_value < 0.5f) : (abs_value >= 0.5f)))
{ {
InputBindingKey key_to_add = key; InputBindingKey key_to_add = key;
key_to_add.modifier = (value < 0.0f && !reverse_threshold) ? InputModifier::Negate : InputModifier::None; key_to_add.modifier = (value < 0.0f) ? InputModifier::Negate : InputModifier::None;
key_to_add.invert = reverse_threshold; key_to_add.invert = reverse_threshold;
s_state.input_binding_new_bindings.push_back(key_to_add); s_state.input_binding_new_bindings.push_back(key_to_add);
} }

@ -306,7 +306,8 @@ void InputBindingDialog::inputManagerHookCallback(InputBindingKey key, float val
} }
const float abs_value = std::abs(value); const float abs_value = std::abs(value);
const bool reverse_threshold = (key.source_subtype == InputSubclass::ControllerAxis && initial_value > 0.5f); const bool reverse_threshold =
(key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f);
for (InputBindingKey& other_key : m_new_bindings) for (InputBindingKey& other_key : m_new_bindings)
{ {
@ -334,7 +335,7 @@ void InputBindingDialog::inputManagerHookCallback(InputBindingKey key, float val
if ((reverse_threshold ? (abs_value < 0.5f) : (abs_value >= 0.5f))) if ((reverse_threshold ? (abs_value < 0.5f) : (abs_value >= 0.5f)))
{ {
InputBindingKey key_to_add = key; InputBindingKey key_to_add = key;
key_to_add.modifier = (value < 0.0f && !reverse_threshold) ? InputModifier::Negate : InputModifier::None; key_to_add.modifier = (value < 0.0f) ? InputModifier::Negate : InputModifier::None;
key_to_add.invert = reverse_threshold; key_to_add.invert = reverse_threshold;
m_new_bindings.push_back(key_to_add); m_new_bindings.push_back(key_to_add);
} }

@ -346,7 +346,8 @@ void InputBindingWidget::inputManagerHookCallback(InputBindingKey key, float val
} }
const float abs_value = std::abs(value); const float abs_value = std::abs(value);
const bool reverse_threshold = (key.source_subtype == InputSubclass::ControllerAxis && initial_value > 0.5f); const bool reverse_threshold =
(key.source_subtype == InputSubclass::ControllerAxis && std::abs(initial_value) > 0.5f);
for (InputBindingKey& other_key : m_new_bindings) for (InputBindingKey& other_key : m_new_bindings)
{ {
@ -374,7 +375,7 @@ void InputBindingWidget::inputManagerHookCallback(InputBindingKey key, float val
if ((reverse_threshold ? (abs_value < 0.5f) : (abs_value >= 0.5f))) if ((reverse_threshold ? (abs_value < 0.5f) : (abs_value >= 0.5f)))
{ {
InputBindingKey key_to_add = key; InputBindingKey key_to_add = key;
key_to_add.modifier = (value < 0.0f && !reverse_threshold) ? InputModifier::Negate : InputModifier::None; key_to_add.modifier = (value < 0.0f) ? InputModifier::Negate : InputModifier::None;
key_to_add.invert = reverse_threshold; key_to_add.invert = reverse_threshold;
m_new_bindings.push_back(key_to_add); m_new_bindings.push_back(key_to_add);
} }

Loading…
Cancel
Save