1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

gcs gamepad: teach GCS that an accel is not a gamepad

The gcscontrolgadget expects all gamepad devices to have
at least 4 axes of control.  The SDL layer (on Linux anyway)
will detect the accelerometer that's built into some laptops
as a gamepad with 3 axes.

This change prevents the accel from being selected and
subsequently flooding the console with errors from
gcscontrolgadget every 10ms.
This commit is contained in:
Stacey Sheldon 2012-09-29 21:47:26 -04:00
parent 4edf78d1cd
commit ed24d93ab1

View File

@ -93,8 +93,18 @@ bool SDLGamepad::setGamepad(qint16 index)
{
buttons = SDL_JoystickNumButtons(gamepad);
axes = SDL_JoystickNumAxes(gamepad);
this->index = index;
return true;
if (axes >= 4) {
this->index = index;
return true;
}
else
{
buttons = -1;
axes = -1;
this->index = -1;
qCritical("Gamepad has less than 4 axes");
}
}
else
{