JoystickAndroid.h 1.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef JOYSTICKANDROID_H
#define JOYSTICKANDROID_H

#include "Joystick.h"
#include "Vehicle.h"
#include "MultiVehicleManager.h"

#include <jni.h>
#include <QtCore/private/qjni_p.h>
#include <QtCore/private/qjnihelpers_p.h>
#include <QtAndroidExtras/QtAndroidExtras>
#include <QtAndroidExtras/QAndroidJniObject>


class JoystickAndroid : public Joystick, public QtAndroidPrivate::GenericMotionEventListener, public QtAndroidPrivate::KeyEventListener
{
public:
Gregory Dymarek's avatar
Gregory Dymarek committed
18
    JoystickAndroid(const QString& name, int axisCount, int buttonCount, int id, MultiVehicleManager* multiVehicleManager);
19 20 21 22 23 24 25 26
    ~JoystickAndroid();

    static QMap<QString, Joystick*> discover(MultiVehicleManager* _multiVehicleManager); 

private:
    bool handleKeyEvent(jobject event);
    bool handleGenericMotionEvent(jobject event);

Gregory Dymarek's avatar
Gregory Dymarek committed
27 28 29
    virtual bool _open();
    virtual void _close();
    virtual bool _update();
30

Gregory Dymarek's avatar
Gregory Dymarek committed
31 32 33
    virtual bool _getButton(int i);
    virtual int _getAxis(int i);
    virtual uint8_t _getHat(int hat,int i);
34 35 36 37 38 39

    int *btnCode;
    int *axisCode;
    bool *btnValue;
    int *axisValue;

Gregory Dymarek's avatar
Gregory Dymarek committed
40
    static void _initStatic();
41 42 43
    static int * _androidBtnList; //list of all possible android buttons
    static int _androidBtnListCount;

Gregory Dymarek's avatar
Gregory Dymarek committed
44
    static int ACTION_DOWN, ACTION_UP;
45 46 47 48 49 50
    static QMutex m_mutex;

    int deviceId;
};

#endif // JOYSTICKANDROID_H