Commit 40404552 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 7e1e1e97
...@@ -119,24 +119,40 @@ void JoystickWidget::updateUIForJoystick(int id) ...@@ -119,24 +119,40 @@ void JoystickWidget::updateUIForJoystick(int id)
// And add the necessary button displays for this joystick. // And add the necessary button displays for this joystick.
int newButtons = joystick->getJoystickNumButtons(); int newButtons = joystick->getJoystickNumButtons();
for (int i = 0; i < newButtons; i++) if (newButtons)
{ {
JoystickButton* button = new JoystickButton(i, m_ui->buttonBox); m_ui->buttonBox->show();
// And make sure we insert BEFORE the vertical spacer. for (int i = 0; i < newButtons; i++)
m_ui->buttonLayout->insertWidget(i, button); {
buttons.append(button); JoystickButton* button = new JoystickButton(i, m_ui->buttonBox);
// And make sure we insert BEFORE the vertical spacer.
m_ui->buttonLayout->insertWidget(i, button);
buttons.append(button);
}
}
else
{
m_ui->buttonBox->hide();
} }
// Do the same for the axes supported by this joystick. // 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));
connect(axis, SIGNAL(mappingChanged(int,JoystickInput::JOYSTICK_INPUT_MAPPING)), this->joystick, SLOT(setAxisMapping(int,JoystickInput::JOYSTICK_INPUT_MAPPING)));
connect(axis, SIGNAL(inversionChanged(int,bool)), this->joystick, SLOT(setAxisInversion(int,bool)));
// And make sure we insert BEFORE the vertical spacer.
m_ui->axesLayout->insertWidget(i, axis);
axes.append(axis);
}
}
else
{ {
JoystickAxis* axis = new JoystickAxis(i, m_ui->axesBox); m_ui->buttonBox->hide();
axis->setValue(joystick->getCurrentValueForAxis(i));
connect(axis, SIGNAL(mappingChanged(int,JoystickInput::JOYSTICK_INPUT_MAPPING)), this->joystick, SLOT(setAxisMapping(int,JoystickInput::JOYSTICK_INPUT_MAPPING)));
connect(axis, SIGNAL(inversionChanged(int,bool)), this->joystick, SLOT(setAxisInversion(int,bool)));
// And make sure we insert BEFORE the vertical spacer.
m_ui->axesLayout->insertWidget(i, axis);
axes.append(axis);
} }
} }
......
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