mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-09-18 07:22:25 +00:00
Qt/Input: enable DS4 controller reconnect without refresh
This commit is contained in:
parent
6e323622a5
commit
bdb5606317
2 changed files with 15 additions and 5 deletions
|
@ -156,7 +156,7 @@ void ds4_pad_handler::GetNextButtonPress(const std::string& padId, const std::fu
|
||||||
if (get_blacklist)
|
if (get_blacklist)
|
||||||
blacklist.clear();
|
blacklist.clear();
|
||||||
|
|
||||||
std::shared_ptr<DS4Device> device = GetDevice(padId);
|
std::shared_ptr<DS4Device> device = GetDevice(padId, true);
|
||||||
if (device == nullptr || device->hidDevice == nullptr)
|
if (device == nullptr || device->hidDevice == nullptr)
|
||||||
return fail_callback();
|
return fail_callback();
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ void ds4_pad_handler::TestVibration(const std::string& padId, u32 largeMotor, u3
|
||||||
SendVibrateData(device);
|
SendVibrateData(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<ds4_pad_handler::DS4Device> ds4_pad_handler::GetDevice(const std::string& padId)
|
std::shared_ptr<ds4_pad_handler::DS4Device> ds4_pad_handler::GetDevice(const std::string& padId, bool try_reconnect)
|
||||||
{
|
{
|
||||||
if (!Init())
|
if (!Init())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -262,12 +262,22 @@ std::shared_ptr<ds4_pad_handler::DS4Device> ds4_pad_handler::GetDevice(const std
|
||||||
std::string pad_serial = padId.substr(pos + 9);
|
std::string pad_serial = padId.substr(pos + 9);
|
||||||
std::shared_ptr<DS4Device> device = nullptr;
|
std::shared_ptr<DS4Device> device = nullptr;
|
||||||
|
|
||||||
int i = 1; // Controllers 1-n in GUI
|
int i = 0; // Controllers 1-n in GUI
|
||||||
for (auto& cur_control : controllers)
|
for (auto& cur_control : controllers)
|
||||||
{
|
{
|
||||||
if (pad_serial == std::to_string(i++) || pad_serial == cur_control.first)
|
if (pad_serial == std::to_string(++i) || pad_serial == cur_control.first)
|
||||||
{
|
{
|
||||||
device = cur_control.second;
|
device = cur_control.second;
|
||||||
|
|
||||||
|
if (try_reconnect && device && !device->hidDevice)
|
||||||
|
{
|
||||||
|
device->hidDevice = hid_open_path(device->path.c_str());
|
||||||
|
if (device->hidDevice)
|
||||||
|
{
|
||||||
|
hid_set_nonblocking(device->hidDevice, 1);
|
||||||
|
LOG_NOTICE(HLE, "DS4 device %d reconnected", i);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ private:
|
||||||
std::shared_ptr<DS4Device> m_dev;
|
std::shared_ptr<DS4Device> m_dev;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DS4Device> GetDevice(const std::string& padId);
|
std::shared_ptr<DS4Device> GetDevice(const std::string& padId, bool try_reconnect = false);
|
||||||
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
|
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
|
||||||
void ProcessDataToPad(const std::shared_ptr<DS4Device>& ds4Device, const std::shared_ptr<Pad>& pad);
|
void ProcessDataToPad(const std::shared_ptr<DS4Device>& ds4Device, const std::shared_ptr<Pad>& pad);
|
||||||
// Copies data into padData if status is NewData, otherwise buffer is untouched
|
// Copies data into padData if status is NewData, otherwise buffer is untouched
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue