|
stmm-input-doc
0.17.0
|
Base event class. More...

Classes | |
| class | Class |
| The representation of a registered event class. More... | |
| class | RegisterClass |
| Template used to register event classes. More... | |
Public Types | |
| enum | AS_KEY_INPUT_TYPE { AS_KEY_PRESS = 1, AS_KEY_RELEASE = 2, AS_KEY_RELEASE_CANCEL = 3 } |
| Key simulation type. More... | |
Public Member Functions | |
| virtual | ~Event () noexcept=default |
| int64_t | getTimeUsec () const noexcept |
| Returns the time this event originated. More... | |
| virtual shared_ptr< Capability > | getCapability () const noexcept=0 |
| Returns the capability that generated this event. 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 Class & | getEventClass () const noexcept |
| Get the registered class of the event instance. More... | |
Static Public Member Functions | |
| 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... | |
Protected Member Functions | |
| 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... | |
Static Protected Member Functions | |
| 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... | |
Base event class.
Usage: if an event listener's callback (stmi::EventListener) is called by the device manager, you get the actual registered subclass of the event by statically casting as follows:
void handleEvent(const shared_ptr<stmi::Event>& refEvent)
{
const stmi::Event::Class& oC = refEvent->getEventClass();
auto& oT = oC.getTypeInfo();
if (oT == typeid(stmi::KeyEvent)) {
handleKeyEvent(static_cast<stmi::KeyEvent*>(refEvent.get()));
} else if (oT == typeid(stmi::PointerEvent)) {
handlePointerEvent(static_cast<stmi::PointerEvent*>(refEvent.get()));
} // and so on
}
with specific registered class implementations:
void handleKeyEvent(stmi::KeyEvent* pEvent) { ... }
void handlePointerEvent(stmi::PointerEvent* pEvent) { ... }
// and so on
|
virtualdefaultnoexcept |
|
protectednoexcept |
Constructor to be called from subclasses.
The registered class has to be the actual class of the instance being constructed or a superclass of it.
| oClass | The registered class of the event. |
| nTimeUsec | Time from epoch in microseconds. |
| nCapabilityId | The id of the capability that generated this event. Must be >= 0. |
| refAccessor | The accessor used to generate the event. Can be null. |
|
inlineprotectednoexcept |
Constructor to be called from subclasses (with empty accessor).
The registered class has to be the actual class of the instance being constructed or a superclass of it.
| oClass | The registered class of the event. |
| nTimeUsec | Time from epoch in microseconds. |
| nCapabilityId | The id of the capability that generated this event. Must be >= 0. |
|
inlinenoexcept |
Returns the accessor that helped generate this event.
|
inlinevirtualnoexcept |
Tells whether the event can simulate hardware keys.
If it can the parameters nKey and eType will contain the first of the simulated keys, bMoreThanOne whether there are more. If it's the case (bMoreThanOne == true) then getAsKeys() should be called, which returns all the simulated keys (the first included). If the function returns false the parameters are left unchanged. The default implementation returns false.
Ex.: a subclass JoystickHatEvent might return, for transition from HAT_CENTER to HAT_RIGHTUP, the first key (nKey=KEY_RIGHT, eType=AS_KEY_PRESS) and bMoreThanOne=true while getAsKeys() returns all keys {(KEY_RIGHT,AS_KEY_PRESS), (KEY_UP,AS_KEY_PRESS)}.
| eKey | The first simulated hardware key (or unchanged if no keys). |
| eType | The type of the first simulated key (or unchanged if no keys). |
| bMoreThanOne | If more than one key is simulated (or unchanged if no keys). |
Reimplemented in stmi::JoystickButtonEvent, stmi::PointerScrollEvent, stmi::JoystickHatEvent, stmi::PointerEvent, and stmi::KeyEvent.
|
inlinevirtualnoexcept |
All the keys this event simulates.
The default implementation calls getAsKey() and returns an empty set if no keys are simulated, otherwise a set containing the first (nKey, eType) pair. Therefore subclass implementations have to override this function only if more than one key is simulated.
Ex.: a subclass PointerScrollEvent may return {(KEY_SCROLLUP,AS_KEY_PRESS), (KEY_SCROLLUP,AS_KEY_RELEASE)}, if mouse's wheel was scrolled up.
Reimplemented in stmi::PointerScrollEvent, and stmi::JoystickHatEvent.
|
pure virtualnoexcept |
Returns the capability that generated this event.
The Event subclass implementation keeps only a weak_ptr on the capability to avoid reference cycles.
Implemented in stmi::JoystickAxisEvent, stmi::JoystickButtonEvent, stmi::PointerScrollEvent, stmi::JoystickHatEvent, stmi::PointerEvent, stmi::DeviceMgmtEvent, stmi::TouchEvent, and stmi::KeyEvent.
|
inlinenoexcept |
Returns the id of the capability that generated this event.
The unique id isn't changed when the capability is removed and getCapability() returns null.
|
inlinenoexcept |
Get the registered class of the event instance.
|
staticnoexcept |
Gets the event class with given class id.
| sEventClassId | The registered class id. |
|
staticprotectednoexcept |
Gets the type of the registered event subclass associated with class id.
| sEventClassId | The type string. |
| bRegistered | Whether the return value is valid. |
false the result is undefined.
|
staticprotectednoexcept |
Gets the class id of the given type.
| oType | The type to be tested. |
|
inlinenoexcept |
Returns the time this event originated.
|
staticnoexcept |
Tells whether the given event class id is registered.
| sEventClassId | The class id. |
|
staticprotectednoexcept |
Tells whether an event type was registered.
| oEventType | The c++ typeid of a class. |
|
inlineprotectednoexcept |
Set the accessor.
| refAccessor | Can be null. |
|
inlineprotectednoexcept |
Set the capability id.
| nCapabilityId | The id of the capability that generated this event. Must be >= 0. |
|
inlineprotectednoexcept |
Set the event time.
| nTimeUsec | Time from epoch in microseconds. |
1.8.13