|
stmm-games-doc
0.32.0
|
Class for testing code that interacts with device managers. More...

Public Member Functions | |
| FakeDeviceManager (bool bEnableEventClasses, const std::vector< Event::Class > &aEnDisableEventClasses) noexcept | |
| Constructor. More... | |
| FakeDeviceManager () noexcept | |
| Default constructor. More... | |
| bool | simulateRemoveDevice (int32_t nDeviceId) noexcept |
| Removes a device. More... | |
| bool | simulateChangedDevice (int32_t nDeviceId) noexcept |
| Sends a changed event to the listeners. More... | |
| template<class DEV > | |
| int32_t | simulateNewDevice () noexcept |
| Adds a device with single capability class. More... | |
| int32_t | simulateEvent (const shared_ptr< Event > &refEvent) noexcept |
| Sends an event to the listeners. More... | |
| int32_t | simulateKeyEvent (int32_t nDeviceId, KeyEvent::KEY_INPUT_TYPE eType, HARDWARE_KEY eKey) noexcept |
| Generates a key event and sends it to listeners. More... | |
| int32_t | simulatePointerEvent (int32_t nDeviceId, double fX, double fY, PointerEvent::POINTER_INPUT_TYPE eType, int32_t nButton, bool bAnyButtonPressed, bool bWasAnyButtonPressed) noexcept |
| Generates a pointer event and sends it to listeners. More... | |
| int32_t | simulatePointerScrollEvent (int32_t nDeviceId, PointerScrollEvent::POINTER_SCROLL_DIR eScrollDir, double fX, double fY, bool bAnyButtonPressed) noexcept |
| Generates a pointer scroll event and sends it to listeners. More... | |
| int32_t | simulateTouchEvent (int32_t nDeviceId, TouchEvent::TOUCH_INPUT_TYPE eType, double fX, double fY, int64_t nFingerId) noexcept |
| Generates a touch event and sends it to listeners. More... | |
| int32_t | simulateJoystickButtonEvent (int32_t nDeviceId, JoystickButtonEvent::BUTTON_INPUT_TYPE eType, JoystickCapability::BUTTON eButton) noexcept |
| Generates a joystick button event and sends it to listeners. More... | |
| int32_t | simulateJoystickHatEvent (int32_t nDeviceId, int32_t nHat, JoystickCapability::HAT_VALUE eValue, JoystickCapability::HAT_VALUE ePreviousValue) noexcept |
| Generates a joystick hat event and sends it to listeners. More... | |
| int32_t | simulateJoystickAxisEvent (int32_t nDeviceId, JoystickCapability::AXIS eAxis, int32_t nValue) noexcept |
| Generates a joystick axis event with key simulation and sends it to listeners. More... | |
Public Member Functions inherited from stmi::StdDeviceManager | |
| std::vector< Capability::Class > | getCapabilityClasses () const noexcept override |
| The registered capability classes of the device manager. More... | |
| shared_ptr< Capability > | getCapability (const Capability::Class &oClass) const noexcept override |
| Requests the instance of a capability class. More... | |
| shared_ptr< Capability > | getCapability (int32_t nCapabilityId) const noexcept override |
| Returns the device manager's capability with the given id, or null if not found. More... | |
Public Member Functions inherited from stmi::BasicDeviceManager | |
| shared_ptr< Device > | getDevice (int32_t nDeviceId) const noexcept override |
| Returns the device with the given id, or null if not found. More... | |
| std::vector< int32_t > | getDevicesWithCapabilityClass (const Capability::Class &oCapabilityClass) const noexcept override |
| Returns the ids of the devices that have the given capability class. More... | |
| std::vector< int32_t > | getDevices () const noexcept override |
| Returns the ids of all the device manager's devices. More... | |
| std::vector< Capability::Class > | getCapabilityClasses () const noexcept override |
| The registered capability classes of the device manager. More... | |
| std::vector< Capability::Class > | getDeviceCapabilityClasses () const noexcept override |
| The registered capability classes of the device manager's devices. More... | |
| std::vector< Event::Class > | getEventClasses () const noexcept override |
| The registered event classes the device manager and all its devices can send. More... | |
| bool | isEventClassEnabled (const Event::Class &oEventClass) const noexcept override |
| Tells whether an event class is enabled. More... | |
| void | enableEventClass (const Event::Class &oEventClass) noexcept override |
| Enables an event class. More... | |
| bool | addAccessor (const shared_ptr< Accessor > &) noexcept override |
| Default empty implementation. More... | |
| bool | removeAccessor (const shared_ptr< Accessor > &) noexcept override |
| Default empty implementation. More... | |
| bool | hasAccessor (const shared_ptr< Accessor > &) noexcept override |
| Default empty implementation. More... | |
| bool | addEventListener (const shared_ptr< EventListener > &refEventListener, const shared_ptr< CallIf > &refCallIf) noexcept override |
| Adds an event listener with its callif condition to the device manager. More... | |
| bool | addEventListener (const shared_ptr< EventListener > &refEventListener) noexcept override |
| Adds an event listener to the device manager. More... | |
| bool | removeEventListener (const shared_ptr< EventListener > &refEventListener, bool bFinalize) noexcept override |
| Removes an event listener from the device manager. More... | |
| bool | removeEventListener (const shared_ptr< EventListener > &refEventListener) noexcept override |
| Removes an event listener from the device manager. More... | |
Public Member Functions inherited from stmi::ChildDeviceManager | |
| shared_ptr< ParentDeviceManager > | getParent () const noexcept |
| Gets the parent of this child device manager. More... | |
| shared_ptr< ParentDeviceManager > | getParent () noexcept |
| Gets the parent of this child device manager. More... | |
| shared_ptr< ParentDeviceManager > | getRoot () const noexcept |
| Returns the root device manager. More... | |
| shared_ptr< ParentDeviceManager > | getRoot () noexcept |
| Returns the root device manager. More... | |
| bool | isParent () const noexcept |
| Tells whether this instance is also a ParentDeviceManager. More... | |
| shared_ptr< ParentDeviceManager > | getAsParent () const noexcept |
| If a parent returns this object as a parent. More... | |
| shared_ptr< ParentDeviceManager > | getAsParent () noexcept |
| If a parent returns this object as a parent. More... | |
Public Member Functions inherited from stmi::DeviceManager | |
| virtual | ~DeviceManager () noexcept=default |
| template<typename TCapa > | |
| bool | getCapability (shared_ptr< TCapa > &refCapa) const noexcept |
| Request a registered device manager capability. More... | |
Protected Member Functions | |
| void | finalizeListener (ListenerData &oListenerData) noexcept override |
| Does nothing. More... | |
Protected Member Functions inherited from stmi::StdDeviceManager | |
| StdDeviceManager (const std::vector< Capability::Class > &aDeviceCapabitityClasses, const std::vector< Event::Class > &aEventClasses, bool bEnableEventClasses, const std::vector< Event::Class > &aEnDisableEventClasses) noexcept | |
| Constructor. More... | |
| void | sendDeviceMgmtToListeners (const DeviceMgmtEvent::DEVICE_MGMT_TYPE &eMgmtType, const shared_ptr< Device > &refDevice) noexcept |
| Sends a device mgmt event to the listeners. More... | |
| void | checkWeakPtr () const noexcept |
| shared_ptr< DeviceMgmtCapability > | getDeviceMgmtCapability () noexcept |
Protected Member Functions inherited from stmi::BasicDeviceManager | |
| BasicDeviceManager (const std::vector< Capability::Class > &aCapabitityClasses, const std::vector< Capability::Class > &aDeviceCapabitityClasses, const std::vector< Event::Class > &aEventClasses, bool bEnableEventClasses, const std::vector< Event::Class > &aEnDisableEventClasses) noexcept | |
| Constructor. More... | |
| bool | addDevice (const shared_ptr< Device > &refDevice) noexcept |
| Adding a device. More... | |
| bool | removeDevice (const shared_ptr< Device > &refDevice) noexcept |
| Removing a device. More... | |
| bool | isWithinAListenerCallback () const noexcept |
| Tells whether the caller is within a listener callback. More... | |
| shared_ptr< const std::list< ListenerData *> > | getListeners () noexcept |
| Returns the listeners data pointers. More... | |
| int32_t | getEventClassIndex (const Event::Class &oEventClass) const noexcept |
| Returns the index of the event class in the array passed to the constructor. More... | |
| void | resetExtraDataOfAllListeners () noexcept |
| Calls overloaded ListenerExtraData::reset() for each listener. More... | |
Protected Member Functions inherited from stmi::ChildDeviceManager | |
| ChildDeviceManager () noexcept | |
| Constructor. More... | |
Protected Member Functions inherited from stmi::DeviceManager | |
| DeviceManager () noexcept | |
Additional Inherited Members | |
Static Public Member Functions inherited from stmi::DeviceManager | |
| static int64_t | getNowTimeMicroseconds () noexcept |
| Current time from epoch in microseconds. More... | |
Static Protected Member Functions inherited from stmi::BasicDeviceManager | |
| static uint64_t | getUniqueTimeStamp () noexcept |
| Returns a unique time stamp. More... | |
Class for testing code that interacts with device managers.
It allows to add and remove listeners, create and remove devices (which trigger a DeviceMgmtEvent to be sent to listeners), send events to the listeners but without providing a consistent state of the fake devices. This means that when a device or a listener is removed pressed keys aren't canceled and that the user has to make sure for example that the press of a key isn't followed by another press of the same key but rather by a release or a cancel. This also means that the JoystickCapability's methods shouldn't be called by the to be tested code because they return bogus values.
This class is supposed to be instantiated with std::make_shared().
|
noexcept |
Constructor.
Only the given event classes are enabled.
| bEnableEventClasses | Whether to enable or disable all but aEnDisableEventClasses. |
| aEnDisableEventClasses | The event classes to be enabled or disabled according to bEnableEventClasses. |
|
noexcept |
Default constructor.
All event classes are enabled.
|
overrideprotectedvirtualnoexcept |
Does nothing.
Implements stmi::BasicDeviceManager.
|
noexcept |
Sends a changed event to the listeners.
|
noexcept |
Sends an event to the listeners.
| refEvent | The event. Cannot be null. |
-1 if not enabled.
|
noexcept |
Generates a joystick axis event with key simulation and sends it to listeners.
| nDeviceId | The id of the device with the joystick capability. |
| eAxis | The axis. |
| nValue | Value normalized to [-32767, 32767]. |
-1 if some error.
|
noexcept |
Generates a joystick button event and sends it to listeners.
| nDeviceId | The id of the device with the joystick capability. |
| eType | What happened to the button. |
| eButton | The button. |
-1 if some error.
|
noexcept |
Generates a joystick hat event and sends it to listeners.
Note: the caller has to set the consistent value for the ePreviousValue parameter to reflect the current state of the hat. If ePreviousValue is set to JoystickCapability::HAT_VALUE_NOT_SET key simulation is disabled (Event::getAsKey() returns false).
| nDeviceId | The id of the device with the joystick capability. |
| nHat | The hat that changed its state. Must be >= 0. |
| eValue | The new value for the hat. Can't be JoystickCapability::HAT_VALUE_NOT_SET. |
| ePreviousValue | The previous value for the hat. Can be JoystickCapability::HAT_VALUE_NOT_SET. Can't be HAT_CENTER_CANCEL. |
-1 if some error.
|
noexcept |
Generates a key event and sends it to listeners.
If the device doesn't exists or it has not a key capability -1 is returned.
| nDeviceId | The id of the device with the key capability. |
| eType | The key input type. |
| eKey | The key. |
-1 if some error.
|
inlinenoexcept |
Adds a device with single capability class.
Example: const int32_t nKeyDevId = refFakeDM->simulateNewDevice<FakeKeyDevice>();
|
noexcept |
Generates a pointer event and sends it to listeners.
If the device doesn't exists or it has not a pointer capability -1 is returned. Note: the caller has to set the consistent values for the bAnyButtonPressed and bWasAnyButtonPressed parameters to reflect the current (and preceding) state of the pointer buttons.
| nDeviceId | The id of the device with the pointer capability. |
| fX | The X position of the pointer. |
| fY | The Y position of the pointer. |
| eType | The key input type. |
| nButton | The button involved or -1 if hover. |
| bAnyButtonPressed | Whether any button is pressed (after this event). |
| bWasAnyButtonPressed | Whether any button was pressed before this event. |
-1 if some error.
|
noexcept |
Generates a pointer scroll event and sends it to listeners.
If the device doesn't exists or it has not a pointer capability -1 is returned. Note: the caller has to set the consistent value for the bAnyButtonPressed parameter to reflect the current state of the pointer buttons.
| nDeviceId | The id of the device with the pointer capability. |
| eScrollDir | The direction of the scroll. |
| fX | The X position of the pointer. |
| fY | The Y position of the pointer. |
| bAnyButtonPressed | Whether any button is pressed. |
-1 if some error.
|
noexcept |
Removes a device.
| nDeviceId | The device id as returned by simulateNewXXXDevice(). |
|
noexcept |
Generates a touch event and sends it to listeners.
| nDeviceId | The id of the device with the touch capability. |
| eType | The touch event type. |
| fX | The X position of the touch. |
| fY | The Y position of the touch. |
| nFingerId | The id of the finger performing the touch. |
-1 if some error.
1.8.13