|
stmm-input-doc
0.17.0
|
Base class for pointer-like events that hold coordinates. More...

Public Types | |
| enum | XY_GRAB_INPUT_TYPE { XY_HOVER = 0, XY_GRAB = 1, XY_MOVE = 2, XY_UNGRAB = 3, XY_UNGRAB_CANCEL = 4 } |
| The type of grab the event represents. More... | |
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... | |
Public Member Functions | |
| double | getX () const noexcept |
| The main X coordinate. More... | |
| double | getY () const noexcept |
| The main Y coordinate. More... | |
| bool | getIsModified () const noexcept |
| Whether the event coordinates were modified. More... | |
| XY_GRAB_INPUT_TYPE | getXYGrabType () const noexcept |
| Get the grab type of the event. More... | |
| int64_t | getXYGrabId () const noexcept |
| Identifies what is grabbed. More... | |
| virtual void | translateXY (double fDX, double fDY) noexcept |
| Translates the xy coordinates. More... | |
| virtual void | scaleXY (double fSX, double fSY) noexcept |
| Scales the xy coordinates. More... | |
Public Member Functions inherited from stmi::Event | |
| 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... | |
Protected Member Functions | |
| XYEvent (const Class &oClass, int64_t nTimeUsec, int32_t nCapabilityId, const shared_ptr< Accessor > &refAccessor, double fX, double fY) noexcept | |
| Constructor without grab info. More... | |
| XYEvent (const Class &oClass, int64_t nTimeUsec, int32_t nCapabilityId, const shared_ptr< Accessor > &refAccessor, double fX, double fY, XY_GRAB_INPUT_TYPE eXYGrabType, int64_t nGrabId) noexcept | |
| Constructor. More... | |
| void | setX (double fX) noexcept |
| Sets X. More... | |
| void | setY (double fY) noexcept |
| Sets Y. More... | |
| void | setIsModified (bool bIsModified) noexcept |
| Sets the modified flag. More... | |
| void | setXYGrab (XY_GRAB_INPUT_TYPE eXYGrabType, int64_t nGrabId) noexcept |
| Sets the grab type and id. 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 | |
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 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... | |
Base class for pointer-like events that hold coordinates.
This class provides an interface (that is independent from the actual registered event class) for grabbing a pointer (mouse, touch finger, etc.). It also allows to change the coordinates of the event.
If a subclass of XYEvent has, in addition to (fX,fY), more coordinates (fX2,fY2), (fX3,fY3), ... it should keep (fX,fY) as the main coordinates, and override translateXY(double fDX, double fDY) and scaleXY(double fSX, double fSY) to change the additional coordinates and call setIsModified(true) to mark the instance as modified.
Usage example within a callback:
void SomeListener::handleEvent(const std::shared_ptr<stmi::Event>& refEvent) {
...
const stmi::Event::Class& oC = refEvent->getEventClass();
if (oC.isXYEvent()) {
auto pXYEvent = static_cast<stmi::XYEvent*>(refEvent.get());
if (pXYEvent->getX() >= 100) {
pXYEvent->translateXY(-100, 0);
pXYEvent->scaleXY(0.5, 0.5);
...
} The type of grab the event represents.
If the event has no grab representation then XY_HOVER should be used.
|
protectednoexcept |
Constructor without grab info.
Sets grab type to XY_HOVER and the modified flag to false.
| oClass | See Event::Event(const Class&, int64_t, const shared_ptr<Accessor>&) |
| nTimeUsec | See Event::Event(const Class&, int64_t, const shared_ptr<Accessor>&) |
| nCapabilityId | The id of the capability that generated this event. Must be >= 0. |
| refAccessor | See Event::Event(const Class&, int64_t, const shared_ptr<Accessor>&) |
| fX | The X coordinate. |
| fY | The Y coordinate. |
|
protectednoexcept |
Constructor.
The modified flag is set to false.
| oClass | See Event::Event(const Class&, int64_t, const shared_ptr<Accessor>&) |
| nTimeUsec | See Event::Event(const Class&, int64_t, const shared_ptr<Accessor>&) |
| nCapabilityId | The id of the capability that generated this event. Must be >= 0. |
| refAccessor | See Event::Event(const Class&, int64_t, const shared_ptr<Accessor>&) |
| fX | The X coordinate. |
| fY | The Y coordinate. |
| eXYGrabType | The grab type. |
| nGrabId | The grab id. |
|
inlinenoexcept |
Whether the event coordinates were modified.
Tells whether translateXY(double, double) or scaleXY(double, double) were called and modified the event's coordinates.
|
inlinenoexcept |
The main X coordinate.
|
inlinenoexcept |
Identifies what is grabbed.
Ex. For a touch device it could be a finger.
getXYGrabType() == XY_HOVER.
|
inlinenoexcept |
Get the grab type of the event.
If no grab or don't care about it returns XY_HOVER. Example: When a touch is started type is XY_GRAB, when it moves it's XY_MOVE and when it's ended it's XY_UNGRAB.
|
inlinenoexcept |
The main Y coordinate.
|
virtualnoexcept |
Scales the xy coordinates.
Can be overridden if the event subclass contains additional coords. If any of the values is changed sets the modified flag to true.
| fSX | Value multiplied to the Xs of the event. |
| fSY | Value multiplied to the Ys of the event. |
|
inlineprotectednoexcept |
Sets the modified flag.
Listeners receiving the event should only call this function with argument true. Device managers owning and recycling the event call this function with argument false.
| bIsModified | The new flag value. |
|
inlineprotectednoexcept |
Sets X.
The modified flag is not changed by this function.
| fX | The new value. |
|
inlineprotectednoexcept |
Sets the grab type and id.
The modified flag is not changed by this function.
| eXYGrabType | The new grab type. |
| nGrabId | The new id. |
|
inlineprotectednoexcept |
Sets Y.
The modified flag is not changed by this function.
| fY | The new value. |
|
virtualnoexcept |
Translates the xy coordinates.
Can be overridden if the event subclass contains additional coords. If any of the values is changed sets the modified flag to true.
| fDX | Value added to the Xs of the event. |
| fDY | Value added to the Ys of the event. |
1.8.13