stmm-input-doc  0.17.0
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
stmi::JoystickCapability Class Referenceabstract

The joystick capability of a device. More...

Inheritance diagram for stmi::JoystickCapability:
Inheritance graph
[legend]

Public Types

enum  HAT_VALUE {
  HAT_VALUE_NOT_SET = -1, HAT_CENTER = 0, HAT_UP = 4, HAT_RIGHT = 2,
  HAT_DOWN = 8, HAT_LEFT = 1, HAT_RIGHTUP = (HAT_RIGHT | HAT_UP), HAT_RIGHTDOWN = (HAT_RIGHT | HAT_DOWN),
  HAT_LEFTUP = (HAT_LEFT | HAT_UP), HAT_LEFTDOWN = (HAT_LEFT | HAT_DOWN), HAT_CENTER_CANCEL = 16
}
 The valid states of a hat. More...
 
enum  BUTTON {
  BUTTON_TRIGGER = 0x120, BUTTON_THUMB = 0x121, BUTTON_THUMB2 = 0x122, BUTTON_TOP = 0x123,
  BUTTON_TOP2 = 0x124, BUTTON_PINKIE = 0x125, BUTTON_BASE = 0x126, BUTTON_A = 0x130,
  BUTTON_B = 0x131, BUTTON_C = 0x132, BUTTON_X = 0x133, BUTTON_Y = 0x134,
  BUTTON_Z = 0x135, BUTTON_TL = 0x136, BUTTON_TR = 0x137, BUTTON_TL2 = 0x138,
  BUTTON_TR2 = 0x139, BUTTON_SELECT = 0x13a, BUTTON_START = 0x13b, BUTTON_MODE = 0x13c,
  BUTTON_THUMBL = 0x13d, BUTTON_THUMBR = 0x13e, BUTTON_GEAR_DOWN = 0x150, BUTTON_GEAR_UP = 0x151
}
 The valid buttons. More...
 
enum  AXIS {
  AXIS_X = 0x00, AXIS_Y = 0x01, AXIS_Z = 0x02, AXIS_RX = 0x03,
  AXIS_RY = 0x04, AXIS_RZ = 0x05, AXIS_THROTTLE = 0x06, AXIS_RUDDER = 0x07,
  AXIS_WHEEL = 0x08, AXIS_GAS = 0x09, AXIS_BRAKE = 0x0a, AXIS_PRESSURE = 0x18,
  AXIS_DISTANCE = 0x19, AXIS_TILT_X = 0x1a, AXIS_TILT_Y = 0x1b
}
 The valid axes. More...
 

Public Member Functions

virtual bool hasButton (JoystickCapability::BUTTON eButton) const noexcept=0
 Whether a device implementing this capability has the given button. More...
 
virtual int32_t getTotHats () const noexcept=0
 The number of hats the device implementing this capability has. More...
 
virtual bool hasAxis (JoystickCapability::AXIS eAxis) const noexcept=0
 Whether a device implementing this capability has the given axis. More...
 
virtual bool isButtonPressed (JoystickCapability::BUTTON eButton) const noexcept=0
 Whether the given button is pressed. More...
 
virtual HAT_VALUE getHatValue (int32_t nHat) const noexcept=0
 The given hat value. More...
 
virtual int32_t getAxisValue (JoystickCapability::AXIS eAxis) const noexcept=0
 The given axis` value. More...
 
- Public Member Functions inherited from stmi::Capability
virtual ~Capability () noexcept=default
 
int32_t getId () const noexcept
 The capability id. More...
 
virtual shared_ptr< DevicegetDevice () const noexcept=0
 Returns the device owning this capability, if any. More...
 
const ClassgetCapabilityClass () const noexcept
 Get the registered class of the capability instance. More...
 

Static Public Member Functions

static const std::vector< HAT_VALUE > & getHatValues () noexcept
 Returns the defined HAT_VALUE values as an ordered vector (HAT_VALUE_NOT_SET excluded). More...
 
static bool isValidHatValue (HAT_VALUE eValue) noexcept
 Tells whether a hat value is valid. More...
 
static const std::vector< BUTTON > & getButtons () noexcept
 Returns the defined BUTTON values as an ordered vector. More...
 
static bool isValidButton (BUTTON eButton) noexcept
 Tells whether a button value is valid. More...
 
static const std::vector< AXIS > & getAxes () noexcept
 Returns the defined AXIS values as an ordered vector. More...
 
static bool isValidAxis (AXIS eAxis) noexcept
 Tells whether an axis value is valid. More...
 
static constexpr BUTTON getMinButtonValue () noexcept
 The minimal value of enum JoystickCapability::BUTTON. More...
 
static constexpr BUTTON getMaxButtonValue () noexcept
 The maximal value of enum JoystickCapability::BUTTON. More...
 
static constexpr AXIS getMinAxisValue () noexcept
 The minimal value of enum JoystickCapability::AXIS. More...
 
static constexpr AXIS getMaxAxisValue () noexcept
 The maximal value of enum JoystickCapability::AXIS. More...
 
static const Capability::ClassgetClass () noexcept
 
- Static Public Member Functions inherited from stmi::Capability
static bool isCapabilityClassIdRegistered (const std::string &sCapabilityClassId) noexcept
 Tells whether the given capability class id is registered. More...
 
static Class getCapabilityClassIdClass (const std::string &sCapabilityClassId) noexcept
 Gets the class with given class id. More...
 

Static Public Attributes

static const char *const s_sClassId
 

Protected Member Functions

 JoystickCapability () noexcept
 Constructor. More...
 
- Protected Member Functions inherited from stmi::Capability
 Capability (const Class &oClass) noexcept
 Constructor to be called from subclasses. More...
 

Additional Inherited Members

- Static Protected Member Functions inherited from stmi::Capability
static bool isCapabilityTypeRegistered (const std::type_info &oCapabilityType) noexcept
 Tells whether a capability type was registered. More...
 
static const std::type_info & getCapabilityClassIdType (const std::string &sCapabilityClassId, bool &bRegistered) noexcept
 Gets the type of the registered capability subclass associated with class id. More...
 
static std::string getCapabilityTypeClassId (const std::type_info &oType) noexcept
 Gets the class id of the given type. More...
 

Detailed Description

The joystick capability of a device.

Devices with this capability can generate joystick events.

Member Enumeration Documentation

◆ AXIS

The valid axes.

Enumerator
AXIS_X 
AXIS_Y 
AXIS_Z 
AXIS_RX 
AXIS_RY 
AXIS_RZ 
AXIS_THROTTLE 
AXIS_RUDDER 
AXIS_WHEEL 
AXIS_GAS 
AXIS_BRAKE 
AXIS_PRESSURE 
AXIS_DISTANCE 
AXIS_TILT_X 
AXIS_TILT_Y 

◆ BUTTON

The valid buttons.

Enumerator
BUTTON_TRIGGER 
BUTTON_THUMB 
BUTTON_THUMB2 
BUTTON_TOP 
BUTTON_TOP2 
BUTTON_PINKIE 
BUTTON_BASE 
BUTTON_A 
BUTTON_B 
BUTTON_C 
BUTTON_X 
BUTTON_Y 
BUTTON_Z 
BUTTON_TL 
BUTTON_TR 
BUTTON_TL2 
BUTTON_TR2 
BUTTON_SELECT 
BUTTON_START 
BUTTON_MODE 
BUTTON_THUMBL 
BUTTON_THUMBR 
BUTTON_GEAR_DOWN 
BUTTON_GEAR_UP 

◆ HAT_VALUE

The valid states of a hat.

Enumerator
HAT_VALUE_NOT_SET 
HAT_CENTER 
HAT_UP 
HAT_RIGHT 
HAT_DOWN 
HAT_LEFT 
HAT_RIGHTUP 
HAT_RIGHTDOWN 
HAT_LEFTUP 
HAT_LEFTDOWN 
HAT_CENTER_CANCEL 

Constructor & Destructor Documentation

◆ JoystickCapability()

stmi::JoystickCapability::JoystickCapability ( )
inlineprotectednoexcept

Constructor.

Member Function Documentation

◆ getAxes()

static const std::vector<AXIS>& stmi::JoystickCapability::getAxes ( )
inlinestaticnoexcept

Returns the defined AXIS values as an ordered vector.

The singleton vector is only created when this function is first called.

Returns
The axis values as a std::vector.

◆ getAxisValue()

virtual int32_t stmi::JoystickCapability::getAxisValue ( JoystickCapability::AXIS  eAxis) const
pure virtualnoexcept

The given axis` value.

If the axis is not supported 0 is returned.

Implemented in stmi::testing::FakeJoystickCapability.

◆ getButtons()

static const std::vector<BUTTON>& stmi::JoystickCapability::getButtons ( )
inlinestaticnoexcept

Returns the defined BUTTON values as an ordered vector.

The singleton vector is only created when this function is first called.

Returns
The button values as a std::vector.

◆ getClass()

static const Capability::Class& stmi::JoystickCapability::getClass ( )
inlinestaticnoexcept

◆ getHatValue()

virtual HAT_VALUE stmi::JoystickCapability::getHatValue ( int32_t  nHat) const
pure virtualnoexcept

The given hat value.

Implemented in stmi::testing::FakeJoystickCapability.

◆ getHatValues()

static const std::vector<HAT_VALUE>& stmi::JoystickCapability::getHatValues ( )
inlinestaticnoexcept

Returns the defined HAT_VALUE values as an ordered vector (HAT_VALUE_NOT_SET excluded).

The singleton vector is only created when this function is first called.

Returns
The hat values as a std::vector.

◆ getMaxAxisValue()

static constexpr AXIS stmi::JoystickCapability::getMaxAxisValue ( )
inlinestaticnoexcept

The maximal value of enum JoystickCapability::AXIS.

◆ getMaxButtonValue()

static constexpr BUTTON stmi::JoystickCapability::getMaxButtonValue ( )
inlinestaticnoexcept

The maximal value of enum JoystickCapability::BUTTON.

◆ getMinAxisValue()

static constexpr AXIS stmi::JoystickCapability::getMinAxisValue ( )
inlinestaticnoexcept

The minimal value of enum JoystickCapability::AXIS.

◆ getMinButtonValue()

static constexpr BUTTON stmi::JoystickCapability::getMinButtonValue ( )
inlinestaticnoexcept

The minimal value of enum JoystickCapability::BUTTON.

◆ getTotHats()

virtual int32_t stmi::JoystickCapability::getTotHats ( ) const
pure virtualnoexcept

The number of hats the device implementing this capability has.

Implemented in stmi::testing::FakeJoystickCapability.

◆ hasAxis()

virtual bool stmi::JoystickCapability::hasAxis ( JoystickCapability::AXIS  eAxis) const
pure virtualnoexcept

Whether a device implementing this capability has the given axis.

Implemented in stmi::testing::FakeJoystickCapability.

◆ hasButton()

virtual bool stmi::JoystickCapability::hasButton ( JoystickCapability::BUTTON  eButton) const
pure virtualnoexcept

Whether a device implementing this capability has the given button.

Implemented in stmi::testing::FakeJoystickCapability.

◆ isButtonPressed()

virtual bool stmi::JoystickCapability::isButtonPressed ( JoystickCapability::BUTTON  eButton) const
pure virtualnoexcept

Whether the given button is pressed.

If the button is not supported false is returned.

Implemented in stmi::testing::FakeJoystickCapability.

◆ isValidAxis()

static bool stmi::JoystickCapability::isValidAxis ( AXIS  eAxis)
inlinestaticnoexcept

Tells whether an axis value is valid.

Parameters
eAxisThe axis to check.
Returns
Whether the axis is valid.

◆ isValidButton()

static bool stmi::JoystickCapability::isValidButton ( BUTTON  eButton)
inlinestaticnoexcept

Tells whether a button value is valid.

Parameters
eButtonThe button to check.
Returns
Whether the button is valid.

◆ isValidHatValue()

static bool stmi::JoystickCapability::isValidHatValue ( HAT_VALUE  eValue)
inlinestaticnoexcept

Tells whether a hat value is valid.

HAT_VALUE_NOT_SET is not considered a valid hat by this function!

Parameters
eValueThe hat to check.
Returns
Whether the hat is valid.

Member Data Documentation

◆ s_sClassId

const char* const stmi::JoystickCapability::s_sClassId
static