JoystickSDL.h 1.16 KB
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

    static QMap<QString, Joystick*> discover(MultiVehicleManager* _multiVehicleManager); 
Jacob Walser's avatar
Jacob Walser committed
16 17 18 19
    static bool init(void);

    int index(void) { return _index; }
    void setIndex(int index) { _index = index; }
Gregory Dymarek's avatar
Gregory Dymarek committed
20

21 22
    // This can be uncommented to hide the calibration buttons for gamecontrollers in the future
    // bool requiresCalibration(void) final { return !_isGameController; }
Gregory Dymarek's avatar
Gregory Dymarek committed
23 24

private:
25 26
    static void _loadGameControllerMappings();

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

Gus Grubba's avatar
Gus Grubba committed
31 32 33 34 35 36
    bool _getButton (int i) final;
    int  _getAxis   (int i) final;
    bool _getHat    (int hat,int i) final;

    SDL_Joystick*       sdlJoystick;
    SDL_GameController* sdlController;
Gregory Dymarek's avatar
Gregory Dymarek committed
37

38
    bool    _isGameController;
Gregory Dymarek's avatar
Gregory Dymarek committed
39
    int     _index;      ///< Index for SDL_JoystickOpen
40

Gregory Dymarek's avatar
Gregory Dymarek committed
41 42 43
};

#endif // JOYSTICKSDL_H