more fixes

This commit is contained in:
Valentin Vanelslande 2018-12-28 21:26:50 -05:00
parent 39140bbff8
commit 860860397b

View file

@ -100,21 +100,19 @@ ConfigureInput::ConfigureInput(QWidget* parent)
ui->setupUi(this);
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(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->buttonDpadDown, ui->buttonDpadLeft, ui->buttonDpadRight, ui->buttonL, ui->buttonR,
ui->buttonStart, ui->buttonSelect, ui->buttonZL, ui->buttonZR, ui->buttonHome,
};
};
analog_map_buttons = {{
analog_map_buttons = {{
{
ui->buttonCircleUp,
ui->buttonCircleDown,
@ -129,11 +127,11 @@ analog_map_buttons = {{
ui->buttonCStickRight,
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])
continue;
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
@ -165,13 +163,14 @@ for (int button_id = 0; button_id < Settings::NativeButton::NumButtons; button_i
});
context_menu.exec(button_map[button_id]->mapToGlobal(menu_location));
});
}
}
for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) {
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;
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(Qt::CustomContextMenu);
analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy(
Qt::CustomContextMenu);
connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
handleClick(
analog_map_buttons[analog_id][sub_button_id],
@ -202,8 +201,8 @@ for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_i
applyConfiguration();
Settings::SaveProfile(ui->profile->currentIndex());
});
context_menu.exec(
analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(menu_location));
context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
menu_location));
});
}
connect(analog_map_stick[analog_id], &QPushButton::released, [=]() {
@ -219,19 +218,19 @@ for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_i
},
InputCommon::Polling::DeviceType::Analog);
});
}
}
connect(ui->buttonMotionTouch, &QPushButton::released, [this] {
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(); });
});
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(); });
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
[this](int i) {
applyConfiguration();
Settings::SaveProfile(Settings::values.current_input_profile);
@ -239,10 +238,10 @@ connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIn
loadConfiguration();
});
timeout_timer->setSingleShot(true);
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
timeout_timer->setSingleShot(true);
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, true); });
connect(poll_timer.get(), &QTimer::timeout, [this]() {
connect(poll_timer.get(), &QTimer::timeout, [this]() {
Common::ParamPackage params;
for (auto& poller : device_pollers) {
params = poller->GetNextInput();
@ -251,12 +250,12 @@ connect(poll_timer.get(), &QTimer::timeout, [this]() {
return;
}
}
});
});
this->loadConfiguration();
this->loadConfiguration();
// TODO(wwylele): enable this when we actually emulate it
ui->buttonHome->setEnabled(false);
// TODO(wwylele): enable this when we actually emulate it
ui->buttonHome->setEnabled(false);
}
ConfigureInput::~ConfigureInput() = default;