GCAdapter: Report libusb open errors to the user

If opening the adapter fails, report the libusb error message in the GUI
instead of “No Adapter Detected”.

The error condition is removed when the adapter is unplugged.
This commit is contained in:
Vincent Duvert
2018-07-17 22:31:18 +02:00
parent 0165e5e703
commit b08e2ec959
4 changed files with 60 additions and 24 deletions

View File

@ -28,9 +28,25 @@ void GCPadWiiUConfigDialog::CreateLayout()
{
setWindowTitle(tr("GameCube Adapter for Wii U at Port %1").arg(m_port + 1));
const bool detected = GCAdapter::IsDetected();
const char* error_message = nullptr;
const bool detected = GCAdapter::IsDetected(&error_message);
QString status_text;
if (detected)
{
status_text = tr("Adapter Detected");
}
else if (error_message)
{
status_text = tr("Error Opening Adapter: %1").arg(QString::fromUtf8(error_message));
}
else
{
status_text = tr("No Adapter Detected");
}
m_layout = new QVBoxLayout();
m_status_label = new QLabel(detected ? tr("Adapter Detected") : tr("No Adapter Detected"));
m_status_label = new QLabel(status_text);
m_rumble = new QCheckBox(tr("Enable Rumble"));
m_simulate_bongos = new QCheckBox(tr("Simulate DK Bongos"));
m_button_box = new QDialogButtonBox(QDialogButtonBox::Ok);