Browse Source
* Mavlink/master: Improving coding style Updating mavlink v1.0 ref Removing AndroidJoystick (requires Qt5.6) GPSFact.json: add RTK float & fixed types gps: use a read buffer size of 1024 gps: update drivers submodule gps read callback: avoid sleep, don't wait when data already available gps: use GPS_RTCM_DATA mavlink message for RTCM, use fragmentation if needed gps: update submodule gps: use an inline function for usleep instead of #define GPSProvider: add SIMULATE_RTCM_OUTPUT to enable simulated RTCM output (currently disabled) Sync with official Fixing syntax Android Joystick support Fixing syntax Android Joystick support Fixing syntax Android Joystick supportQGC4.4
15 changed files with 222 additions and 115 deletions
@ -1 +1 @@
@@ -1 +1 @@
|
||||
Subproject commit 60739aaace1723c700f23b22212696dc75169559 |
||||
Subproject commit 5c1ae956552c3887c5fddd303a8f242efa715333 |
@ -0,0 +1,73 @@
@@ -0,0 +1,73 @@
|
||||
#include "JoystickSDL.h" |
||||
|
||||
#include "QGCApplication.h" |
||||
|
||||
#include <QQmlEngine> |
||||
|
||||
JoystickSDL::JoystickSDL(const QString& name, int axisCount, int buttonCount, int index, MultiVehicleManager* multiVehicleManager) |
||||
: Joystick(name,axisCount,buttonCount,multiVehicleManager) |
||||
, _index(index) |
||||
{ |
||||
} |
||||
|
||||
QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicleManager) { |
||||
static QMap<QString, Joystick*> ret; |
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0) { |
||||
qWarning() << "Couldn't initialize SimpleDirectMediaLayer:" << SDL_GetError(); |
||||
return ret; |
||||
} |
||||
|
||||
// Load available joysticks
|
||||
|
||||
qCDebug(JoystickLog) << "Available joysticks"; |
||||
|
||||
for (int i=0; i<SDL_NumJoysticks(); i++) { |
||||
QString name = SDL_JoystickName(i); |
||||
|
||||
if (!ret.contains(name)) { |
||||
int axisCount, buttonCount; |
||||
|
||||
SDL_Joystick* sdlJoystick = SDL_JoystickOpen(i); |
||||
axisCount = SDL_JoystickNumAxes(sdlJoystick); |
||||
buttonCount = SDL_JoystickNumButtons(sdlJoystick); |
||||
SDL_JoystickClose(sdlJoystick); |
||||
|
||||
qCDebug(JoystickLog) << "\t" << name << "axes:" << axisCount << "buttons:" << buttonCount; |
||||
ret[name] = new JoystickSDL(name, axisCount, buttonCount, i, _multiVehicleManager); |
||||
} else { |
||||
qCDebug(JoystickLog) << "\tSkipping duplicate" << name; |
||||
} |
||||
} |
||||
return ret; |
||||
} |
||||
|
||||
bool JoystickSDL::_open(void) { |
||||
sdlJoystick = SDL_JoystickOpen(_index); |
||||
|
||||
if (!sdlJoystick) { |
||||
qCWarning(JoystickLog) << "SDL_JoystickOpen failed:" << SDL_GetError(); |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
void JoystickSDL::_close(void) { |
||||
SDL_JoystickClose(sdlJoystick); |
||||
} |
||||
|
||||
bool JoystickSDL::_update(void) |
||||
{ |
||||
SDL_JoystickUpdate(); |
||||
return true; |
||||
} |
||||
|
||||
bool JoystickSDL::_getButton(int i) { |
||||
return !!SDL_JoystickGetButton(sdlJoystick, i); |
||||
} |
||||
|
||||
int JoystickSDL::_getAxis(int i) { |
||||
return SDL_JoystickGetAxis(sdlJoystick, i); |
||||
} |
||||
|
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
#ifndef JOYSTICKSDL_H |
||||
#define JOYSTICKSDL_H |
||||
|
||||
#include "Joystick.h" |
||||
#include "Vehicle.h" |
||||
#include "MultiVehicleManager.h" |
||||
|
||||
#ifdef Q_OS_MAC |
||||
#include <SDL.h> |
||||
#else |
||||
#include <SDL/SDL.h> |
||||
#endif |
||||
|
||||
|
||||
class JoystickSDL : public Joystick |
||||
{ |
||||
public: |
||||
JoystickSDL(const QString& name, int axisCount, int buttonCount, int index, MultiVehicleManager* multiVehicleManager); |
||||
|
||||
static QMap<QString, Joystick*> discover(MultiVehicleManager* _multiVehicleManager);
|
||||
|
||||
private: |
||||
bool _open() final; |
||||
void _close() final; |
||||
bool _update() final; |
||||
|
||||
bool _getButton(int i) final; |
||||
int _getAxis(int i) final; |
||||
|
||||
SDL_Joystick *sdlJoystick; |
||||
int _index; ///< Index for SDL_JoystickOpen
|
||||
}; |
||||
|
||||
#endif // JOYSTICKSDL_H
|
Loading…
Reference in new issue