Qt/Input: improve DS4 device list

Needed to move Reset out to main_window due to hid closing problems. It's better to have the reset logic outside anyway
This commit is contained in:
Megamouse 2018-12-20 12:52:30 +01:00
parent f617e47152
commit 91d834ce73
4 changed files with 16 additions and 17 deletions

View file

@ -96,7 +96,8 @@ ds4_pad_handler::ds4_pad_handler() : PadHandlerBase(pad_handler::ds4)
b_has_rumble = true;
b_has_deadzones = true;
m_name_string = "Ds4 Pad #";
m_name_string = "DS4 Pad #";
m_max_devices = CELL_PAD_MAX_PORT_NUM;
m_trigger_threshold = trigger_max / 2;
m_thumb_threshold = thumb_max / 2;
@ -261,9 +262,10 @@ std::shared_ptr<ds4_pad_handler::DS4Device> ds4_pad_handler::GetDevice(const std
std::string pad_serial = padId.substr(pos + 9);
std::shared_ptr<DS4Device> device = nullptr;
int i = 0;
for (auto& cur_control : controllers)
{
if (pad_serial == cur_control.first)
if (pad_serial == std::to_string(i++) || pad_serial == cur_control.first)
{
device = cur_control.second;
break;
@ -768,9 +770,9 @@ std::vector<std::string> ds4_pad_handler::ListDevices()
if (!Init())
return ds4_pads_list;
for (auto& pad : controllers)
for (size_t i = 0; i < controllers.size(); ++i)
{
ds4_pads_list.emplace_back(m_name_string + pad.first);
ds4_pads_list.emplace_back(m_name_string + std::to_string(i));
}
return ds4_pads_list;

View file

@ -1252,7 +1252,16 @@ void main_window::CreateConnects()
auto openPadSettings = [this]
{
auto resetPadHandlers = [this]
{
if (Emu.IsStopped())
{
return;
}
Emu.GetCallbacks().reset_pads();
};
pad_settings_dialog dlg(this);
connect(&dlg, &QDialog::accepted, resetPadHandlers);
dlg.exec();
};

View file

@ -791,6 +791,7 @@ void pad_settings_dialog::ChangeInputType()
switch (m_handler->m_type)
{
#ifdef _WIN32
case pad_handler::ds4:
case pad_handler::xinput:
{
const QString name_string = qstr(m_handler->name_string());
@ -960,16 +961,6 @@ void pad_settings_dialog::SaveProfile()
m_handler_cfg.save();
}
void pad_settings_dialog::ResetPadHandler()
{
if (Emu.IsStopped())
{
return;
}
Emu.GetCallbacks().reset_pads();
}
void pad_settings_dialog::SaveExit()
{
SaveProfile();
@ -986,8 +977,6 @@ void pad_settings_dialog::SaveExit()
g_cfg_input.save();
ResetPadHandler();
QDialog::accept();
}

View file

@ -146,7 +146,6 @@ private:
void ReloadButtons();
void ChangeProfile();
void ResetPadHandler();
/** Repaints a stick deadzone preview label */
void RepaintPreviewLabel(QLabel* l, int dz, int w, int x, int y);