event_utils

A set of utilities that simplify event handling.

Key monitor

The following two macros set up monitoring of a keyboard key or keys:

MONITOR_KEY(<name>, <key1>, ...);
MONITOR_KEYS(<name>, <key1>, <key2>, ...);

The state of the key(s) will be stored in a bool or int (in the second case) variable called name, which indicates whether, or how many of the specified keys are being pressed.

Variable event

The following macros set up a virtual variable-based event that can be triggered manually. Depending on the type of your handler function (procedure / glsl / none), choose one of the three:

VAR_EVENT_SETUP(<name>, <handler>);
VAR_EVENT_SETUP_GLSL(<name>, <handler>);
VAR_EVENT_SETUP_NO_HANDLER(<name>);

The event can be then triggered using VAR_EVENT_TRIGGER(name). To check whether the event is being triggered in the current frame (e.g. in a shader), you may use VAR_EVENT_IS_TRIGGERED(name).

Timed event

The following macros set up a virtual timed event that can be scheduled to be triggered after a set amount of time. Only one timer is present for each timed event, so repeated scheduling will cancel the previous. Depending on the type of your handler function (procedure / glsl / none), choose one of the three:

TIMED_EVENT_SETUP(<name>, <handler>);
TIMED_EVENT_SETUP_GLSL(<name>, <handler>);
TIMED_EVENT_SETUP_NO_HANDLER(<name>);

The event can be then scheduled using TIMED_EVENT_SCHEDULE(name, delay) (delay in seconds) and cancelled by TIMED_EVENT_CANCEL(name). To check whether the event is being triggered in the current frame (e.g. in a shader), you may use TIMED_EVENT_IS_TRIGGERED(name).