-
Notifications
You must be signed in to change notification settings - Fork 177
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 updates #2510
base: master
Are you sure you want to change the base?
Input device updates #2510
Changes from 1 commit
6e18861
bb729f4
1008879
fcc81c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
#include "wayfire/signal-definitions.hpp" | ||
#include <wayfire/util/log.hpp> | ||
#include <wayfire/config-backend.hpp> | ||
#include <libudev.h> | ||
|
||
void wf::plugin_interface_t::fini() | ||
{} | ||
|
@@ -27,18 +28,76 @@ std::shared_ptr<config::section_t> wf::config_backend_t::get_output_section( | |
return config.get_section(name); | ||
} | ||
|
||
static struct udev_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` | ||
}; | ||
|
||
std::shared_ptr<config::section_t> wf::config_backend_t::get_input_device_section( | ||
wlr_input_device *device) | ||
{ | ||
auto& config = wf::get_core().config; | ||
std::shared_ptr<wf::config::section_t> section; | ||
auto print_devpath = getenv("WF_PRINT_UDEV_DEVPATH"); | ||
|
||
if (wlr_input_device_is_libinput(device)) | ||
{ | ||
auto libinput_dev = wlr_libinput_get_device_handle(device); | ||
if (libinput_dev) | ||
{ | ||
udev_device *udev_dev = libinput_device_get_udev_device(libinput_dev); | ||
if (udev_dev) | ||
{ | ||
for (struct udev_property_and_desc const & pd : properties_and_descs) | ||
{ | ||
if (!print_devpath && !strncmp(pd.property_name, "DEVPATH", strlen("DEVPATH"))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, wouldn't it be more appropriate to send this info over via IPC and print it in the scripts we already have for listing input devices? I can imagine that this would be much easier to use. Otherwise, I think we can/should just print every property we are querying here (in the corresponding debug category). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I disagree that we should require ipc for this task. It should be as easy as |
||
{ | ||
continue; | ||
} | ||
|
||
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 for config section [", name, "] ", | ||
pd.property_name, " (", pd.description, ")"); | ||
section = config.get_section(name); | ||
if (section) | ||
{ | ||
LOGD("Using config section [", name, "] for ", nonull(device->name)); | ||
return section; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
std::string name = nonull(device->name); | ||
name = "input-device:" + name; | ||
auto& config = wf::get_core().config; | ||
if (!config.get_section(name)) | ||
LOGD("Checking for config section [", name, "]"); | ||
section = config.get_section(name); | ||
if (section) | ||
{ | ||
config.merge_section( | ||
config.get_section("input-device")->clone_with_name(name)); | ||
LOGD("Using config section [", name, "]"); | ||
return section; | ||
} | ||
|
||
config.merge_section( | ||
config.get_section("input-device")->clone_with_name(name)); | ||
|
||
return config.get_section(name); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what you are looking for here are the debug categories, they are rather simple to add, maybe an
input-device
category?Check these here: https://github.com/WayfireWM/wayfire/blob/master/src/api/wayfire/debug.hpp#L42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, this makes more sense. This way we can use
wayfire -d input-device
to get the additional message(s).