BLib Reference Manual |
---|
BModule — definition of the Blinkenlights Game API
struct BModule; struct BModuleEvent; enum BModuleEventType; enum BModuleKey; gboolean (*BModulePaintCallback) (BModule *bmodule, guchar *buffer, gpointer data); void b_module_ticker_start (BModule *module, gint timeout); void b_module_ticker_stop (BModule *module); void b_module_request_stop (BModule *module); void b_module_paint (BModule *module);
"start" void user_function (BModule *bmodule, gpointer user_data); "stop" void user_function (BModule *bmodule, gpointer user_data);
struct BModule;
The BModule struct has a couple of fields that may be read directly from a BModule implementation. You must however not change any members directly. Usually a BModule uses the width, height, channels, maxval, aspect and num_players fields.
The buffer variable is the only one a BModule may write to. It does so when it needs to update the frame buffer. It is however recommened to use utility functions like b_module_fill() instead of writing into the buffer. All other fields of BModule are considered private.
struct BModuleEvent { gint device_id; BModuleEventType type; BModuleKey key; };
The BModuleEvent struct defines an event delivered to a BModule. The key field is only valid if the type is B_EVENT_TYPE_KEY. More field may be added when new event types are added.
gint device_id | the event source |
BModuleEventType type | the type of event |
BModuleKey key | the key |
typedef enum { B_EVENT_TYPE_UNKNOWN = 0, B_EVENT_TYPE_KEY, B_EVENT_TYPE_PLAYER_ENTERED, B_EVENT_TYPE_PLAYER_LEFT } BModuleEventType;
This enumeration classifies an event into a number of types.
typedef enum { B_KEY_0, B_KEY_1, B_KEY_2, B_KEY_3, B_KEY_4, B_KEY_5, B_KEY_6, B_KEY_7, B_KEY_8, B_KEY_9, B_KEY_HASH, B_KEY_ASTERISK } BModuleKey;
Enumeration of the possible key values in an event of type B_EVENT_TYPE_KEY.
gboolean (*BModulePaintCallback) (BModule *bmodule, guchar *buffer, gpointer data);
A callback that is registered when a BModule is created using b_module_new(). It is called from b_module_paint() and typically causes a Blinkenlights frame packet to be emitted. You don't need to care about this if you are implementing a BModule.
bmodule : | |
buffer : | |
data : | |
Returns : |
void b_module_ticker_start (BModule *module, gint timeout);
Starts a timeout for module that will call cause its tick() method to be called in timeout milliseconds. The return value of the tick() method is then used to install a new timeout for module. This proceeds until the tick() method returns -1, b_module_ticker_stop() is called or the module is stopped.
You may only call this function for a BModule that is currently running.
module : | a BModule object |
timeout : | the timeout interval in milliseconds |
void b_module_ticker_stop (BModule *module);
Stops the ticker for module. If there is a pending timeout for module, it is removed.
You may only call this function for a BModule that is currently running.
module : | a BModule object |
void b_module_request_stop (BModule *module);
This function causes the module to be stopped. This is for example used when a game module decides that the game is over.
You may only call this function for a BModule that is currently running.
module : | a BModule object |
void user_function (BModule *bmodule, gpointer user_data);
bmodule : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
void user_function (BModule *bmodule, gpointer user_data);
bmodule : | the object which received the signal. |
user_data : | user data set when the signal handler was connected. |
<< Blinkenlights Modules | BModule Utilities >> |