2024-08-17 16:46:48 +03:00
constants = {
my_modifier = 9;
};
2024-08-16 12:58:19 +03:00
enums = {
2024-08-21 14:18:38 +03:00
namespaces: ["stdin", "clickpad", "variable"];
variables: ["num_touches"];
2024-08-16 11:12:20 +03:00
};
2024-08-16 23:48:09 +03:00
predicates = {
is_evdev = {
type = "code_ns";
min = "namespaces.clickpad";
max = "namespaces.clickpad";
};
key_event = {
type = "and";
args = (
"is_evdev",
{
type = "code_major";
min = "event_type.KEY";
max = "event_type.KEY";
}
);
2024-08-17 12:02:26 +03:00
};
2024-08-21 14:18:38 +03:00
abs_event = {
type = "and";
args = (
"is_evdev",
{
type = "code_major";
min = "event_type.ABS";
max = "event_type.ABS";
}
);
};
2024-08-18 14:32:20 +03:00
btn_touch_event = {
type = "and";
args = (
"key_event",
{
type = "code_minor";
min = "button_event.TOUCH";
max = "button_event.TOUCH";
}
);
};
2024-08-21 14:18:38 +03:00
touch_tracking_id = {
type = "and";
args = (
"abs_event",
{
type = "code_minor";
min = "absolute_axis.MT_TRACKING_ID";
max = "absolute_axis.MT_TRACKING_ID";
}
);
};
2024-08-18 14:32:20 +03:00
payload_zero = {
type = "payload";
min = 0;
max = 0;
};
payload_one = {
type = "payload";
min = 1;
max = 1;
};
2024-08-21 14:18:38 +03:00
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"];
};
2024-08-18 14:32:20 +03:00
touch_held = {
type = "accept";
inverted = 1;
};
2024-08-16 23:48:09 +03:00
};
2024-08-14 23:23:21 +03:00
nodes = {
stdin = {
type = "getchar";
options = {
2024-08-16 12:58:19 +03:00
namespace = "namespaces.stdin";
2024-08-14 23:23:21 +03:00
};
};
print = {
type = "print";
options = {};
};
clickpad = {
type = "evdev";
options = {
file = "/dev/input/event7";
2024-08-16 12:58:19 +03:00
namespace = "namespaces.clickpad";
2024-08-18 18:31:45 +03:00
// grab = 1;
2024-08-14 23:23:21 +03:00
};
};
2024-08-17 12:35:36 +03:00
select_key_events = {
type = "router";
options = {
2024-08-17 16:46:48 +03:00
predicates = (
"key_event",
{
type = "or";
inverted = 1;
args = ["key_event"];
2024-08-21 14:18:38 +03:00
},
"touch_start",
"touch_end"
2024-08-17 16:46:48 +03:00
);
};
};
set_modifier = {
type = "modifiers";
options = {
operation = "set";
modifiers = ["my_modifier"];
2024-08-17 12:35:36 +03:00
};
};
2024-08-18 14:32:20 +03:00
update_touch_held = {
type = "modify_predicate";
options = {
target = "touch_held";
uninvert_on = {type: "and", args: ["btn_touch_event", "payload_one"]};
invert_on = {type: "and", args: ["btn_touch_event", "payload_zero"]};
};
};
while_touch_held = {
type = "router";
options = {
predicates = ["touch_held"];
};
};
2024-08-18 18:19:37 +03:00
uinput_output = {
type = "uinput";
options = {
name = "Resulting device";
enabled_codes = (
{major: "event_type.KEY"; minor: "button_event.LEFT"}
,
{major: "event_type.KEY"; minor: "button_event.RIGHT"}
,
{major: "event_type.ABS"; minor: "absolute_axis.X"; data: {minimum: 0; maximum: 3200; resolution: 0}}
);
};
};
2024-08-21 14:18:38 +03:00
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;
};
};
2024-08-14 23:23:21 +03:00
};
channels = ({
from: ("stdin", 0);
2024-08-17 12:35:36 +03:00
to: ("select_key_events", 0);
2024-08-14 23:23:21 +03:00
}, {
from: ("clickpad", 0);
2024-08-17 12:35:36 +03:00
to: ("select_key_events", 1);
}, {
from: ("select_key_events", 0);
2024-08-17 16:46:48 +03:00
to: ("set_modifier", 0);
}, {
from: ("set_modifier", 0);
2024-08-17 12:35:36 +03:00
to: ("print", 0);
2024-08-17 16:46:48 +03:00
}, {
from: ("select_key_events", 1);
2024-08-18 14:32:20 +03:00
to: ("while_touch_held", 0);
}, {
from: ("while_touch_held", 0);
2024-08-17 16:46:48 +03:00
to: ("print", 1);
2024-08-18 14:32:20 +03:00
}, {
from: ("clickpad", 1);
to: ("update_touch_held", 0);
2024-08-21 14:18:38 +03:00
}, {
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);
2024-08-14 23:23:21 +03:00
});
// vim: ft = libconfig