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)
// And add the necessary button displays for this joystick.
int newButtons = joystick->getJoystickNumButtons();
for (int i = 0; i < newButtons; i++)
if (newButtons)
{
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);
m_ui->buttonBox->show();
for (int i = 0; i < newButtons; i++)
{
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.
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);
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);
m_ui->buttonBox->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