Commit 134947f9 authored by Bryant's avatar Bryant

Improved UI when no joysticks are connected. Also removed hotplugging support...

Improved UI when no joysticks are connected. Also removed hotplugging support for joysticks as it wasn't working, though SDL2 should fix that.
parent 8e533fd3
......@@ -313,7 +313,7 @@ void JoystickInput::setEnabled(bool enabled)
void JoystickInput::init()
{
// INITIALIZE SDL Joystick support
// Initialize SDL Joystick support and detect number of joysticks.
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0) {
printf("Couldn't initialize SimpleDirectMediaLayer: %s\n", SDL_GetError());
}
......@@ -321,16 +321,11 @@ void JoystickInput::init()
// Enumerate joysticks and select one
numJoysticks = SDL_NumJoysticks();
// Wait for joysticks if none are connected
while (numJoysticks == 0 && !done)
// If no joysticks are connected, there's nothing we can do, so just keep
// going back to sleep every second unless the program quits.
while (!numJoysticks && !done)
{
QGC::SLEEP::msleep(400);
// INITIALIZE SDL Joystick support
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0)
{
printf("Couldn't initialize SimpleDirectMediaLayer: %s\n", SDL_GetError());
}
numJoysticks = SDL_NumJoysticks();
QGC::SLEEP::sleep(1);
}
if (done)
{
......
......@@ -67,17 +67,18 @@ void JoystickWidget::initUI()
{
m_ui->joystickFrame->setEnabled(true);
}
// Create the initial UI.
createUIForJoystick();
}
// But if there're no joysticks, just disable everything.
// But if there're no joysticks, disable everything and hide empty UI.
else
{
m_ui->enableCheckBox->setEnabled(false);
m_ui->joystickNameComboBox->addItem(tr("No joysticks found. Connect and restart QGC to add one."));
m_ui->joystickNameComboBox->setEnabled(false);
m_ui->joystickFrame->hide();
}
// Add any missing buttons
createUIForJoystick();
}
void JoystickWidget::styleChanged(MainWindow::QGC_MAINWINDOW_STYLE newStyle)
......@@ -225,7 +226,7 @@ void JoystickWidget::createUIForJoystick()
}
else
{
m_ui->buttonBox->hide();
m_ui->axesBox->hide();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment