-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
input-device: selection by id or by path #2504
Comments
Example udev properties:
This device must be matched by path because the constructor did not add a iSerialNumber on the USB descriptors. I propose to match in the
In order to uniquely match a peripheral. |
Using @soreau 's WIP, we can configure:
Giving:
|
This is an overview and status of the WIP branch in question. In its current state, a udev handle for the device is retrieved using libinput and libudev. It loops through the udev properties until it matches ID_PATH. It then checks if an input-device section matches in the config file The intent is to check for ID_PATH, then ID_SERIAL (and possibly followed by MAC if that property is available), then device name and finally the default input-device section. The log messages are important as well. The idea would be to output something in the debug log to the effect of This WIP branch also includes the ability to calibrate devices with the syntax There are reportedly many devices that @zougloub wants to test, so after the patch has been tested thoroughly, I will submit a pull request for inclusion to master branch of wayfire. |
@soreau please consider the following changes: diff --git a/src/core/plugin.cpp b/src/core/plugin.cpp
index c59f53b6..3f65aaae 100644
--- a/src/core/plugin.cpp
+++ b/src/core/plugin.cpp
@@ -28,29 +28,13 @@ std::shared_ptr<config::section_t> wf::config_backend_t::get_output_section(
return config.get_section(name);
}
-static const char *get_udev_id_path(udev_device *dev)
-{
- const char *udev_id_path = NULL;
- udev_list_entry *properties = udev_device_get_properties_list_entry(dev);
- while (properties)
- {
- const char *property_name = udev_list_entry_get_name(properties);
- const char *property_value = udev_list_entry_get_value(properties);
- if (!strcmp(property_name, "ID_PATH"))
- {
- udev_id_path = property_value;
- }
-
- properties = udev_list_entry_get_next(properties);
- }
-
- return udev_id_path;
-}
std::shared_ptr<config::section_t> wf::config_backend_t::get_input_device_section(
wlr_input_device *device)
{
- std::string name = nonull(device->name);
+ auto& config = wf::get_core().config;
+ std::shared_ptr<wf::config::section_t> section;
+
if (wlr_input_device_is_libinput(device))
{
auto libinput_dev = wlr_libinput_get_device_handle(device);
@@ -59,24 +43,51 @@ std::shared_ptr<config::section_t> wf::config_backend_t::get_input_device_sectio
udev_device *udev_dev = libinput_device_get_udev_device(libinput_dev);
if (udev_dev)
{
- name = nonull(get_udev_id_path(udev_dev));
+ struct property_and_desc {
+ char const * property_name;
+ char const * description;
+ } properties_and_descs [] =
+ {
+ { "ID_PATH", "stable physical connection path" },
+ { "ID_SERIAL", "stable vendor+pn+sn info" },
+ { "LIBINPUT_DEVICE_GROUP", "stable libinput info" },
+ // sometimes it contains info "by path", sometimes "by id"
+ //{ "DEVPATH", "unstable devpath" },
+ // used for debugging, to find DEVPATH and match the right
+ // device in `udevadm info --tree`
+ };
+
+ for (struct property_and_desc const & pd : properties_and_descs)
+ {
+ const char * value = udev_device_get_property_value(udev_dev, pd.property_name);
+ if (value == nullptr)
+ {
+ continue;
+ }
+ std::string name = std::string("input-device:") + nonull(value);
+ LOGD("Checking config section [", name, "] for ", pd.property_name, " (", pd.description, ")");
+ section = config.get_section(name);
+ if (section)
+ {
+ return section;
+ break;
+ }
+ }
}
}
}
+ std::string name = nonull(device->name);
name = "input-device:" + name;
- LOGD("Checking for input-device config section: [", name, "]");
- auto& config = wf::get_core().config;
- if (!config.get_section(name))
+ LOGD("Checking config section [", name, "]");
+ section = config.get_section(name);
+ if (section)
{
- name = nonull(device->name);
+ return section;
}
- if (!config.get_section(name))
- {
- config.merge_section(
- config.get_section("input-device")->clone_with_name(name));
- }
+ config.merge_section(
+ config.get_section("input-device")->clone_with_name(name));
return config.get_section(name);
} Here are some example outputs:
|
I have pushed this patch as-is to input-device-updates branch. |
This patch adds additional checks for input-device sections in the config file. It checks for ID_PATH, ID_SERIAL, LIBINPUT_DEVICE_GROUP then falls back to the device name and finally the global input-device section. In addition, DEVPATH is printed to log when WF_PRINT_UDEV_DEVPATH is set and '-d' is passed to wayfire, for matching the correct device in i.e. 'udevadm info --tree'. The sections that wayfire checks for are also logged with '-d'. This makes it so users can match devices, especially identical devices lacking many of the usual differentiating properties. Fixes #2504.
This patch adds additional checks for input-device sections in the config file. It checks for ID_PATH, ID_SERIAL, LIBINPUT_DEVICE_GROUP then falls back to the device name and finally the global input-device section. In addition, DEVPATH is printed to log when WF_PRINT_UDEV_DEVPATH is set and '-d' is passed to wayfire, for matching the correct device in i.e. 'udevadm info --tree'. The sections that wayfire checks for are also logged with '-d'. This makes it so users can match devices, especially identical devices lacking many of the usual differentiating properties. Fixes #2504.
This may relate to #2481
The code in get_input_device_section only matches an
input-device
section suffixed bydev->name
, which is a problem if devices have the same name.We'd need a syntax to specify a name by id or by path, maybe we can use a /dev/input/by-* path and check if the path exists, and resolve the corresponding device.
The text was updated successfully, but these errors were encountered: