2016-09-06 00:23:31 +01:00
|
|
|
#include "controllerconfigdialog.h"
|
|
|
|
#include "ui_controllerconfigdialog.h"
|
|
|
|
|
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <QLabel>
|
|
|
|
#include <QFile>
|
2017-05-23 16:08:53 +01:00
|
|
|
#include <QAbstractButton>
|
|
|
|
#include <QPushButton>
|
2020-02-25 18:47:50 +00:00
|
|
|
#include <QInputDialog>
|
2023-10-12 10:13:32 -04:00
|
|
|
#include <QShortcut>
|
|
|
|
#include <QMessageBox>
|
2017-05-23 16:08:53 +01:00
|
|
|
|
2020-02-25 18:47:50 +00:00
|
|
|
#include "AppConfig.h"
|
|
|
|
#include "PreferenceDefs.h"
|
|
|
|
#include "PathUtils.h"
|
2020-09-16 15:09:14 -04:00
|
|
|
#include "inputbindingmodel.h"
|
2017-06-13 04:51:38 +01:00
|
|
|
#include "ControllerInfo.h"
|
|
|
|
#include "inputeventselectiondialog.h"
|
2020-02-25 18:47:50 +00:00
|
|
|
#include "QStringUtils.h"
|
|
|
|
|
|
|
|
#include "filesystem_def.h"
|
|
|
|
#include <iostream>
|
2020-09-16 16:31:45 -04:00
|
|
|
#include <cassert>
|
2016-09-06 00:23:31 +01:00
|
|
|
|
2023-04-20 14:23:10 -04:00
|
|
|
#define ANALOG_SENSITIVITY_MIN (0.75f)
|
|
|
|
#define ANALOG_SENSITIVITY_MAX (1.25f)
|
|
|
|
#define ANALOG_SENSITIVITY_SCALE (1000.f)
|
|
|
|
|
2023-04-20 19:03:13 -04:00
|
|
|
ControllerConfigDialog::ControllerConfigDialog(CInputBindingManager* inputBindingManager, CInputProviderQtKey* qtKeyInputProvider, CInputProviderQtMouse* qtMouseInputProvider, QWidget* parent)
|
2018-04-30 21:01:23 +01:00
|
|
|
: QDialog(parent)
|
|
|
|
, ui(new Ui::ControllerConfigDialog)
|
2018-11-19 13:20:46 -05:00
|
|
|
, m_inputManager(inputBindingManager)
|
|
|
|
, m_qtKeyInputProvider(qtKeyInputProvider)
|
2023-04-20 19:03:13 -04:00
|
|
|
, m_qtMouseInputProvider(qtMouseInputProvider)
|
2016-09-06 00:23:31 +01:00
|
|
|
{
|
2017-06-13 04:51:38 +01:00
|
|
|
ui->setupUi(this);
|
2020-02-25 18:47:50 +00:00
|
|
|
|
2023-10-30 22:16:06 +00:00
|
|
|
m_padUiElements.push_back({ui->pad1TableView, ui->pad1AnalogSensitivitySlider, ui->pad1AnalogSensitivityValueLabel, ui->pad1hapticFeedbackComboBox});
|
|
|
|
m_padUiElements.push_back({ui->pad2TableView, ui->pad2AnalogSensitivitySlider, ui->pad2AnalogSensitivityValueLabel, ui->pad2hapticFeedbackComboBox});
|
2025-02-03 19:05:06 -05:00
|
|
|
m_padUiElements.push_back({ui->pad3TableView, ui->pad3AnalogSensitivitySlider, ui->pad3AnalogSensitivityValueLabel, ui->pad3hapticFeedbackComboBox});
|
|
|
|
m_padUiElements.push_back({ui->pad4TableView, ui->pad4AnalogSensitivitySlider, ui->pad4AnalogSensitivityValueLabel, ui->pad4hapticFeedbackComboBox});
|
2020-02-25 18:47:50 +00:00
|
|
|
|
2023-10-30 22:16:06 +00:00
|
|
|
auto devices = m_inputManager->GetDevices();
|
2023-04-22 09:02:24 -04:00
|
|
|
for(uint32 padIndex = 0; padIndex < m_padUiElements.size(); padIndex++)
|
2020-02-25 18:47:50 +00:00
|
|
|
{
|
2020-09-14 19:43:25 -04:00
|
|
|
PrepareBindingsView(padIndex);
|
2020-02-25 18:47:50 +00:00
|
|
|
|
2023-04-22 09:02:24 -04:00
|
|
|
const auto& uiElements = m_padUiElements[padIndex];
|
|
|
|
|
|
|
|
uiElements.analogSensitivitySlider->setMinimum(ANALOG_SENSITIVITY_MIN * ANALOG_SENSITIVITY_SCALE);
|
|
|
|
uiElements.analogSensitivitySlider->setMaximum(ANALOG_SENSITIVITY_MAX * ANALOG_SENSITIVITY_SCALE);
|
|
|
|
uiElements.analogSensitivitySlider->setValue(m_inputManager->GetAnalogSensitivity(padIndex) * ANALOG_SENSITIVITY_SCALE);
|
|
|
|
UpdateAnalogSensitivityValueLabel(padIndex);
|
|
|
|
|
2023-10-12 10:13:32 -04:00
|
|
|
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::Key_Delete), uiElements.bindingsView);
|
|
|
|
connect(shortcut, SIGNAL(activated()), this, SLOT(bindingsViewDeleteItem()));
|
|
|
|
|
2023-04-22 09:02:24 -04:00
|
|
|
QObject::connect(uiElements.analogSensitivitySlider, &QSlider::sliderMoved, this, [this, padIndex](int value) { analogSensitivityValueChanged(padIndex, value); });
|
|
|
|
QObject::connect(uiElements.analogSensitivitySlider, &QSlider::valueChanged, this, [this, padIndex](int value) { analogSensitivityValueChanged(padIndex, value); });
|
|
|
|
QObject::connect(uiElements.bindingsView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(bindingsViewDoubleClicked(const QModelIndex&)));
|
2023-04-20 14:23:10 -04:00
|
|
|
|
2023-10-30 22:16:06 +00:00
|
|
|
auto motorBinding = inputBindingManager->GetMotorBinding(padIndex);
|
|
|
|
uiElements.hapticFeedbackComboBox->addItem("Disabled");
|
|
|
|
|
|
|
|
for(auto index = 0; index < devices.size(); ++index)
|
|
|
|
{
|
|
|
|
auto devInfo = devices[index];
|
|
|
|
uiElements.hapticFeedbackComboBox->addItem(devInfo.name.c_str());
|
|
|
|
if(!motorBinding)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto targetBinding = BINDINGTARGET(devInfo.providerId, devInfo.deviceId, -1, BINDINGTARGET::KEYTYPE::MOTOR);
|
|
|
|
if(motorBinding->GetBindingTarget() == targetBinding)
|
|
|
|
{
|
|
|
|
uiElements.hapticFeedbackComboBox->setCurrentIndex(index + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-31 00:28:16 +00:00
|
|
|
QObject::connect(uiElements.hapticFeedbackComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
[this, padIndex, inputBindingManager, devices](int index) {
|
|
|
|
if(index == 0)
|
|
|
|
{
|
|
|
|
inputBindingManager->SetMotorBinding(padIndex, {});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto devInfo = devices[index - 1];
|
|
|
|
auto targetBinding = BINDINGTARGET(devInfo.providerId, devInfo.deviceId, -1, BINDINGTARGET::KEYTYPE::MOTOR);
|
|
|
|
inputBindingManager->SetMotorBinding(padIndex, targetBinding);
|
|
|
|
inputBindingManager->GetMotorBinding(padIndex)->ProcessEvent(0, 1);
|
|
|
|
});
|
2023-10-30 22:16:06 +00:00
|
|
|
}
|
2020-09-14 19:43:25 -04:00
|
|
|
PrepareProfiles();
|
2017-06-13 04:53:18 +01:00
|
|
|
}
|
2016-09-06 00:23:31 +01:00
|
|
|
|
2017-06-13 04:53:18 +01:00
|
|
|
ControllerConfigDialog::~ControllerConfigDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2020-09-14 19:43:25 -04:00
|
|
|
void ControllerConfigDialog::PrepareBindingsView(uint32 padIndex)
|
2018-10-23 01:41:02 +01:00
|
|
|
{
|
2020-09-16 15:09:14 -04:00
|
|
|
CInputBindingModel* model = new CInputBindingModel(this, m_inputManager, padIndex);
|
2017-06-13 04:51:38 +01:00
|
|
|
model->setHeaderData(0, Qt::Orientation::Horizontal, QVariant("Button"), Qt::DisplayRole);
|
|
|
|
model->setHeaderData(1, Qt::Orientation::Horizontal, QVariant("Binding Type"), Qt::DisplayRole);
|
|
|
|
model->setHeaderData(2, Qt::Orientation::Horizontal, QVariant("Binding Value"), Qt::DisplayRole);
|
2023-04-22 09:02:24 -04:00
|
|
|
assert(padIndex < m_padUiElements.size());
|
|
|
|
auto bindingsView = m_padUiElements[padIndex].bindingsView;
|
2020-09-14 19:43:25 -04:00
|
|
|
bindingsView->setModel(model);
|
|
|
|
bindingsView->horizontalHeader()->setStretchLastSection(true);
|
|
|
|
bindingsView->resizeColumnsToContents();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerConfigDialog::PrepareProfiles()
|
|
|
|
{
|
|
|
|
std::string profile = CAppConfig::GetInstance().GetPreferenceString(PREF_INPUT_PAD1_PROFILE);
|
|
|
|
|
|
|
|
auto path = CInputConfig::GetProfilePath();
|
|
|
|
if(fs::is_directory(path))
|
|
|
|
{
|
|
|
|
for(auto& entry : fs::directory_iterator(path))
|
|
|
|
{
|
|
|
|
auto profile = Framework::PathUtils::GetNativeStringFromPath(entry.path().stem());
|
|
|
|
ui->comboBox->addItem(profile.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
auto index = ui->comboBox->findText(profile.c_str());
|
|
|
|
if(index >= 0)
|
|
|
|
ui->comboBox->setCurrentIndex(index);
|
2016-09-06 00:23:31 +01:00
|
|
|
}
|
|
|
|
|
2023-04-22 09:02:24 -04:00
|
|
|
void ControllerConfigDialog::UpdateAnalogSensitivityValueLabel(uint32 padIndex)
|
|
|
|
{
|
|
|
|
assert(padIndex < m_padUiElements.size());
|
|
|
|
float sensitivityValue = m_inputManager->GetAnalogSensitivity(padIndex);
|
|
|
|
auto label = m_padUiElements[padIndex].analogSensitivityValueLabel;
|
|
|
|
label->setText(QString("%1").arg(sensitivityValue, 0, 'f', 3));
|
|
|
|
}
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
void ControllerConfigDialog::on_buttonBox_clicked(QAbstractButton* button)
|
2017-06-13 04:51:38 +01:00
|
|
|
{
|
|
|
|
if(button == ui->buttonBox->button(QDialogButtonBox::Ok))
|
|
|
|
{
|
|
|
|
m_inputManager->Save();
|
2020-02-25 18:47:50 +00:00
|
|
|
CAppConfig::GetInstance().Save();
|
2017-06-13 04:51:38 +01:00
|
|
|
}
|
2018-04-30 21:01:23 +01:00
|
|
|
else if(button == ui->buttonBox->button(QDialogButtonBox::Apply))
|
2017-06-13 04:51:38 +01:00
|
|
|
{
|
|
|
|
m_inputManager->Save();
|
2020-02-25 18:47:50 +00:00
|
|
|
CAppConfig::GetInstance().Save();
|
2017-06-13 04:51:38 +01:00
|
|
|
}
|
2018-04-30 21:01:23 +01:00
|
|
|
else if(button == ui->buttonBox->button(QDialogButtonBox::RestoreDefaults))
|
2017-06-13 04:51:38 +01:00
|
|
|
{
|
2020-09-14 19:43:25 -04:00
|
|
|
uint32 padIndex = ui->tabWidget->currentIndex();
|
|
|
|
assert(padIndex < CInputBindingManager::MAX_PADS);
|
|
|
|
AutoConfigureKeyboard(padIndex, m_inputManager);
|
2023-04-22 09:02:24 -04:00
|
|
|
for(const auto& uiElements : m_padUiElements)
|
2017-06-13 04:51:38 +01:00
|
|
|
{
|
2023-04-22 09:02:24 -04:00
|
|
|
static_cast<CInputBindingModel*>(uiElements.bindingsView->model())->Refresh();
|
2017-06-13 04:51:38 +01:00
|
|
|
}
|
|
|
|
}
|
2018-04-30 21:01:23 +01:00
|
|
|
else if(button == ui->buttonBox->button(QDialogButtonBox::Cancel))
|
2017-06-13 04:53:18 +01:00
|
|
|
{
|
2020-02-25 18:47:50 +00:00
|
|
|
m_inputManager->Reload();
|
2017-06-13 04:53:18 +01:00
|
|
|
}
|
2016-09-06 00:23:31 +01:00
|
|
|
}
|
|
|
|
|
2020-09-14 19:43:25 -04:00
|
|
|
void ControllerConfigDialog::bindingsViewDoubleClicked(const QModelIndex& index)
|
2017-05-23 16:08:53 +01:00
|
|
|
{
|
2020-09-21 16:13:22 -04:00
|
|
|
uint32 padIndex = ui->tabWidget->currentIndex();
|
|
|
|
assert(padIndex < CInputBindingManager::MAX_PADS);
|
2020-09-14 19:43:25 -04:00
|
|
|
OpenBindConfigDialog(padIndex, index.row());
|
2017-05-23 16:08:53 +01:00
|
|
|
}
|
|
|
|
|
2023-10-12 10:13:32 -04:00
|
|
|
void ControllerConfigDialog::bindingsViewDeleteItem()
|
|
|
|
{
|
|
|
|
uint32 padIndex = ui->tabWidget->currentIndex();
|
|
|
|
assert(padIndex < CInputBindingManager::MAX_PADS);
|
|
|
|
QItemSelectionModel* selModel = m_padUiElements[padIndex].bindingsView->selectionModel();
|
|
|
|
auto selRows = selModel->selectedRows();
|
|
|
|
if(selRows.empty())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto message = QString("Clear %1 binding(s)?").arg(selRows.size());
|
|
|
|
auto result = QMessageBox::question(this, tr("Clear bindings"), message, QMessageBox::Ok, QMessageBox::Cancel);
|
|
|
|
if(result == QMessageBox::Ok)
|
|
|
|
{
|
|
|
|
for(const auto& selRow : selRows)
|
|
|
|
{
|
|
|
|
m_inputManager->ResetBinding(padIndex, static_cast<PS2::CControllerInfo::BUTTON>(selRow.row()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-22 09:02:24 -04:00
|
|
|
void ControllerConfigDialog::analogSensitivityValueChanged(uint32 padIndex, int value)
|
2023-04-20 14:23:10 -04:00
|
|
|
{
|
|
|
|
float sensitivityValue = static_cast<float>(value) / ANALOG_SENSITIVITY_SCALE;
|
2023-04-22 09:02:24 -04:00
|
|
|
assert(padIndex < CInputBindingManager::MAX_PADS);
|
|
|
|
m_inputManager->SetAnalogSensitivity(padIndex, sensitivityValue);
|
|
|
|
UpdateAnalogSensitivityValueLabel(padIndex);
|
2023-04-20 14:23:10 -04:00
|
|
|
}
|
|
|
|
|
2017-06-13 04:51:38 +01:00
|
|
|
void ControllerConfigDialog::on_ConfigAllButton_clicked()
|
2016-09-06 00:23:31 +01:00
|
|
|
{
|
2020-09-21 16:13:22 -04:00
|
|
|
uint32 padIndex = ui->tabWidget->currentIndex();
|
|
|
|
assert(padIndex < CInputBindingManager::MAX_PADS);
|
2020-09-14 19:43:25 -04:00
|
|
|
for(uint32 buttonIndex = 0; buttonIndex < PS2::CControllerInfo::MAX_BUTTONS; ++buttonIndex)
|
2017-06-13 04:51:38 +01:00
|
|
|
{
|
2020-09-14 19:43:25 -04:00
|
|
|
if(!OpenBindConfigDialog(padIndex, buttonIndex))
|
2017-06-13 04:51:38 +01:00
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-09-06 00:23:31 +01:00
|
|
|
}
|
2018-01-10 20:31:37 +00:00
|
|
|
|
2020-09-14 19:43:25 -04:00
|
|
|
void ControllerConfigDialog::AutoConfigureKeyboard(uint32 padIndex, CInputBindingManager* bindingManager)
|
2018-11-19 19:11:39 -05:00
|
|
|
{
|
2020-09-14 19:43:25 -04:00
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::START, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Return));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::SELECT, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Backspace));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::DPAD_LEFT, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Left));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::DPAD_RIGHT, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Right));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::DPAD_UP, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Up));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::DPAD_DOWN, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Down));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::SQUARE, CInputProviderQtKey::MakeBindingTarget(Qt::Key_A));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::CROSS, CInputProviderQtKey::MakeBindingTarget(Qt::Key_Z));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::TRIANGLE, CInputProviderQtKey::MakeBindingTarget(Qt::Key_S));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::CIRCLE, CInputProviderQtKey::MakeBindingTarget(Qt::Key_X));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::L1, CInputProviderQtKey::MakeBindingTarget(Qt::Key_1));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::L2, CInputProviderQtKey::MakeBindingTarget(Qt::Key_2));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::L3, CInputProviderQtKey::MakeBindingTarget(Qt::Key_3));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::R1, CInputProviderQtKey::MakeBindingTarget(Qt::Key_8));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::R2, CInputProviderQtKey::MakeBindingTarget(Qt::Key_9));
|
|
|
|
bindingManager->SetSimpleBinding(padIndex, PS2::CControllerInfo::R3, CInputProviderQtKey::MakeBindingTarget(Qt::Key_0));
|
|
|
|
|
|
|
|
bindingManager->SetSimulatedAxisBinding(padIndex, PS2::CControllerInfo::ANALOG_LEFT_X,
|
2018-11-28 22:32:27 -05:00
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_F),
|
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_H));
|
2020-09-14 19:43:25 -04:00
|
|
|
bindingManager->SetSimulatedAxisBinding(padIndex, PS2::CControllerInfo::ANALOG_LEFT_Y,
|
2018-11-28 22:32:27 -05:00
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_T),
|
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_G));
|
|
|
|
|
2020-09-14 19:43:25 -04:00
|
|
|
bindingManager->SetSimulatedAxisBinding(padIndex, PS2::CControllerInfo::ANALOG_RIGHT_X,
|
2018-11-28 22:32:27 -05:00
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_J),
|
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_L));
|
2020-09-14 19:43:25 -04:00
|
|
|
bindingManager->SetSimulatedAxisBinding(padIndex, PS2::CControllerInfo::ANALOG_RIGHT_Y,
|
2018-11-28 22:32:27 -05:00
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_I),
|
|
|
|
CInputProviderQtKey::MakeBindingTarget(Qt::Key_K));
|
2018-11-19 19:11:39 -05:00
|
|
|
}
|
|
|
|
|
2020-09-14 19:43:25 -04:00
|
|
|
int ControllerConfigDialog::OpenBindConfigDialog(uint32 padIndex, uint32 buttonIndex)
|
2018-01-10 20:31:37 +00:00
|
|
|
{
|
2020-09-14 19:43:25 -04:00
|
|
|
auto button = static_cast<PS2::CControllerInfo::BUTTON>(buttonIndex);
|
|
|
|
std::string buttonName(PS2::CControllerInfo::m_buttonName[button]);
|
|
|
|
std::transform(buttonName.begin(), buttonName.end(), buttonName.begin(), ::toupper);
|
2018-01-10 20:31:37 +00:00
|
|
|
|
2018-11-19 13:20:46 -05:00
|
|
|
InputEventSelectionDialog IESD(this);
|
2023-04-20 19:03:13 -04:00
|
|
|
IESD.Setup(buttonName.c_str(), m_inputManager, m_qtKeyInputProvider, m_qtMouseInputProvider, padIndex, button);
|
2018-01-10 20:31:37 +00:00
|
|
|
auto res = IESD.exec();
|
|
|
|
return res;
|
|
|
|
}
|
2020-02-25 18:47:50 +00:00
|
|
|
|
|
|
|
void ControllerConfigDialog::on_comboBox_currentIndexChanged(int index)
|
|
|
|
{
|
2019-11-06 01:00:53 +00:00
|
|
|
ui->delProfileButton->setEnabled(ui->comboBox->count() > 1);
|
2020-02-25 18:47:50 +00:00
|
|
|
|
|
|
|
auto profile = ui->comboBox->itemText(index).toStdString();
|
2020-02-25 18:44:54 +00:00
|
|
|
m_inputManager->Save();
|
2020-02-25 18:47:50 +00:00
|
|
|
m_inputManager->Load(profile.c_str());
|
|
|
|
CAppConfig::GetInstance().SetPreferenceString(PREF_INPUT_PAD1_PROFILE, profile.c_str());
|
|
|
|
|
2023-04-22 09:02:24 -04:00
|
|
|
for(int padIndex = 0; padIndex < m_padUiElements.size(); padIndex++)
|
2020-09-14 19:43:25 -04:00
|
|
|
{
|
2023-04-22 09:02:24 -04:00
|
|
|
const auto& uiElements = m_padUiElements[padIndex];
|
|
|
|
static_cast<CInputBindingModel*>(uiElements.bindingsView->model())->Refresh();
|
|
|
|
uiElements.analogSensitivitySlider->setValue(m_inputManager->GetAnalogSensitivity(padIndex) * ANALOG_SENSITIVITY_SCALE);
|
|
|
|
UpdateAnalogSensitivityValueLabel(padIndex);
|
2020-09-14 19:43:25 -04:00
|
|
|
}
|
2020-02-25 18:47:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerConfigDialog::on_addProfileButton_clicked()
|
|
|
|
{
|
|
|
|
std::string profile_name;
|
|
|
|
while(profile_name.empty())
|
|
|
|
{
|
|
|
|
bool ok_pressed = false;
|
|
|
|
QString name = QInputDialog::getText(this, tr("Enter Profile Name"), tr("Only letters, numbers and dash characters allowed.\nProfile name:"),
|
|
|
|
QLineEdit::Normal, "", &ok_pressed);
|
|
|
|
|
|
|
|
if(!ok_pressed)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(!name.isEmpty() && CInputConfig::IsValidProfileName(name.toStdString()))
|
|
|
|
profile_name = name.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
auto profile_path = CInputConfig::GetProfile(profile_name);
|
|
|
|
if(!fs::exists(profile_path))
|
|
|
|
{
|
|
|
|
ui->comboBox->addItem(profile_name.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
auto index = ui->comboBox->findText(profile_name.c_str());
|
|
|
|
if(index >= 0)
|
|
|
|
ui->comboBox->setCurrentIndex(index);
|
2020-09-21 17:34:08 -04:00
|
|
|
|
|
|
|
//Set some defaults
|
|
|
|
AutoConfigureKeyboard(0, m_inputManager);
|
2020-02-25 18:47:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ControllerConfigDialog::on_delProfileButton_clicked()
|
|
|
|
{
|
|
|
|
auto name = ui->comboBox->currentText();
|
|
|
|
std::string profile_name = name.toStdString();
|
|
|
|
{
|
|
|
|
auto profile_path = CInputConfig::GetProfile(profile_name);
|
|
|
|
if(fs::exists(profile_path))
|
|
|
|
{
|
|
|
|
int index = ui->comboBox->currentIndex();
|
|
|
|
ui->comboBox->removeItem(index);
|
2019-11-06 00:50:39 +00:00
|
|
|
fs::remove(profile_path);
|
2020-02-25 18:47:50 +00:00
|
|
|
}
|
|
|
|
}
|
2020-09-14 19:43:25 -04:00
|
|
|
}
|