Trigger that responds to device input state changes.
More...
#include <spk_input_trigger.hpp>
|
|
using | Job = std::function<void(const Device *)> |
| | Callback type invoked when the trigger fires.
|
|
using | Predicate = std::function<bool()> |
| | Predicate type tested before firing.
|
|
| | DeviceInputTrigger (DeviceValue p_deviceValue, spk::InputState p_state, spk::Duration p_repeatInterval, const Job &p_jobCallback) |
| | Creates a device trigger with a callback.
|
| | DeviceInputTrigger (DeviceValue p_deviceValue, spk::InputState p_state, spk::Duration p_repeatInterval, const Predicate &p_predicateCallback, const Job &p_jobCallback) |
| | Creates a device trigger with predicate and callback.
|
| void | setDeviceValue (const DeviceValue &p_deviceValue, const spk::InputState &p_state) |
| | Sets the device value and target state.
|
| void | setRepeatInterval (const spk::Duration &p_repeatInterval) |
| | Sets the repeat interval.
|
| void | setCallback (const Job &p_callback) |
| | Sets the callback to invoke when triggered.
|
| void | setPredicate (Predicate p_callback) |
| | Sets the predicate tested before firing.
|
| bool | isInitialized () const override |
| | Reports whether the trigger is initialized.
|
| void | initialize (spk::UpdateEvent &p_event) override |
| | Initializes the trigger by extracting the device from an update event.
|
| const Device * | device () const |
| | Returns the assigned device.
|
| void | setDevice (const Device *p_device) |
| | Manually sets the device.
|
| void | update () override |
| | Updates the trigger and fires callbacks if needed.
|
|
virtual | ~InputTrigger ()=default |
| | Virtual destructor.
|
|
|
static const long long | NoRepeat = -1 |
| | Constant meaning no repeat interval.
|
template<typename Device, typename DeviceValue>
class spk::DeviceInputTrigger< Device, DeviceValue >
Trigger that responds to device input state changes.
- Template Parameters
-
| Device | Device type (e.g. Mouse, Keyboard). |
| DeviceValue | Value type for indexing device state. |
◆ DeviceInputTrigger() [1/2]
template<typename Device, typename DeviceValue>
Creates a device trigger with a callback.
- Parameters
-
| p_deviceValue | Device input identifier. |
| p_state | Target input state. |
| p_repeatInterval | Repeat interval duration. |
| p_jobCallback | Callback invoked on trigger. |
◆ DeviceInputTrigger() [2/2]
template<typename Device, typename DeviceValue>
Creates a device trigger with predicate and callback.
- Parameters
-
| p_deviceValue | Device input identifier. |
| p_state | Target input state. |
| p_repeatInterval | Repeat interval duration. |
| p_predicateCallback | Predicate tested before firing. |
| p_jobCallback | Callback invoked on trigger. |
◆ device()
template<typename Device, typename DeviceValue>
Returns the assigned device.
- Returns
- Device pointer or nullptr.
◆ initialize()
template<typename Device, typename DeviceValue>
Initializes the trigger by extracting the device from an update event.
- Parameters
-
| p_event | Update event providing device references. |
Implements spk::InputTrigger.
◆ isInitialized()
template<typename Device, typename DeviceValue>
Reports whether the trigger is initialized.
- Returns
- True if a device is assigned.
Implements spk::InputTrigger.
◆ setCallback()
template<typename Device, typename DeviceValue>
Sets the callback to invoke when triggered.
- Parameters
-
| p_callback | Callback function. |
◆ setDevice()
template<typename Device, typename DeviceValue>
Manually sets the device.
- Parameters
-
◆ setDeviceValue()
template<typename Device, typename DeviceValue>
| void spk::DeviceInputTrigger< Device, DeviceValue >::setDeviceValue |
( |
const DeviceValue & | p_deviceValue, |
|
|
const spk::InputState & | p_state ) |
|
inline |
Sets the device value and target state.
- Parameters
-
| p_deviceValue | Device input identifier. |
| p_state | Target input state. |
◆ setPredicate()
template<typename Device, typename DeviceValue>
Sets the predicate tested before firing.
- Parameters
-
◆ setRepeatInterval()
template<typename Device, typename DeviceValue>
Sets the repeat interval.
- Parameters
-
| p_repeatInterval | Repeat interval duration. |
◆ update()
template<typename Device, typename DeviceValue>
The documentation for this class was generated from the following file: