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); 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,
@ -129,11 +127,11 @@ analog_map_buttons = {{
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; continue;
button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); 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)); 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++) { 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]) if (!analog_map_buttons[analog_id][sub_button_id])
continue; 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, [=]() { connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::released, [=]() {
handleClick( handleClick(
analog_map_buttons[analog_id][sub_button_id], 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(); applyConfiguration();
Settings::SaveProfile(ui->profile->currentIndex()); Settings::SaveProfile(ui->profile->currentIndex());
}); });
context_menu.exec( context_menu.exec(analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(
analog_map_buttons[analog_id][sub_button_id]->mapToGlobal(menu_location)); menu_location));
}); });
} }
connect(analog_map_stick[analog_id], &QPushButton::released, [=]() { 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); InputCommon::Polling::DeviceType::Analog);
}); });
} }
connect(ui->buttonMotionTouch, &QPushButton::released, [this] { connect(ui->buttonMotionTouch, &QPushButton::released, [this] {
QDialog* motion_touch_dialog = new ConfigureMotionTouch(this); QDialog* motion_touch_dialog = new ConfigureMotionTouch(this);
return motion_touch_dialog->exec(); return motion_touch_dialog->exec();
}); });
connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); }); connect(ui->buttonClearAll, &QPushButton::released, [this] { ClearAll(); });
connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); }); connect(ui->buttonRestoreDefaults, &QPushButton::released, [this]() { restoreDefaults(); });
connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); }); connect(ui->buttonNew, &QPushButton::released, [this] { newProfile(); });
connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); }); connect(ui->buttonDelete, &QPushButton::released, [this] { deleteProfile(); });
connect(ui->buttonRename, &QPushButton::released, [this] { renameProfile(); }); 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) { [this](int i) {
applyConfiguration(); applyConfiguration();
Settings::SaveProfile(Settings::values.current_input_profile); Settings::SaveProfile(Settings::values.current_input_profile);
@ -239,10 +238,10 @@ connect(ui->profile, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIn
loadConfiguration(); loadConfiguration();
}); });
timeout_timer->setSingleShot(true); timeout_timer->setSingleShot(true);
connect(timeout_timer.get(), &QTimer::timeout, [this]() { setPollingResult({}, 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; Common::ParamPackage params;
for (auto& poller : device_pollers) { for (auto& poller : device_pollers) {
params = poller->GetNextInput(); params = poller->GetNextInput();
@ -251,12 +250,12 @@ connect(poll_timer.get(), &QTimer::timeout, [this]() {
return; return;
} }
} }
}); });
this->loadConfiguration(); this->loadConfiguration();
// TODO(wwylele): enable this when we actually emulate it // TODO(wwylele): enable this when we actually emulate it
ui->buttonHome->setEnabled(false); ui->buttonHome->setEnabled(false);
} }
ConfigureInput::~ConfigureInput() = default; ConfigureInput::~ConfigureInput() = default;