From 936b77b5ed049c6941a2ad8f4be8bea34fcbbcd5 Mon Sep 17 00:00:00 2001 From: "Antoine C." Date: Wed, 5 Feb 2025 01:45:59 +0000 Subject: [PATCH] fixup! fix: add HID error message upon failed open --- src/controllers/hid/hidcontroller.cpp | 56 ++++++++++++++++++++------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/src/controllers/hid/hidcontroller.cpp b/src/controllers/hid/hidcontroller.cpp index b91d0111e95..398e404f7d3 100644 --- a/src/controllers/hid/hidcontroller.cpp +++ b/src/controllers/hid/hidcontroller.cpp @@ -10,7 +10,7 @@ class LegacyControllerMapping; namespace { constexpr size_t kMaxHidErrorMessageSize = 512; -} +} // namespace HidController::HidController( mixxx::hid::DeviceInfo&& deviceInfo) @@ -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( + "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(), @@ -87,13 +95,23 @@ 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( + "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); @@ -101,7 +119,15 @@ int HidController::open() { // 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; }