stmm-games-doc  0.32.0
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
stmi::JoystickAxisEvent Class Reference

Event generated when the state of a joystick's absolute axis is changed. More...

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

Public Member Functions

 JoystickAxisEvent (int64_t nTimeUsec, const shared_ptr< Accessor > &refAccessor, const shared_ptr< JoystickCapability > &refJoystickCapability, JoystickCapability::AXIS eAxis, int32_t nValue) noexcept
 Constructor. More...
 
JoystickCapability::AXIS getAxis () const noexcept
 
int32_t getValue () const noexcept
 Integer value normalized to [-32767, +32767]. More...
 
double getValue0ToP1 () const noexcept
 Floating value normalized to [0, +1.0]. More...
 
double getValueM1ToP1 () const noexcept
 Floating value normalized to [-1.0, +1.0]. More...
 
shared_ptr< JoystickCapabilitygetJoystickCapability () const noexcept
 The joystick capability. More...
 
shared_ptr< CapabilitygetCapability () const noexcept override
 Returns the capability that generated this event. More...
 
- Public Member Functions inherited from stmi::Event
virtual ~Event () noexcept=default
 
int64_t getTimeUsec () const noexcept
 Returns the time this event originated. More...
 
int32_t getCapabilityId () const noexcept
 Returns the id of the capability that generated this event. More...
 
const shared_ptr< Accessor > & getAccessor () const noexcept
 Returns the accessor that helped generate this event. More...
 
virtual bool getAsKey (HARDWARE_KEY &eKey, AS_KEY_INPUT_TYPE &eType, bool &bMoreThanOne) const noexcept
 Tells whether the event can simulate hardware keys. More...
 
virtual std::vector< std::pair< HARDWARE_KEY, AS_KEY_INPUT_TYPE > > getAsKeys () const noexcept
 All the keys this event simulates. More...
 
const ClassgetEventClass () const noexcept
 Get the registered class of the event instance. More...
 

Static Public Member Functions

static const Event::ClassgetClass () noexcept
 
- Static Public Member Functions inherited from stmi::Event
static bool isEventClassIdRegistered (const std::string &sEventClassId) noexcept
 Tells whether the given event class id is registered. More...
 
static Class getEventClassIdClass (const std::string &sEventClassId) noexcept
 Gets the event class with given class id. More...
 

Static Public Attributes

static const char *const s_sClassId
 

Protected Member Functions

void setAxis (JoystickCapability::AXIS eAxis) noexcept
 Sets the axis. More...
 
void setValue (int32_t nValue) noexcept
 Sets the axis value. More...
 
void setJoystickCapability (const shared_ptr< JoystickCapability > &refJoystickCapability) noexcept
 Set the capability. More...
 
- Protected Member Functions inherited from stmi::Event
 Event (const Class &oClass, int64_t nTimeUsec, int32_t nCapabilityId, const shared_ptr< Accessor > &refAccessor) noexcept
 Constructor to be called from subclasses. More...
 
 Event (const Class &oClass, int64_t nTimeUsec, int32_t nCapabilityId) noexcept
 Constructor to be called from subclasses (with empty accessor). More...
 
void setTimeUsec (int64_t nTimeUsec) noexcept
 Set the event time. More...
 
void setCapabilityId (int32_t nCapabilityId) noexcept
 Set the capability id. More...
 
void setAccessor (const shared_ptr< Accessor > &refAccessor) noexcept
 Set the accessor. More...
 

Additional Inherited Members

- Public Types inherited from stmi::Event
enum  AS_KEY_INPUT_TYPE { AS_KEY_PRESS = 1, AS_KEY_RELEASE = 2, AS_KEY_RELEASE_CANCEL = 3 }
 Key simulation type. More...
 
- Static Protected Member Functions inherited from stmi::Event
static bool isEventTypeRegistered (const std::type_info &oEventType) noexcept
 Tells whether an event type was registered. More...
 
static const std::type_info & getEventClassIdType (const std::string &sEventClassId, bool &bRegistered) noexcept
 Gets the type of the registered event subclass associated with class id. More...
 
static std::string getEventTypeClassId (const std::type_info &oType) noexcept
 Gets the class id of the given type. More...
 

Detailed Description

Event generated when the state of a joystick's absolute axis is changed.

Constructor & Destructor Documentation

◆ JoystickAxisEvent()

stmi::JoystickAxisEvent::JoystickAxisEvent ( int64_t  nTimeUsec,
const shared_ptr< Accessor > &  refAccessor,
const shared_ptr< JoystickCapability > &  refJoystickCapability,
JoystickCapability::AXIS  eAxis,
int32_t  nValue 
)
noexcept

Constructor.

Parameters
nTimeUsecTime from epoch in microseconds.
refAccessorThe accessor used to generate the event. Can be null.
refJoystickCapabilityThe capability that generated this event. Cannot be null.
eAxisThe axis.
nValueValue normalized to [-32767, 32767].

Member Function Documentation

◆ getAxis()

JoystickCapability::AXIS stmi::JoystickAxisEvent::getAxis ( ) const
inlinenoexcept

◆ getCapability()

shared_ptr<Capability> stmi::JoystickAxisEvent::getCapability ( ) const
inlineoverridevirtualnoexcept

Returns the capability that generated this event.

The Event subclass implementation keeps only a weak_ptr on the capability to avoid reference cycles.

Returns
The capability or null if the capability was deleted.

Implements stmi::Event.

◆ getClass()

static const Event::Class& stmi::JoystickAxisEvent::getClass ( )
inlinestaticnoexcept

◆ getJoystickCapability()

shared_ptr<JoystickCapability> stmi::JoystickAxisEvent::getJoystickCapability ( ) const
inlinenoexcept

The joystick capability.

Returns
The capability or null if the capability was deleted.

◆ getValue()

int32_t stmi::JoystickAxisEvent::getValue ( ) const
inlinenoexcept

Integer value normalized to [-32767, +32767].

Returns
The value of the axis.

◆ getValue0ToP1()

double stmi::JoystickAxisEvent::getValue0ToP1 ( ) const
inlinenoexcept

Floating value normalized to [0, +1.0].

Returns
The value of the axis.

◆ getValueM1ToP1()

double stmi::JoystickAxisEvent::getValueM1ToP1 ( ) const
inlinenoexcept

Floating value normalized to [-1.0, +1.0].

Returns
The value of the axis.

◆ setAxis()

void stmi::JoystickAxisEvent::setAxis ( JoystickCapability::AXIS  eAxis)
inlineprotectednoexcept

Sets the axis.

Parameters
eAxisThe axis.

◆ setJoystickCapability()

void stmi::JoystickAxisEvent::setJoystickCapability ( const shared_ptr< JoystickCapability > &  refJoystickCapability)
inlineprotectednoexcept

Set the capability.

Parameters
refJoystickCapabilityThe capability that generated this event. Cannot be null.

◆ setValue()

void stmi::JoystickAxisEvent::setValue ( int32_t  nValue)
inlineprotectednoexcept

Sets the axis value.

Parameters
nValueValue normalized to [-32767, 32767].

Member Data Documentation

◆ s_sClassId

const char* const stmi::JoystickAxisEvent::s_sClassId
static