JoystickSDL.h 865 Bytes
Newer Older
Gregory Dymarek's avatar
Gregory Dymarek committed
1 2 3 4 5 6 7
#ifndef JOYSTICKSDL_H
#define JOYSTICKSDL_H

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

8
#include <SDL.h>
Gregory Dymarek's avatar
Gregory Dymarek committed
9 10 11 12

class JoystickSDL : public Joystick
{
public:
13
    JoystickSDL(const QString& name, int axisCount, int buttonCount, int hatCount, int index, bool isGameController, MultiVehicleManager* multiVehicleManager);
Gregory Dymarek's avatar
Gregory Dymarek committed
14 15 16 17

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

private:
18 19
    static void _loadGameControllerMappings();

Gregory Dymarek's avatar
Gregory Dymarek committed
20 21 22
    bool _open() final;
    void _close() final;
    bool _update() final;
Gregory Dymarek's avatar
Gregory Dymarek committed
23

Gregory Dymarek's avatar
Gregory Dymarek committed
24 25
    bool _getButton(int i) final;
    int _getAxis(int i) final;
26
    uint8_t _getHat(int hat,int i) final;
Gregory Dymarek's avatar
Gregory Dymarek committed
27 28

    SDL_Joystick *sdlJoystick;
29 30
    SDL_GameController *sdlController;
    bool    _isGameController;
Gregory Dymarek's avatar
Gregory Dymarek committed
31 32 33 34
    int     _index;      ///< Index for SDL_JoystickOpen
};

#endif // JOYSTICKSDL_H