mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-26 12:42:41 +01:00
input: log hid_get_feature_report return values
This commit is contained in:
parent
e5793acd78
commit
7df7ac57cc
@ -279,25 +279,24 @@ void ds3_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
|
|||||||
u8 buf[0xFF];
|
u8 buf[0xFF];
|
||||||
buf[0] = 0xF2;
|
buf[0] = 0xF2;
|
||||||
|
|
||||||
bool got_report = hid_get_feature_report(hidDevice, buf, 0xFF) >= 0;
|
int res = hid_get_feature_report(hidDevice, buf, 0xFF);
|
||||||
if (!got_report)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
|
ds3_log.warning("check_add_device: hid_get_feature_report 0xF2 failed! Trying again with 0x0. (result=%d, error=%s)", res, hid_error(hidDevice));
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
got_report = hid_get_feature_report(hidDevice, buf, 0xFF) >= 0;
|
res = hid_get_feature_report(hidDevice, buf, 0xFF);
|
||||||
}
|
}
|
||||||
if (!got_report)
|
if (res < 0)
|
||||||
{
|
{
|
||||||
ds3_log.error("check_add_device: hid_get_feature_report failed! Reason: %s", hid_error(hidDevice));
|
ds3_log.error("check_add_device: hid_get_feature_report 0x0 failed! result=%d, error=%s", res, hid_error(hidDevice));
|
||||||
hid_close(hidDevice);
|
hid_close(hidDevice);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
device->report_id = buf[0];
|
device->report_id = buf[0];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{
|
|
||||||
for (wchar_t ch : wide_serial)
|
for (wchar_t ch : wide_serial)
|
||||||
serial += static_cast<uchar>(ch);
|
serial += static_cast<uchar>(ch);
|
||||||
}
|
|
||||||
|
|
||||||
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
||||||
{
|
{
|
||||||
|
@ -382,9 +382,9 @@ bool ds4_pad_handler::GetCalibrationData(DS4Device* ds4Dev) const
|
|||||||
{
|
{
|
||||||
buf[0] = 0x05;
|
buf[0] = 0x05;
|
||||||
|
|
||||||
if (hid_get_feature_report(ds4Dev->hidDevice, buf.data(), DS4_FEATURE_REPORT_0x05_SIZE) <= 0)
|
if (int res = hid_get_feature_report(ds4Dev->hidDevice, buf.data(), DS4_FEATURE_REPORT_0x05_SIZE); res <= 0)
|
||||||
{
|
{
|
||||||
ds4_log.error("GetCalibrationData: hid_get_feature_report 0x05 failed! Reason: %s", hid_error(ds4Dev->hidDevice));
|
ds4_log.error("GetCalibrationData: hid_get_feature_report 0x05 for bluetooth controller failed! result=%d, error=%s", res, hid_error(ds4Dev->hidDevice));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -408,9 +408,9 @@ bool ds4_pad_handler::GetCalibrationData(DS4Device* ds4Dev) const
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
buf[0] = 0x02;
|
buf[0] = 0x02;
|
||||||
if (hid_get_feature_report(ds4Dev->hidDevice, buf.data(), DS4_FEATURE_REPORT_0x02_SIZE) <= 0)
|
if (int res = hid_get_feature_report(ds4Dev->hidDevice, buf.data(), DS4_FEATURE_REPORT_0x02_SIZE); res <= 0)
|
||||||
{
|
{
|
||||||
ds4_log.error("GetCalibrationData: hid_get_feature_report 0x02 failed! Reason: %s", hid_error(ds4Dev->hidDevice));
|
ds4_log.error("GetCalibrationData: hid_get_feature_report 0x02 for wired controller failed! result=%d, error=%s", res, hid_error(ds4Dev->hidDevice));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -527,12 +527,13 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
|
|||||||
std::string serial;
|
std::string serial;
|
||||||
|
|
||||||
// There isnt a nice 'portable' way with hidapi to detect bt vs wired as the pid/vid's are the same
|
// There isnt a nice 'portable' way with hidapi to detect bt vs wired as the pid/vid's are the same
|
||||||
// Let's try getting 0x81 feature report, which should will return mac address on wired, and should error on bluetooth
|
// Let's try getting 0x81 feature report, which should return the mac address on wired, and should an error on bluetooth
|
||||||
std::array<u8, 64> buf{};
|
std::array<u8, 64> buf{};
|
||||||
buf[0] = 0x81;
|
buf[0] = 0x81;
|
||||||
if (const auto bytes_read = hid_get_feature_report(hidDevice, buf.data(), DS4_FEATURE_REPORT_0x81_SIZE); bytes_read > 0)
|
int res = hid_get_feature_report(hidDevice, buf.data(), DS4_FEATURE_REPORT_0x81_SIZE);
|
||||||
|
if (res > 0)
|
||||||
{
|
{
|
||||||
if (bytes_read != DS4_FEATURE_REPORT_0x81_SIZE)
|
if (res != DS4_FEATURE_REPORT_0x81_SIZE)
|
||||||
{
|
{
|
||||||
// Controller may not be genuine. These controllers do not have feature 0x81 implemented and calibration data is in bluetooth format even in USB mode!
|
// Controller may not be genuine. These controllers do not have feature 0x81 implemented and calibration data is in bluetooth format even in USB mode!
|
||||||
ds4_log.warning("check_add_device: DS4 controller may not be genuine. Workaround enabled.");
|
ds4_log.warning("check_add_device: DS4 controller may not be genuine. Workaround enabled.");
|
||||||
@ -540,9 +541,9 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
|
|||||||
// Read feature report 0x12 instead which is what the console uses.
|
// Read feature report 0x12 instead which is what the console uses.
|
||||||
buf[0] = 0x12;
|
buf[0] = 0x12;
|
||||||
buf[1] = 0;
|
buf[1] = 0;
|
||||||
if (hid_get_feature_report(hidDevice, buf.data(), DS4_FEATURE_REPORT_0x12_SIZE) == -1)
|
if (res = hid_get_feature_report(hidDevice, buf.data(), DS4_FEATURE_REPORT_0x12_SIZE); res < 0)
|
||||||
{
|
{
|
||||||
ds4_log.error("check_add_device: hid_get_feature_report 0x12 failed! Reason: %s", hid_error(hidDevice));
|
ds4_log.error("check_add_device: hid_get_feature_report 0x12 failed! result=%d, error=%s", res, hid_error(hidDevice));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,6 +551,7 @@ void ds4_pad_handler::check_add_device(hid_device* hidDevice, std::string_view p
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
ds4_log.warning("check_add_device: DS4 Bluetooth controller detected. (hid_get_feature_report 0x81 failed, result=%d, error=%s)", res, hid_error(hidDevice));
|
||||||
device->bt_controller = true;
|
device->bt_controller = true;
|
||||||
for (wchar_t ch : wide_serial)
|
for (wchar_t ch : wide_serial)
|
||||||
serial += static_cast<uchar>(ch);
|
serial += static_cast<uchar>(ch);
|
||||||
@ -676,9 +678,9 @@ ds4_pad_handler::DataStatus ds4_pad_handler::get_data(DS4Device* device)
|
|||||||
// tells controller to send 0x11 reports
|
// tells controller to send 0x11 reports
|
||||||
std::array<u8, 64> buf_error{};
|
std::array<u8, 64> buf_error{};
|
||||||
buf_error[0] = 0x2;
|
buf_error[0] = 0x2;
|
||||||
if (hid_get_feature_report(device->hidDevice, buf_error.data(), buf_error.size()) == -1)
|
if (int res = hid_get_feature_report(device->hidDevice, buf_error.data(), buf_error.size()); res < 0)
|
||||||
{
|
{
|
||||||
ds4_log.error("GetRawData: hid_get_feature_report 0x2 failed! Reason: %s", hid_error(device->hidDevice));
|
ds4_log.error("GetRawData: hid_get_feature_report 0x2 failed! result=%d, error=%s", res, hid_error(device->hidDevice));
|
||||||
}
|
}
|
||||||
return DataStatus::NoNewData;
|
return DataStatus::NoNewData;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,14 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_
|
|||||||
// This will give us the bluetooth mac address of the device, regardless if we are on wired or bluetooth.
|
// This will give us the bluetooth mac address of the device, regardless if we are on wired or bluetooth.
|
||||||
// So we can't use this to determine if it is a bluetooth device or not.
|
// So we can't use this to determine if it is a bluetooth device or not.
|
||||||
// Will also enable enhanced feature reports for bluetooth.
|
// Will also enable enhanced feature reports for bluetooth.
|
||||||
if (hid_get_feature_report(hidDevice, buf.data(), 64) == 21)
|
int res = hid_get_feature_report(hidDevice, buf.data(), 64);
|
||||||
|
if (res < 0)
|
||||||
|
{
|
||||||
|
dualsense_log.error("check_add_device: hid_get_feature_report 0x09 failed! result=%d, error=%s", res, hid_error(hidDevice));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res == 21)
|
||||||
{
|
{
|
||||||
serial = fmt::format("%x%x%x%x%x%x", buf[6], buf[5], buf[4], buf[3], buf[2], buf[1]);
|
serial = fmt::format("%x%x%x%x%x%x", buf[6], buf[5], buf[4], buf[3], buf[2], buf[1]);
|
||||||
device->data_mode = DualSenseDevice::DualSenseDataMode::Enhanced;
|
device->data_mode = DualSenseDevice::DualSenseDataMode::Enhanced;
|
||||||
@ -191,6 +198,8 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_
|
|||||||
{
|
{
|
||||||
// We're probably on Bluetooth in this case, but for whatever reason the feature report failed.
|
// We're probably on Bluetooth in this case, but for whatever reason the feature report failed.
|
||||||
// This will give us a less capable fallback.
|
// This will give us a less capable fallback.
|
||||||
|
dualsense_log.warning("check_add_device: hid_get_feature_report returned wrong size! Falling back to simple mode. (result=%d)", res);
|
||||||
|
|
||||||
device->data_mode = DualSenseDevice::DualSenseDataMode::Simple;
|
device->data_mode = DualSenseDevice::DualSenseDataMode::Simple;
|
||||||
for (wchar_t ch : wide_serial)
|
for (wchar_t ch : wide_serial)
|
||||||
serial += static_cast<uchar>(ch);
|
serial += static_cast<uchar>(ch);
|
||||||
@ -210,14 +219,16 @@ void dualsense_pad_handler::check_add_device(hid_device* hidDevice, std::string_
|
|||||||
u32 fw_version{};
|
u32 fw_version{};
|
||||||
|
|
||||||
buf[0] = 0x20;
|
buf[0] = 0x20;
|
||||||
if (hid_get_feature_report(hidDevice, buf.data(), 64) == 65)
|
|
||||||
|
res = hid_get_feature_report(hidDevice, buf.data(), 64);
|
||||||
|
if (res == 65)
|
||||||
{
|
{
|
||||||
hw_version = read_u32(&buf[24]);
|
hw_version = read_u32(&buf[24]);
|
||||||
fw_version = read_u32(&buf[28]);
|
fw_version = read_u32(&buf[28]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dualsense_log.error("Could not retrieve firmware version");
|
dualsense_log.error("check_add_device: hid_get_feature_report 0x20 failed! Could not retrieve firmware version! result=%d, error=%s", res, hid_error(hidDevice));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
if (hid_set_nonblocking(hidDevice, 1) == -1)
|
||||||
@ -413,9 +424,9 @@ bool dualsense_pad_handler::get_calibration_data(DualSenseDevice* dualsense_devi
|
|||||||
{
|
{
|
||||||
buf[0] = 0x05;
|
buf[0] = 0x05;
|
||||||
|
|
||||||
if (hid_get_feature_report(dualsense_device->hidDevice, buf.data(), DUALSENSE_CALIBRATION_REPORT_SIZE) <= 0)
|
if (int res = hid_get_feature_report(dualsense_device->hidDevice, buf.data(), DUALSENSE_CALIBRATION_REPORT_SIZE); res <= 0)
|
||||||
{
|
{
|
||||||
dualsense_log.error("get_calibration_data: hid_get_feature_report 0x05 failed! Reason: %s", hid_error(dualsense_device->hidDevice));
|
dualsense_log.error("get_calibration_data: hid_get_feature_report 0x05 for bluetooth controller failed! result=%d, error=%s", res, hid_error(dualsense_device->hidDevice));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,9 +451,9 @@ bool dualsense_pad_handler::get_calibration_data(DualSenseDevice* dualsense_devi
|
|||||||
{
|
{
|
||||||
buf[0] = 0x05;
|
buf[0] = 0x05;
|
||||||
|
|
||||||
if (hid_get_feature_report(dualsense_device->hidDevice, buf.data(), DUALSENSE_CALIBRATION_REPORT_SIZE) <= 0)
|
if (int res = hid_get_feature_report(dualsense_device->hidDevice, buf.data(), DUALSENSE_CALIBRATION_REPORT_SIZE); res <= 0)
|
||||||
{
|
{
|
||||||
dualsense_log.error("get_calibration_data: hid_get_feature_report 0x05 failed! Reason: %s", hid_error(dualsense_device->hidDevice));
|
dualsense_log.error("get_calibration_data: hid_get_feature_report 0x05 for wired controller failed! result=%d, error=%s", res, hid_error(dualsense_device->hidDevice));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user