Compare commits
No commits in common. "52b3b74e7b0c2c2623a08c900c5e4c5c4b515d29" and "3a9eed56bbe355fbd7c414a3133046772d7130d2" have entirely different histories.
52b3b74e7b
...
3a9eed56bb
2
Makefile
2
Makefile
|
@ -12,7 +12,7 @@ CPPFLAGS += $(shell pkg-config --cflags $(DEPS))
|
||||||
LDLIBS += $(shell pkg-config --libs $(DEPS))
|
LDLIBS += $(shell pkg-config --libs $(DEPS))
|
||||||
INTERP ?=
|
INTERP ?=
|
||||||
MAIN = main
|
MAIN = main
|
||||||
OBJS = main.o events.o processing.o graph.o config.o event_code_names.o hash_table.o queue.o module_registry.o event_predicate.o nodes/getchar.o nodes/print.o nodes/evdev.o nodes/tee.o nodes/router.o nodes/modifiers.o nodes/modify_predicate.o nodes/uinput.o nodes/assign.o nodes/differentiate.o nodes/integrate.o nodes/scale.o nodes/window.o
|
OBJS = main.o events.o processing.o graph.o config.o event_code_names.o hash_table.o queue.o module_registry.o event_predicate.o nodes/getchar.o nodes/print.o nodes/evdev.o nodes/tee.o nodes/router.o nodes/modifiers.o nodes/modify_predicate.o nodes/uinput.o nodes/assign.o nodes/differentiate.o nodes/scale.o nodes/window.o
|
||||||
|
|
||||||
all: $(MAIN)
|
all: $(MAIN)
|
||||||
|
|
||||||
|
|
78
config.cfg
78
config.cfg
|
@ -3,8 +3,7 @@ constants = {
|
||||||
};
|
};
|
||||||
|
|
||||||
enums = {
|
enums = {
|
||||||
namespaces: ["stdin", "clickpad", "variable"];
|
namespaces: ["stdin", "clickpad"];
|
||||||
variables: ["num_touches"];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
predicates = {
|
predicates = {
|
||||||
|
@ -24,17 +23,6 @@ predicates = {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
abs_event = {
|
|
||||||
type = "and";
|
|
||||||
args = (
|
|
||||||
"is_evdev",
|
|
||||||
{
|
|
||||||
type = "code_major";
|
|
||||||
min = "event_type.ABS";
|
|
||||||
max = "event_type.ABS";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
btn_touch_event = {
|
btn_touch_event = {
|
||||||
type = "and";
|
type = "and";
|
||||||
args = (
|
args = (
|
||||||
|
@ -46,17 +34,6 @@ predicates = {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
touch_tracking_id = {
|
|
||||||
type = "and";
|
|
||||||
args = (
|
|
||||||
"abs_event",
|
|
||||||
{
|
|
||||||
type = "code_minor";
|
|
||||||
min = "absolute_axis.MT_TRACKING_ID";
|
|
||||||
max = "absolute_axis.MT_TRACKING_ID";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
payload_zero = {
|
payload_zero = {
|
||||||
type = "payload";
|
type = "payload";
|
||||||
min = 0;
|
min = 0;
|
||||||
|
@ -67,22 +44,6 @@ predicates = {
|
||||||
min = 1;
|
min = 1;
|
||||||
max = 1;
|
max = 1;
|
||||||
};
|
};
|
||||||
payload_negative = {
|
|
||||||
type = "payload";
|
|
||||||
max = -1;
|
|
||||||
};
|
|
||||||
payload_nonnegative = {
|
|
||||||
type = "payload";
|
|
||||||
min = 0;
|
|
||||||
};
|
|
||||||
touch_start = {
|
|
||||||
type = "and";
|
|
||||||
args = ["touch_tracking_id", "payload_nonnegative"];
|
|
||||||
};
|
|
||||||
touch_end = {
|
|
||||||
type = "and";
|
|
||||||
args = ["touch_tracking_id", "payload_negative"];
|
|
||||||
};
|
|
||||||
touch_held = {
|
touch_held = {
|
||||||
type = "accept";
|
type = "accept";
|
||||||
inverted = 1;
|
inverted = 1;
|
||||||
|
@ -117,9 +78,7 @@ nodes = {
|
||||||
type = "or";
|
type = "or";
|
||||||
inverted = 1;
|
inverted = 1;
|
||||||
args = ["key_event"];
|
args = ["key_event"];
|
||||||
},
|
}
|
||||||
"touch_start",
|
|
||||||
"touch_end"
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -157,24 +116,6 @@ nodes = {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
set_one = {
|
|
||||||
type = "assign";
|
|
||||||
options = {
|
|
||||||
payload = 1;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
count_touches = {
|
|
||||||
// This exact usecase may be implemented using events like button_event.TOOL_DOUBLETAP, button_event.TOOL_TRIPLETAP, button_event.TOOL_QUADTAP, button_event.TOOL_QUINTTAP
|
|
||||||
type = "integrate";
|
|
||||||
};
|
|
||||||
set_variable_num_touches = {
|
|
||||||
type = "assign";
|
|
||||||
options = {
|
|
||||||
namespace = "namespaces.variable";
|
|
||||||
major = "variables.num_touches";
|
|
||||||
minor = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
channels = ({
|
channels = ({
|
||||||
|
@ -198,21 +139,6 @@ channels = ({
|
||||||
}, {
|
}, {
|
||||||
from: ("clickpad", 1);
|
from: ("clickpad", 1);
|
||||||
to: ("update_touch_held", 0);
|
to: ("update_touch_held", 0);
|
||||||
}, {
|
|
||||||
from: ("select_key_events", 2); // touch_start
|
|
||||||
to: ("set_one", 0);
|
|
||||||
}, {
|
|
||||||
from: ("set_one", 0);
|
|
||||||
to: ("count_touches", 0);
|
|
||||||
}, {
|
|
||||||
from: ("select_key_events", 3); // touch_end
|
|
||||||
to: ("count_touches", 1);
|
|
||||||
}, {
|
|
||||||
from: ("count_touches", 0);
|
|
||||||
to: ("set_variable_num_touches", 0);
|
|
||||||
}, {
|
|
||||||
from: ("set_variable_num_touches", 0);
|
|
||||||
to: ("print", 2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// vim: ft=libconfig
|
// vim: ft=libconfig
|
||||||
|
|
6
events.c
6
events.c
|
@ -21,7 +21,8 @@ event_replicate(EventNode * source, size_t count)
|
||||||
}
|
}
|
||||||
replica->position = NULL;
|
replica->position = NULL;
|
||||||
replica->input_index = 0;
|
replica->input_index = 0;
|
||||||
replica->data = event_data_copy(source->data);
|
replica->data = source->data;
|
||||||
|
replica->data.modifiers = modifier_set_copy(source->data.modifiers);
|
||||||
replica->prev = source;
|
replica->prev = source;
|
||||||
replica->next = source->next;
|
replica->next = source->next;
|
||||||
source->next->prev = replica;
|
source->next->prev = replica;
|
||||||
|
@ -38,7 +39,8 @@ event_create(const EventData * content)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (content) {
|
if (content) {
|
||||||
event->data = event_data_copy(*content);
|
event->data = *content;
|
||||||
|
event->data.modifiers = modifier_set_copy(content->modifiers);
|
||||||
} else {
|
} else {
|
||||||
event->data.time = get_current_time();
|
event->data.time = get_current_time();
|
||||||
}
|
}
|
||||||
|
|
7
events.h
7
events.h
|
@ -49,11 +49,4 @@ EventNode * event_create(const EventData * content);
|
||||||
void event_destroy(EventNode * self);
|
void event_destroy(EventNode * self);
|
||||||
void event_destroy_all();
|
void event_destroy_all();
|
||||||
|
|
||||||
__attribute__((unused)) inline static EventData
|
|
||||||
event_data_copy(EventData orig)
|
|
||||||
{
|
|
||||||
orig.modifiers = modifier_set_copy(orig.modifiers);
|
|
||||||
return orig;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* end of include guard: EVENTS_H_ */
|
#endif /* end of include guard: EVENTS_H_ */
|
||||||
|
|
|
@ -1,78 +0,0 @@
|
||||||
#include "../graph.h"
|
|
||||||
#include "../module_registry.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
GraphNode as_GraphNode;
|
|
||||||
int64_t total;
|
|
||||||
} IntegrateGraphNode;
|
|
||||||
|
|
||||||
static bool
|
|
||||||
handle_event(EventPositionBase * self, EventNode * event)
|
|
||||||
{
|
|
||||||
IntegrateGraphNode *node = DOWNCAST(IntegrateGraphNode, GraphNode, DOWNCAST(GraphNode, EventPositionBase, self));
|
|
||||||
size_t count = node->as_GraphNode.outputs.length;
|
|
||||||
if (!count) {
|
|
||||||
event_destroy(event);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t total = node->total;
|
|
||||||
total += event->data.payload;
|
|
||||||
event->data.payload = total;
|
|
||||||
node->total = total;
|
|
||||||
|
|
||||||
graph_node_broadcast_forward_event(&node->as_GraphNode, event);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GraphNode *
|
|
||||||
create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEnvironment * env)
|
|
||||||
{
|
|
||||||
(void) config;
|
|
||||||
(void) env;
|
|
||||||
IntegrateGraphNode * node = T_ALLOC(1, IntegrateGraphNode);
|
|
||||||
if (!node) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int64_t initial = 0;
|
|
||||||
if (config->options) {
|
|
||||||
initial = env_resolve_constant(env, config_setting_get_member(config->options, "initial"));
|
|
||||||
}
|
|
||||||
|
|
||||||
*node = (IntegrateGraphNode) {
|
|
||||||
.as_GraphNode = {
|
|
||||||
.as_EventPositionBase = {
|
|
||||||
.handle_event = &handle_event,
|
|
||||||
.waiting_new_event = false,
|
|
||||||
},
|
|
||||||
.specification = spec,
|
|
||||||
.inputs = EMPTY_GRAPH_CHANNEL_LIST,
|
|
||||||
.outputs = EMPTY_GRAPH_CHANNEL_LIST,
|
|
||||||
},
|
|
||||||
.total = initial,
|
|
||||||
};
|
|
||||||
return &node->as_GraphNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void destroy
|
|
||||||
(GraphNodeSpecification * self, GraphNode * target)
|
|
||||||
{
|
|
||||||
(void) self;
|
|
||||||
free(target);
|
|
||||||
}
|
|
||||||
|
|
||||||
GraphNodeSpecification nodespec_integrate = (GraphNodeSpecification) {
|
|
||||||
.create = &create,
|
|
||||||
.destroy = &destroy,
|
|
||||||
.register_io = NULL,
|
|
||||||
.name = "integrate",
|
|
||||||
.documentation = "Calculates a running sum of previous event payloads and replaces with it the current one\nAccepts events on any connector\nSends events on all connectors"
|
|
||||||
"\nOption 'initial' (optional): the initial partial sum value"
|
|
||||||
,
|
|
||||||
};
|
|
||||||
|
|
||||||
MODULE_CONSTRUCTOR(init)
|
|
||||||
{
|
|
||||||
register_graph_node_specification(&nodespec_integrate);
|
|
||||||
}
|
|
|
@ -69,7 +69,6 @@ trigger_new_window(WindowGraphNode * node, EventNode * base)
|
||||||
terminator->data.code = node->terminator_prototype.code;
|
terminator->data.code = node->terminator_prototype.code;
|
||||||
terminator->data.modifiers = modifier_set_copy(node->terminator_prototype.modifiers);
|
terminator->data.modifiers = modifier_set_copy(node->terminator_prototype.modifiers);
|
||||||
terminator->data.payload = node->terminator_prototype.payload;
|
terminator->data.payload = node->terminator_prototype.payload;
|
||||||
// Preserve ttl, priority, time
|
|
||||||
graph_node_broadcast_forward_event(&node->as_GraphNode, terminator);
|
graph_node_broadcast_forward_event(&node->as_GraphNode, terminator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +102,8 @@ trigger_new_window(WindowGraphNode * node, EventNode * base)
|
||||||
if (!recipient) {
|
if (!recipient) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
recipient->data = event_data_copy(orig->data);
|
recipient->data = orig->data;
|
||||||
|
recipient->data.modifiers = modifier_set_copy(orig->data.modifiers);
|
||||||
graph_node_broadcast_forward_event(&node->as_GraphNode, recipient);
|
graph_node_broadcast_forward_event(&node->as_GraphNode, recipient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue