Support for input properties in uinput

This commit is contained in:
Vftdan 2024-08-19 10:56:25 +02:00
parent 4c654cd621
commit eaa64f5b4c
2 changed files with 11 additions and 0 deletions

View File

@ -96,6 +96,12 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
return NULL;
}
size_t properties_length = 0;
const config_setting_t *properties_setting = config_setting_get_member(config->options, "properties");
if (properties_setting) {
properties_length = config_setting_length(enabled_codes_setting);
}
struct libevdev *dev = libevdev_new();
if (!dev) {
free(node);
@ -107,6 +113,9 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
for (size_t i = 0; i < codes_length; ++i) {
load_enable_code(dev, config_setting_get_elem(enabled_codes_setting, i), env);
}
for (size_t i = 0; i < properties_length; ++i) {
libevdev_enable_property(dev, (unsigned int) env_resolve_constant(env, config_setting_get_elem(properties_setting, i)));
}
struct libevdev_uinput *uidev;
int err;
@ -158,6 +167,7 @@ GraphNodeSpecification nodespec_uinput = (GraphNodeSpecification) {
.name = "uinput",
.documentation = "Writes received events to a new uinput device\nAccepts events on any connector\nDoes not send events"
"\nOption 'name' (required): device name provided to uinput"
"\nOption 'properties' (optional): collection of integers --- input properties"
"\nOption 'enabled_codes' (required): collection of event code specifications:"
"\n\tField 'major' (required): evdev event type"
"\n\tField 'minor' (required): evdev event code"

View File

@ -86,6 +86,7 @@ nodes = {
,
{major: "event_type.KEY"; minor: "button_event.MIDDLE"}
);
properties = ["input_property.POINTER", "input_property.BUTTONPAD"];
};
};
};