diff --git a/graph.h b/graph.h index 79815e3..9fafe89 100644 --- a/graph.h +++ b/graph.h @@ -33,6 +33,7 @@ struct graph_node_specification { void (*destroy)(GraphNodeSpecification * self, GraphNode * target); void (*register_io)(GraphNodeSpecification * self, GraphNode * target, ProcessingState * state); char *name; + char *documentation; }; void graph_channel_init(GraphChannel * ch, GraphNode * start, size_t start_idx, GraphNode * end, size_t end_idx); diff --git a/main.c b/main.c index d70aecc..b32c8dc 100644 --- a/main.c +++ b/main.c @@ -65,9 +65,9 @@ main(int argc, char ** argv) fprintf(stderr, "Unknown node type \"%s\"\n", optarg); return 1; } - const char* module_help = NULL; + const char* module_help = spec->documentation; if (module_help) { - printf("Help for module \"%s\":\n", optarg); + printf("Help for node type \"%s\":\n", optarg); printf("%s\n", module_help); } else { printf("No help provided for node type \"%s\"\n", optarg); diff --git a/nodes/evdev.c b/nodes/evdev.c index ce8891c..ff90b24 100644 --- a/nodes/evdev.c +++ b/nodes/evdev.c @@ -139,6 +139,10 @@ GraphNodeSpecification nodespec_evdev = (GraphNodeSpecification) { .destroy = &destroy, .register_io = ®ister_io, .name = "evdev", + .documentation = "Reads evdev events of the specified device\nDoes not accept events\nSends events on all connectors with major code, minor code, payload respectively set to evdev event type, code, value" + "\nOption 'namespace' (optional): set namespace for the generated events" + "\nOption 'file' (required): device file to read events from (like '/dev/input/eventN'), the process must have sufficient privileges to read the file" + , }; MODULE_CONSTRUCTOR(init) diff --git a/nodes/getchar.c b/nodes/getchar.c index 7d6696d..44eb9ed 100644 --- a/nodes/getchar.c +++ b/nodes/getchar.c @@ -95,6 +95,9 @@ GraphNodeSpecification nodespec_getchar = (GraphNodeSpecification) { .destroy = &destroy, .register_io = ®ister_io, .name = "getchar", + .documentation = "Converts stdin bytes to events\nDoes not accept events\nSends events on all connectors with major and minor codes (0, 1) and the read byte as payload" + "\nOption 'namespace' (optional): set namespace for the generated events" + , }; MODULE_CONSTRUCTOR(init) diff --git a/nodes/modifiers.c b/nodes/modifiers.c index fff6adc..bf6a1c9 100644 --- a/nodes/modifiers.c +++ b/nodes/modifiers.c @@ -91,6 +91,10 @@ GraphNodeSpecification nodespec_modifiers = (GraphNodeSpecification) { .destroy = &destroy, .register_io = NULL, .name = "modifiers", + .documentation = "Sets/unsets/toggles modifiers in an event\nAccepts events on any connector\nSends events on all connectors" + "\nOption 'operation' (required): the operation to apply to the event modifier set ('set'/'unset'/'toggle')" + "\nOption 'modifiers' (required): collection of integers --- the set of modifiers to operate on" + , }; MODULE_CONSTRUCTOR(init) diff --git a/nodes/modify_predicate.c b/nodes/modify_predicate.c index 8884716..ed8611f 100644 --- a/nodes/modify_predicate.c +++ b/nodes/modify_predicate.c @@ -94,6 +94,13 @@ GraphNodeSpecification nodespec_modify_predicate = (GraphNodeSpecification) { .destroy = &destroy, .register_io = NULL, .name = "modify_predicate", + .documentation = "Changes 'enabled' and 'inverted' flags of a predicate\nAccepts events on any connector\nDoes not send events" + "\nOption 'target' (required): the predicate to modify" + "\nOption 'enable_on' (optional): the predicate, satisfying events of which set 'enabled' flag of the target predicate to 1" + "\nOption 'disable_on' (optional): the predicate, satisfying events of which set 'enabled' flag of the target predicate to 0" + "\nOption 'invert_on' (optional): the predicate, satisfying events of which set 'inverted' flag of the target predicate to 1" + "\nOption 'uninvert_on' (optional): the predicate, satisfying events of which set 'inverted' flag of the target predicate to 0" + , }; MODULE_CONSTRUCTOR(init) diff --git a/nodes/print.c b/nodes/print.c index 7c3234f..38b393c 100644 --- a/nodes/print.c +++ b/nodes/print.c @@ -60,6 +60,8 @@ GraphNodeSpecification nodespec_print = (GraphNodeSpecification) { .destroy = &destroy, .register_io = NULL, .name = "print", + .documentation = "Prints received events\nAccepts events on any connector\nDoes not send events" + , }; MODULE_CONSTRUCTOR(init) diff --git a/nodes/router.c b/nodes/router.c index 109c3b3..2e29d5f 100644 --- a/nodes/router.c +++ b/nodes/router.c @@ -88,6 +88,9 @@ GraphNodeSpecification nodespec_router = (GraphNodeSpecification) { .destroy = &destroy, .register_io = NULL, .name = "router", + .documentation = "Conditionally copies the received events\nAccepts events on any connector\nSends events on all connectors with configured predicates" + "\nOption 'predicates' (required): collection of predicates in the order of output connectors from zero, a received event is copied to the given connector iff it satisfies the predicate" + , }; MODULE_CONSTRUCTOR(init) diff --git a/nodes/tee.c b/nodes/tee.c index e675573..a098e33 100644 --- a/nodes/tee.c +++ b/nodes/tee.c @@ -53,6 +53,8 @@ GraphNodeSpecification nodespec_tee = (GraphNodeSpecification) { .destroy = &destroy, .register_io = NULL, .name = "tee", + .documentation = "Copies the received events\nAccepts events on any connector\nSends events on all connectors" + , }; MODULE_CONSTRUCTOR(init)