Skip to content

Commit

Permalink
Qt/Input: enable XInput configs with disconnected devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Megamouse authored and Nekotekina committed Jan 16, 2018
1 parent c5755b3 commit d6c4d8e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
5 changes: 5 additions & 0 deletions rpcs3/Emu/Io/PadHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,11 @@ std::tuple<u16, u16> PadHandlerBase::ConvertToSquirclePoint(u16 inX, u16 inY, in
return std::tuple<u16, u16>(newX, newY);
}

int PadHandlerBase::max_devices()
{
return m_max_devices;
}

bool PadHandlerBase::has_config()
{
return b_has_config;
Expand Down
2 changes: 2 additions & 0 deletions rpcs3/Emu/Io/PadHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ class PadHandlerBase

std::array<bool, MAX_GAMEPADS> last_connection_status{{ false, false, false, false, false, false, false }};

int m_max_devices = 0;
int m_trigger_threshold = 0;
int m_thumb_threshold = 0;

Expand Down Expand Up @@ -435,6 +436,7 @@ class PadHandlerBase

pad_handler m_type = pad_handler::null;

int max_devices();
bool has_config();
bool has_rumble();
bool has_deadzones();
Expand Down
27 changes: 22 additions & 5 deletions rpcs3/rpcs3qt/gamepads_settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,16 +324,33 @@ void gamepads_settings_dialog::ChangeInputType(int player)

// Refill the device combobox with currently available devices
co_deviceID[player]->clear();
for (int i = 0; i < list_devices.size(); i++)

bool force_enable = true; // enable configs even with disconnected devices

switch (cur_pad_handler->m_type)
{
co_deviceID[player]->addItem(qstr(list_devices[i]), i);
#ifdef _MSC_VER
case pad_handler::xinput:
for (int i = 0; i < cur_pad_handler->max_devices(); i++)
{
co_deviceID[player]->addItem(QString("XInput Pad #%1").arg(i), i);
}
break;
#endif
default:
for (int i = 0; i < list_devices.size(); i++)
{
co_deviceID[player]->addItem(qstr(list_devices[i]), i);
}
force_enable = false;
break;
}

// Handle empty device list
bool device_found = list_devices.size() > 0;
co_deviceID[player]->setEnabled(device_found);
co_deviceID[player]->setEnabled(force_enable || device_found);

if (device_found)
if (force_enable || device_found)
{
co_deviceID[player]->setCurrentText(qstr(device));
}
Expand All @@ -342,7 +359,7 @@ void gamepads_settings_dialog::ChangeInputType(int player)
co_deviceID[player]->addItem(tr("No Device Detected"), -1);
}

bool config_enabled = device_found && cur_pad_handler->has_config();
bool config_enabled = force_enable || (device_found && cur_pad_handler->has_config());
co_profile[player]->clear();

// update profile list if possible
Expand Down
4 changes: 3 additions & 1 deletion rpcs3/xinput_pad_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ xinput_pad_handler::xinput_pad_handler() : PadHandlerBase(pad_handler::xinput)
b_has_rumble = true;
b_has_deadzones = true;

m_max_devices = XUSER_MAX_COUNT;

m_trigger_threshold = trigger_max / 2;
m_thumb_threshold = thumb_max / 2;
}
Expand Down Expand Up @@ -451,7 +453,7 @@ std::vector<std::string> xinput_pad_handler::ListDevices()
XINPUT_STATE state;
DWORD result = (*xinputGetState)(i, &state);
if (result == ERROR_SUCCESS)
xinput_pads_list.push_back(fmt::format("Xinput Pad #%d", i));
xinput_pads_list.push_back(fmt::format("XInput Pad #%d", i));
}
return xinput_pads_list;
}
Expand Down

0 comments on commit d6c4d8e

Please sign in to comment.