You simply create your own listeners that inherit from IODevices base classes. When any device-related event occur, IODevices will inform your listeners so you can take further steps.
So far, IODevices gives you support for those devices:
- If you return true during processing an event, it will mean "stop propagation" - the event won't be delivered to rest of listeners (with lower priorities).
Using the listeners
First of all, you have to include the IODevices Module and it's Implementation (just like with any other Module).
Then you can use that IOGether to assign the listeners for different devices (like keyboard or mouse) with void add_X_Listener(_X_Listener * listener, bool asHighestPriority) method, where _X_ is the name of the listener. The listeners with higher priorities will get the event faster (and can interrupt processing of it).
When device-related event occur, the assigned listener with highest priority will receive it. For example, when you press a key, KeyListener::characterTyped(char characterUTF8) will be called. If you will return true (which means "stop propagation"), the event won't reach rest of listeners. Otherwise, the event will be passed to next listener and so on.
The sample code of the listener:
Which you can assing that way:
From now on, when you press a key, the accurate listeners will be called to react to that event.