yuzu/configuration: Only assert that all buttons exist when we are handling the click for a button device

This fixes failed assertions that were present in yuzu master code for 18 months.
This commit is contained in:
FearlessTobi 2020-04-05 07:16:09 +02:00
parent fb8afee077
commit aa6214feb7
2 changed files with 16 additions and 14 deletions

View file

@ -541,18 +541,19 @@ void ConfigureInputPlayer::HandleClick(
button->setText(tr("[press key]")); button->setText(tr("[press key]"));
button->setFocus(); button->setFocus();
const auto iter = std::find(button_map.begin(), button_map.end(), button); // Keyboard keys can only be used as button devices
ASSERT(iter != button_map.end()); want_keyboard_keys = type == InputCommon::Polling::DeviceType::Button;
const auto index = std::distance(button_map.begin(), iter); if (want_keyboard_keys) {
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0); const auto iter = std::find(button_map.begin(), button_map.end(), button);
ASSERT(iter != button_map.end());
const auto index = std::distance(button_map.begin(), iter);
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0);
}
input_setter = new_input_setter; input_setter = new_input_setter;
device_pollers = InputCommon::Polling::GetPollers(type); device_pollers = InputCommon::Polling::GetPollers(type);
// Keyboard keys can only be used as button devices
want_keyboard_keys = type == InputCommon::Polling::DeviceType::Button;
for (auto& poller : device_pollers) { for (auto& poller : device_pollers) {
poller->Start(); poller->Start();
} }

View file

@ -184,18 +184,19 @@ void ConfigureMouseAdvanced::HandleClick(
button->setText(tr("[press key]")); button->setText(tr("[press key]"));
button->setFocus(); button->setFocus();
const auto iter = std::find(button_map.begin(), button_map.end(), button); // Keyboard keys can only be used as button devices
ASSERT(iter != button_map.end()); want_keyboard_keys = type == InputCommon::Polling::DeviceType::Button;
const auto index = std::distance(button_map.begin(), iter); if (want_keyboard_keys) {
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0); const auto iter = std::find(button_map.begin(), button_map.end(), button);
ASSERT(iter != button_map.end());
const auto index = std::distance(button_map.begin(), iter);
ASSERT(index < Settings::NativeButton::NumButtons && index >= 0);
}
input_setter = new_input_setter; input_setter = new_input_setter;
device_pollers = InputCommon::Polling::GetPollers(type); device_pollers = InputCommon::Polling::GetPollers(type);
// Keyboard keys can only be used as button devices
want_keyboard_keys = type == InputCommon::Polling::DeviceType::Button;
for (auto& poller : device_pollers) { for (auto& poller : device_pollers) {
poller->Start(); poller->Start();
} }