Skip to content

Commit

Permalink
fixup! fix: add HID error message upon failed open
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Feb 5, 2025
1 parent a4daed1 commit 936b77b
Showing 1 changed file with 41 additions and 15 deletions.
56 changes: 41 additions & 15 deletions src/controllers/hid/hidcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LegacyControllerMapping;

namespace {
constexpr size_t kMaxHidErrorMessageSize = 512;
}
} // namespace

HidController::HidController(
mixxx::hid::DeviceInfo&& deviceInfo)
Expand Down Expand Up @@ -72,12 +72,20 @@ int HidController::open() {

// If that fails, try to open device with vendor/product/serial #
if (!pHidDevice) {
qCWarning(m_logBase)
<< "Failed. Trying to open with make, model & serial no:"
<< m_deviceInfo.getVendorId() << m_deviceInfo.getProductId()
<< m_deviceInfo.getSerialNumber() << ":"
<< mixxx::convertWCStringToQString(
hid_error(nullptr), kMaxHidErrorMessageSize);
qCWarning(m_logBase) << QStringLiteral(

Check failure on line 75 in src/controllers/hid/hidcontroller.cpp

View workflow job for this annotation

GitHub Actions / clazy

Use multi-arg instead [-Wclazy-qstring-arg]
"Unable to open specific HID device %1 using its path %2: %3")
.arg(getName())
.arg(m_deviceInfo.pathRaw())
.arg(mixxx::convertWCStringToQString(
hid_error(nullptr),
kMaxHidErrorMessageSize));
qCInfo(m_logBase) << QStringLiteral(
"Trying to open HID device %1 using its vendor, product and "
"serial no (%2, %3 and %4)")
.arg(getName())
.arg(m_deviceInfo.getVendorId())
.arg(m_deviceInfo.getProductId())
.arg(m_deviceInfo.getSerialNumber());
pHidDevice = hid_open(
m_deviceInfo.getVendorId(),
m_deviceInfo.getProductId(),
Expand All @@ -87,21 +95,39 @@ int HidController::open() {
// If it does fail, try without serial number WARNING: This will only open
// one of multiple identical devices
if (!pHidDevice) {
qCWarning(m_logBase)
<< "Unable to open specific HID device" << getName()
<< "Trying now with just make and model."
<< "(This may only open the first of multiple identical "
"devices.): "
<< mixxx::convertWCStringToQString(
hid_error(nullptr), kMaxHidErrorMessageSize);
qCWarning(m_logBase) << QStringLiteral(

Check failure on line 98 in src/controllers/hid/hidcontroller.cpp

View workflow job for this annotation

GitHub Actions / clazy

Use multi-arg instead [-Wclazy-qstring-arg]
"Unable to open specific HID device %1 using its vendor, "
"product and serial no (%2, %3 and %4): %5")
.arg(getName())
.arg(m_deviceInfo.getVendorId())
.arg(m_deviceInfo.getProductId())
.arg(m_deviceInfo.getSerialNumber())
.arg(mixxx::convertWCStringToQString(
hid_error(nullptr),
kMaxHidErrorMessageSize));
qCInfo(m_logBase) << QStringLiteral(
"Trying to open HID device %1 using its vendor and product "
"only (%2 and %3). This may only open the first of multiple "
"identical devices.")
.arg(getName())
.arg(m_deviceInfo.getVendorId())
.arg(m_deviceInfo.getProductId());
pHidDevice = hid_open(m_deviceInfo.getVendorId(),
m_deviceInfo.getProductId(),
nullptr);
}

// If that fails, we give up!
if (!pHidDevice) {
qCWarning(m_logBase) << "Unable to open HID device" << getName();
qCWarning(m_logBase) << QStringLiteral(
"Unable to open specific HID device %1 using its vendor and "
"product only (%2 and %3): %4")
.arg(getName())
.arg(m_deviceInfo.getVendorId())
.arg(m_deviceInfo.getProductId())
.arg(mixxx::convertWCStringToQString(
hid_error(nullptr),
kMaxHidErrorMessageSize));
return -1;
}

Expand Down

0 comments on commit 936b77b

Please sign in to comment.