Skip to content
Snippets Groups Projects
JoystickSDL.h 1.16 KiB
Newer Older
  • Learn to ignore specific revisions
  • Gregory Dymarek's avatar
    Gregory Dymarek committed
    #ifndef JOYSTICKSDL_H
    #define JOYSTICKSDL_H
    
    #include "Joystick.h"
    #include "Vehicle.h"
    #include "MultiVehicleManager.h"
    
    
    Gregory Dymarek's avatar
    Gregory Dymarek committed
    
    class JoystickSDL : public Joystick
    {
    public:
    
        JoystickSDL(const QString& name, int axisCount, int buttonCount, int hatCount, int index, bool isGameController, MultiVehicleManager* multiVehicleManager);
    
    Gregory Dymarek's avatar
    Gregory Dymarek committed
    
        static QMap<QString, Joystick*> discover(MultiVehicleManager* _multiVehicleManager); 
    
    Jacob Walser's avatar
    Jacob Walser committed
        static bool init(void);
    
        int index(void) { return _index; }
        void setIndex(int index) { _index = index; }
    
    Gregory Dymarek's avatar
    Gregory Dymarek committed
    
    
        // 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
    
    private:
    
    Gus Grubba's avatar
    Gus Grubba committed
        bool _open      () final;
        void _close     () final;
        bool _update    () final;
    
    Gregory Dymarek's avatar
    Gregory Dymarek committed
    
    
    Gus Grubba's avatar
    Gus Grubba committed
        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
    
    
    Gregory Dymarek's avatar
    Gregory Dymarek committed
        int     _index;      ///< Index for SDL_JoystickOpen
    
    Gregory Dymarek's avatar
    Gregory Dymarek committed
    };
    
    #endif // JOYSTICKSDL_H