Input: move some pad handler logic to the parent class

This commit is contained in:
Megamouse 2019-09-20 16:28:55 +02:00
parent 8f47f9517a
commit 4594148409
19 changed files with 1574 additions and 1602 deletions

View file

@ -94,7 +94,7 @@ pad_settings_dialog::pad_settings_dialog(QWidget *parent, const GameInfo *game)
// Fill input type combobox
std::vector<std::string> str_inputs = g_cfg_input.player[0]->handler.to_list();
for (int index = 0; index < str_inputs.size(); index++)
for (size_t index = 0; index < str_inputs.size(); index++)
{
ui->chooseHandler->addItem(qstr(str_inputs[index]));
}
@ -355,7 +355,7 @@ void pad_settings_dialog::InitButtons()
});
// Enable Button Remapping
const auto& callback = [=](u16 val, std::string name, std::string pad_name, int preview_values[6])
const auto& callback = [=](u16 val, std::string name, std::string pad_name, std::array<int, 6> preview_values)
{
SwitchPadInfo(pad_name, true);
@ -385,7 +385,7 @@ void pad_settings_dialog::InitButtons()
return;
}
LOG_NOTICE(HLE, "GetNextButtonPress: %s device %s button %s pressed with value %d", m_handler->m_type, pad_name, name, val);
LOG_NOTICE(HLE, "get_next_button_press: %s device %s button %s pressed with value %d", m_handler->m_type, pad_name, name, val);
if (m_button_id > button_ids::id_pad_begin && m_button_id < button_ids::id_pad_end)
{
m_cfg_entries[m_button_id].key = name;
@ -414,7 +414,7 @@ void pad_settings_dialog::InitButtons()
m_cfg_entries[button_ids::id_pad_rstick_left].key, m_cfg_entries[button_ids::id_pad_rstick_right].key, m_cfg_entries[button_ids::id_pad_rstick_down].key,
m_cfg_entries[button_ids::id_pad_rstick_up].key
};
m_handler->GetNextButtonPress(m_device_name, callback, fail_callback, false, buttons);
m_handler->get_next_button_press(m_device_name, callback, fail_callback, false, buttons);
});
// Use timer to refresh pad connection status
@ -428,7 +428,7 @@ void pad_settings_dialog::InitButtons()
continue;
}
const pad_info info = ui->chooseDevice->itemData(i).value<pad_info>();
m_handler->GetNextButtonPress(info.name, [=](u16, std::string, std::string pad_name, int[6]) { SwitchPadInfo(pad_name, true); }, [=](std::string pad_name) { SwitchPadInfo(pad_name, false); }, false);
m_handler->get_next_button_press(info.name, [=](u16, std::string, std::string pad_name, std::array<int, 6>) { SwitchPadInfo(pad_name, true); }, [=](std::string pad_name) { SwitchPadInfo(pad_name, false); }, false);
}
});
}
@ -835,7 +835,7 @@ void pad_settings_dialog::OnPadButtonClicked(int id)
UpdateLabel(true);
return;
case button_ids::id_blacklist:
m_handler->GetNextButtonPress(m_device_name, nullptr, nullptr, true);
m_handler->get_next_button_press(m_device_name, nullptr, nullptr, true);
return;
default:
break;
@ -987,7 +987,7 @@ void pad_settings_dialog::ChangeInputType()
case pad_handler::ds4:
{
const QString name_string = qstr(m_handler->name_string());
for (int i = 1; i <= m_handler->max_devices(); i++) // Controllers 1-n in GUI
for (size_t i = 1; i <= m_handler->max_devices(); i++) // Controllers 1-n in GUI
{
const QString device_name = name_string + QString::number(i);
ui->chooseDevice->addItem(device_name, QVariant::fromValue(pad_info{ sstr(device_name), true }));
@ -997,7 +997,7 @@ void pad_settings_dialog::ChangeInputType()
}
default:
{
for (int i = 0; i < device_list.size(); i++)
for (size_t i = 0; i < device_list.size(); i++)
{
ui->chooseDevice->addItem(qstr(device_list[i]), QVariant::fromValue(pad_info{ device_list[i], true }));
}
@ -1020,7 +1020,7 @@ void pad_settings_dialog::ChangeInputType()
continue;
}
const pad_info info = ui->chooseDevice->itemData(i).value<pad_info>();
m_handler->GetNextButtonPress(info.name, [=](u16, std::string, std::string pad_name, int[6]) { SwitchPadInfo(pad_name, true); }, [=](std::string pad_name) { SwitchPadInfo(pad_name, false); }, false);
m_handler->get_next_button_press(info.name, [=](u16, std::string, std::string pad_name, std::array<int, 6>) { SwitchPadInfo(pad_name, true); }, [=](std::string pad_name) { SwitchPadInfo(pad_name, false); }, false);
if (info.name == device)
{
ui->chooseDevice->setCurrentIndex(i);