Commit f3ddb9d5 authored by Bryant's avatar Bryant

The UI now updates properly for when a detected joystick is lacking either...

The UI now updates properly for when a detected joystick is lacking either buttons or axes (as in the case of an in-built accelerometer).
parent 4ed616a4
......@@ -119,6 +119,9 @@ void JoystickWidget::updateUIForJoystick(int id)
// And add the necessary button displays for this joystick.
int newButtons = joystick->getJoystickNumButtons();
if (newButtons)
{
m_ui->buttonBox->show();
for (int i = 0; i < newButtons; i++)
{
JoystickButton* button = new JoystickButton(i, m_ui->buttonBox);
......@@ -126,9 +129,17 @@ void JoystickWidget::updateUIForJoystick(int id)
m_ui->buttonLayout->insertWidget(i, button);
buttons.append(button);
}
}
else
{
m_ui->buttonBox->hide();
}
// Do the same for the axes supported by this joystick.
for (int i = 0; i < joystick->getJoystickNumAxes(); i++)
int newAxes = joystick->getJoystickNumAxes();
if (newAxes)
{
for (int i = 0; i < newAxes; i++)
{
JoystickAxis* axis = new JoystickAxis(i, m_ui->axesBox);
axis->setValue(joystick->getCurrentValueForAxis(i));
......@@ -138,6 +149,11 @@ void JoystickWidget::updateUIForJoystick(int id)
m_ui->axesLayout->insertWidget(i, axis);
axes.append(axis);
}
}
else
{
m_ui->buttonBox->hide();
}
}
void JoystickWidget::updateAxisValue(int axis, float value)
......
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