more fixes
This commit is contained in:
parent
39140bbff8
commit
860860397b
@ -100,163 +100,162 @@ ConfigureInput::ConfigureInput(QWidget* parent)
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
setFocusPolicy(Qt::ClickFocus);
|
setFocusPolicy(Qt::ClickFocus);
|
||||||
|
|
||||||
for (const auto& profile : Settings::values::profiles) {
|
for (const auto& profile : Settings::values.input_profiles) {
|
||||||
ui->profile->addItem(QString::fromStdString(profile.name));
|
ui->profile->addItem(QString::fromStdString(profile.name));
|
||||||
}
|
}
|
||||||
ui->profile->addItem(QString::fromStdString(Settings::values.profiles[i].name));
|
|
||||||
}
|
|
||||||
|
|
||||||
ui->profile->setCurrentIndex(Settings::values.current_input_profile);
|
ui->profile->setCurrentIndex(Settings::values.current_input_profile);
|
||||||
|
|
||||||
button_map = {
|
button_map = {
|
||||||
ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, ui->buttonDpadUp,
|
ui->buttonA, ui->buttonB, ui->buttonX, ui->buttonY, ui->buttonDpadUp,
|
||||||
ui->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL, ui->buttonR,
|
ui->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL, ui->buttonR,
|
||||||
ui->buttonStart, ui->buttonSelect, ui->buttonZL, ui->buttonZR, ui->buttonHome,
|
ui->buttonStart, ui->buttonSelect, ui->buttonZL, ui->buttonZR, ui->buttonHome,
|
||||||
};
|
};
|
||||||
|
|
||||||
analog_map_buttons = {{
|
analog_map_buttons = {{
|
||||||
{
|
{
|
||||||
ui->buttonCircleUp,
|
ui->buttonCircleUp,
|
||||||
ui->buttonCircleDown,
|
ui->buttonCircleDown,
|
||||||
ui->buttonCircleLeft,
|
ui->buttonCircleLeft,
|
||||||
ui->buttonCircleRight,
|
ui->buttonCircleRight,
|
||||||
ui->buttonCircleMod,
|
ui->buttonCircleMod,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ui->buttonCStickUp,
|
ui->buttonCStickUp,
|
||||||
ui->buttonCStickDown,
|
ui->buttonCStickDown,
|
||||||
ui->buttonCStickLeft,
|
ui->buttonCStickLeft,
|
||||||
ui->buttonCStickRight,
|
ui->buttonCStickRight,
|
||||||
nullptr,
|
nullptr,
|
||||||
},
|
},
|
||||||
}};
|
}};
|
||||||
|
|
||||||
analog_map_stick = {ui->buttonCircleAnalog, ui->buttonCStickAnalog};
|
analog_map_stick = {ui->buttonCircleAnalog, ui->buttonCStickAnalog};
|
||||||
|
|
||||||
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_id++) {
|
||||||
if (!button_map[button_id])
|
if (!button_map[button_id])
|
||||||
continue;
|
|
||||||
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
|
|
||||||
connect(button_map[button_id], &QPushButton::released, [=]() {
|
|
||||||
handleClick(
|
|
||||||
button_map[button_id],
|
|
||||||
[=](const Common::ParamPackage& params) {
|
|
||||||
buttons_param[button_id] = params;
|
|
||||||
applyConfiguration();
|
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
|
||||||
},
|
|
||||||
InputCommon::Polling::DeviceType::Button);
|
|
||||||
});
|
|
||||||
connect(button_map[button_id], &QPushButton::customContextMenuRequested,
|
|
||||||
[=](const QPoint& menu_location) {
|
|
||||||
QMenu context_menu;
|
|
||||||
context_menu.addAction(tr("Clear"), [&] {
|
|
||||||
buttons_param[button_id].Clear();
|
|
||||||
button_map[button_id]->setText(tr("[not set]"));
|
|
||||||
applyConfiguration();
|
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
|
||||||
});
|
|
||||||
context_menu.addAction(tr("Restore Default"), [&] {
|
|
||||||
buttons_param[button_id] = Common::ParamPackage{
|
|
||||||
InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
|
|
||||||
button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
|
|
||||||
applyConfiguration();
|
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
|
||||||
});
|
|
||||||
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
|
||||||
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
|
||||||
if (!analog_map_buttons[analog_id][sub_button_id])
|
|
||||||
continue;
|
continue;
|
||||||
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
|
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
|
connect(button_map[button_id], &QPushButton::released, [=]() {
|
||||||
handleClick(
|
handleClick(
|
||||||
analog_map_buttons[analog_id][sub_button_id],
|
button_map[button_id],
|
||||||
[=](const Common::ParamPackage& params) {
|
[=](const Common::ParamPackage& params) {
|
||||||
SetAnalogButton(params, analogs_param[analog_id],
|
buttons_param[button_id] = params;
|
||||||
analog_sub_buttons[sub_button_id]);
|
|
||||||
applyConfiguration();
|
applyConfiguration();
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
},
|
},
|
||||||
InputCommon::Polling::DeviceType::Button);
|
InputCommon::Polling::DeviceType::Button);
|
||||||
});
|
});
|
||||||
connect(analog_map_buttons[analog_id][sub_button_id],
|
connect(button_map[button_id], &QPushButton::customContextMenuRequested,
|
||||||
&QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
|
[=](const QPoint& menu_location) {
|
||||||
QMenu context_menu;
|
QMenu context_menu;
|
||||||
context_menu.addAction(tr("Clear"), [&] {
|
context_menu.addAction(tr("Clear"), [&] {
|
||||||
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
|
buttons_param[button_id].Clear();
|
||||||
analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
|
button_map[button_id]->setText(tr("[not set]"));
|
||||||
applyConfiguration();
|
applyConfiguration();
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
});
|
});
|
||||||
context_menu.addAction(tr("Restore Default"), [&] {
|
context_menu.addAction(tr("Restore Default"), [&] {
|
||||||
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
|
buttons_param[button_id] = Common::ParamPackage{
|
||||||
Config::default_analogs[analog_id][sub_button_id])};
|
InputCommon::GenerateKeyboardParam(Config::default_buttons[button_id])};
|
||||||
SetAnalogButton(params, analogs_param[analog_id],
|
button_map[button_id]->setText(ButtonToText(buttons_param[button_id]));
|
||||||
analog_sub_buttons[sub_button_id]);
|
|
||||||
analog_map_buttons[analog_id][sub_button_id]->setText(AnalogToText(
|
|
||||||
analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
|
|
||||||
applyConfiguration();
|
applyConfiguration();
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
});
|
});
|
||||||
context_menu.exec(
|
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
|
||||||
analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(menu_location));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
connect(analog_map_stick[analog_id], &QPushButton::released, [=]() {
|
|
||||||
QMessageBox::information(this, tr("Information"),
|
|
||||||
tr("After pressing OK, first move your joystick horizontally, "
|
|
||||||
"and then vertically."));
|
|
||||||
handleClick(
|
|
||||||
analog_map_stick[analog_id],
|
|
||||||
[=](const Common::ParamPackage& params) {
|
|
||||||
analogs_param[analog_id] = params;
|
|
||||||
applyConfiguration();
|
|
||||||
Settings::SaveProfile(ui->profile->currentIndex());
|
|
||||||
},
|
|
||||||
InputCommon::Polling::DeviceType::Analog);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(ui->buttonMotionTouch, &QPushButton::released, [this] {
|
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
|
||||||
QDialog* motion_touch_dialog = new ConfigureMotionTouch(this);
|
for (int sub_button_id = 0; sub_button_id < ANALOG_SUB_BUTTONS_NUM; sub_button_id++) {
|
||||||
return motion_touch_dialog->exec();
|
if (!analog_map_buttons[analog_id][sub_button_id])
|
||||||
});
|
continue;
|
||||||
connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); });
|
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(
|
||||||
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });
|
Qt::CustomContextMenu);
|
||||||
connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); });
|
connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
|
||||||
connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); });
|
handleClick(
|
||||||
connect(ui->buttonRename, &QPushButton::released, [this] { renameProfile(); });
|
analog_map_buttons[analog_id][sub_button_id],
|
||||||
|
[=](const Common::ParamPackage& params) {
|
||||||
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
SetAnalogButton(params, analogs_param[analog_id],
|
||||||
[this](int i) {
|
analog_sub_buttons[sub_button_id]);
|
||||||
applyConfiguration();
|
applyConfiguration();
|
||||||
Settings::SaveProfile(Settings::values.current_input_profile);
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
Settings::LoadProfile(i);
|
},
|
||||||
loadConfiguration();
|
InputCommon::Polling::DeviceType::Button);
|
||||||
});
|
});
|
||||||
|
connect(analog_map_buttons[analog_id][sub_button_id],
|
||||||
timeout_timer->setSingleShot(true);
|
&QPushButton::customContextMenuRequested, [=](const QPoint& menu_location) {
|
||||||
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
|
QMenu context_menu;
|
||||||
|
context_menu.addAction(tr("Clear"), [&] {
|
||||||
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]);
|
||||||
Common::ParamPackage params;
|
analog_map_buttons[analog_id][sub_button_id]->setText(tr("[not set]"));
|
||||||
for (auto& poller : device_pollers) {
|
applyConfiguration();
|
||||||
params = poller->GetNextInput();
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
if (params.Has("engine")) {
|
});
|
||||||
setPollingResult(params, false);
|
context_menu.addAction(tr("Restore Default"), [&] {
|
||||||
return;
|
Common::ParamPackage params{InputCommon::GenerateKeyboardParam(
|
||||||
|
Config::default_analogs[analog_id][sub_button_id])};
|
||||||
|
SetAnalogButton(params, analogs_param[analog_id],
|
||||||
|
analog_sub_buttons[sub_button_id]);
|
||||||
|
analog_map_buttons[analog_id][sub_button_id]->setText(AnalogToText(
|
||||||
|
analogs_param[analog_id], analog_sub_buttons[sub_button_id]));
|
||||||
|
applyConfiguration();
|
||||||
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
|
});
|
||||||
|
context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
|
||||||
|
menu_location));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
connect(analog_map_stick[analog_id], &QPushButton::released, [=]() {
|
||||||
|
QMessageBox::information(this, tr("Information"),
|
||||||
|
tr("After pressing OK, first move your joystick horizontally, "
|
||||||
|
"and then vertically."));
|
||||||
|
handleClick(
|
||||||
|
analog_map_stick[analog_id],
|
||||||
|
[=](const Common::ParamPackage& params) {
|
||||||
|
analogs_param[analog_id] = params;
|
||||||
|
applyConfiguration();
|
||||||
|
Settings::SaveProfile(ui->profile->currentIndex());
|
||||||
|
},
|
||||||
|
InputCommon::Polling::DeviceType::Analog);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
this->loadConfiguration();
|
connect(ui->buttonMotionTouch, &QPushButton::released, [this] {
|
||||||
|
QDialog* motion_touch_dialog = new ConfigureMotionTouch(this);
|
||||||
|
return motion_touch_dialog->exec();
|
||||||
|
});
|
||||||
|
connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); });
|
||||||
|
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });
|
||||||
|
connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); });
|
||||||
|
connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); });
|
||||||
|
connect(ui->buttonRename, &QPushButton::released, [this] { renameProfile(); });
|
||||||
|
|
||||||
// TODO(wwylele): enable this when we actually emulate it
|
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
ui->buttonHome->setEnabled(false);
|
[this](int i) {
|
||||||
|
applyConfiguration();
|
||||||
|
Settings::SaveProfile(Settings::values.current_input_profile);
|
||||||
|
Settings::LoadProfile(i);
|
||||||
|
loadConfiguration();
|
||||||
|
});
|
||||||
|
|
||||||
|
timeout_timer->setSingleShot(true);
|
||||||
|
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
|
||||||
|
|
||||||
|
connect(poll_timer.get(), &QTimer::timeout, [this]() {
|
||||||
|
Common::ParamPackage params;
|
||||||
|
for (auto& poller : device_pollers) {
|
||||||
|
params = poller->GetNextInput();
|
||||||
|
if (params.Has("engine")) {
|
||||||
|
setPollingResult(params, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this->loadConfiguration();
|
||||||
|
|
||||||
|
// TODO(wwylele): enable this when we actually emulate it
|
||||||
|
ui->buttonHome->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigureInput::~ConfigureInput() = default;
|
ConfigureInput::~ConfigureInput() = default;
|
||||||
|
Loading…
Reference in New Issue
Block a user