class EE::Window::Joystick

Overview

Represents a physical Joystick, and contains all its states. More…

#include <joystick.hpp>

class Joystick {
public:
    // construction

    Joystick(const Uint32& index);
    virtual ~Joystick();

    // methods

    virtual void close();
    virtual void open();
    virtual void update() = 0;
    virtual Uint8 getHat(const Int32& index = 0) = 0;
    virtual Float getAxis(const Int32& axis) = 0;
    virtual Vector2i getBallMotion(const Int32& ball) = 0;
    virtual bool isPlugged() const = 0;
    virtual void reOpen();
    const Int32& getNumHats() const;
    const Int32& getNumButtons() const;
    const Int32& getNumAxes() const;
    const Int32& getNumBalls() const;
    const Uint32& getButtonTrigger() const;
    const Uint32& getButtonUpTrigger() const;
    bool isButtonDown(const Int32& index);
    bool isButtonUp(const Int32& index);
};

Detailed Documentation

Represents a physical Joystick, and contains all its states.

Methods

virtual void close()

Close the joystick

virtual void open()

Open the joystick

virtual void update() = 0

Update the current joystick states ( users don’t need to call this manually )

virtual Uint8 getHat(const Int32& index = 0) = 0

Returns:

The hat index state

See also:

EE_HAT_POS to get info about the possible states You just need to compare the state against what position you need, example if ( myJoy->GetHat() == HAT_LEFT) { … do whatever you need to do }

virtual Float getAxis(const Int32& axis) = 0

Returns:

the axis state

See also:

EE_JOYAXIS to know the possible axis ( usually you will use AXIS_X and AXIS_Y Axis values goes from AXIS_MIN to AXIS_MAX

virtual Vector2i getBallMotion(const Int32& ball) = 0

Returns:

The ball motion position

virtual bool isPlugged() const = 0

Returns:

True if the joystick is plugged in

virtual void reOpen()

ReOpen the joysick ( this is the same of doing Close and the Open )

const Int32& getNumHats() const

Returns:

The number of hats

const Int32& getNumButtons() const

Returns:

The number of buttons

const Int32& getNumAxes() const

Returns:

The number of axes

const Int32& getNumBalls() const

Returns:

The number of balls

const Uint32& getButtonTrigger() const

Returns:

The buttons states flags

const Uint32& getButtonUpTrigger() const

Returns:

The buttons released states flags

bool isButtonDown(const Int32& index)

Returns:

If the button index is down ( pressed )

bool isButtonUp(const Int32& index)

Returns:

If the button index is up ( released )