Files
Tahgibu/tests/plugins/plug_events.c
T
2026-10-24 11:52:16 -03:00

15 lines
842 B
C

#include "plug_common.h"
TGB_PLUGIN_DECLARE_API_VERSION;
static const tgb_host_api *H;
static int seen_pixels = 0, seen_total = 0;
static void on_event(const tgb_event *ev, void *user) { (void)user; seen_total++; if (ev->type == TGB_EVENT_PIXELS_CHANGED) seen_pixels++; }
static tgb_status cmd_seen(tgb_plugin_handle *self, void *user) { (void)self; (void)user; return seen_pixels > 0 ? TGB_OK : TGB_ERR_PLUGIN; }
TGB_PLUGIN_EXPORT tgb_status tgb_plugin_init(const tgb_host_api *host, tgb_plugin_handle *self, tgb_plugin_info *info) {
H = host;
tgb_status s = host->subscribe(self, on_event, NULL);
if (s < 0) return s;
host->register_command(self, "eventos-vistos", cmd_seen, NULL);
info->name = "Escucha eventos"; info->version = "1.0"; info->required_caps = TGB_CAP_EVENTS | TGB_CAP_READ_DOCUMENT;
return TGB_OK;
}