-
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 all commits
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) | ||
std::string const & prefix, wlr_input_device *device) | ||
{ | ||
std::string name = nonull(device->name); | ||
name = "input-device:" + name; | ||
auto& config = wf::get_core().config; | ||
if (!config.get_section(name)) | ||
std::shared_ptr<wf::config::section_t> section; | ||
auto print_devpath = getenv("WF_PRINT_UDEV_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. I think what you are looking for here are the debug categories, they are rather simple to add, maybe an 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 commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, this makes more sense. This way we can use |
||
|
||
if (wlr_input_device_is_libinput(device)) | ||
{ | ||
config.merge_section( | ||
config.get_section("input-device")->clone_with_name(name)); | ||
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 = prefix + ":" + 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 = prefix + ":" + name; | ||
LOGD("Checking for config section [", name, "]"); | ||
section = config.get_section(name); | ||
if (section) | ||
{ | ||
LOGD("Using config section [", name, "]"); | ||
return section; | ||
} | ||
|
||
config.merge_section( | ||
config.get_section(prefix)->clone_with_name(name)); | ||
|
||
return config.get_section(name); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -37,11 +37,23 @@ class input_manager_t | |||
*/ | ||||
uint32_t locked_mods = 0; | ||||
|
||||
/** | ||||
* Map a single input device to output as specified in the | ||||
* config file or by hints in the wlroots backend. | ||||
*/ | ||||
void configure_input_device(wlr_input_device *dev); | ||||
|
||||
/** | ||||
* Go through all input devices and map them to outputs as specified in the | ||||
* config file or by hints in the wlroots backend. | ||||
*/ | ||||
void refresh_device_mappings(); | ||||
void configure_input_devices(); | ||||
|
||||
/** | ||||
* Calibrate a touch device with a matrix. This function does nothing | ||||
* if called with a device that is not a touch device. | ||||
*/ | ||||
void calibrate_touch_device(wlr_input_device *dev, std::string const & cal); | ||||
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. This doesn't seem like it should be in input-manager ... Because this is device-type-specific (mapping inputs to outputs works for tablets, touch and pointer). Ideally speaking, we'd want to add an input-device class for touch devices and load their specific options there, just like we do for pointers: https://github.com/WayfireWM/wayfire/blob/master/src/core/seat/pointing-device.hpp And then we can create this device-specific object here: wayfire/src/core/seat/input-manager.cpp Line 39 in 5653242 At the very least, it seems like this should be somewhere in the input device class. 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. Hm, ok.. |
||||
|
||||
input_manager_t(); | ||||
~input_manager_t() = default; | ||||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -121,14 +121,18 @@ void wf::keyboard_t::setup_listeners() | |||||||||||||||||||||||||||||||||||||||||
wf::keyboard_t::keyboard_t(wlr_input_device *dev) : | ||||||||||||||||||||||||||||||||||||||||||
handle(wlr_keyboard_from_input_device(dev)), device(dev) | ||||||||||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||||||||||
model.load_option("input/xkb_model"); | ||||||||||||||||||||||||||||||||||||||||||
variant.load_option("input/xkb_variant"); | ||||||||||||||||||||||||||||||||||||||||||
layout.load_option("input/xkb_layout"); | ||||||||||||||||||||||||||||||||||||||||||
options.load_option("input/xkb_options"); | ||||||||||||||||||||||||||||||||||||||||||
rules.load_option("input/xkb_rules"); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
repeat_rate.load_option("input/kb_repeat_rate"); | ||||||||||||||||||||||||||||||||||||||||||
repeat_delay.load_option("input/kb_repeat_delay"); | ||||||||||||||||||||||||||||||||||||||||||
auto section = | ||||||||||||||||||||||||||||||||||||||||||
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. Seems like we'd want the same for pointer? wayfire/src/core/seat/pointing-device.cpp Lines 12 to 31 in 5653242
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 was thinking what other bits we might want this for.. adding for pointer makes sense to me, will update. |
||||||||||||||||||||||||||||||||||||||||||
wf::get_core().config_backend->get_input_device_section("input", dev); | ||||||||||||||||||||||||||||||||||||||||||
auto section_name = section->get_name(); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
model.load_option(section_name + "/xkb_model"); | ||||||||||||||||||||||||||||||||||||||||||
variant.load_option(section_name + "/xkb_variant"); | ||||||||||||||||||||||||||||||||||||||||||
layout.load_option(section_name + "/xkb_layout"); | ||||||||||||||||||||||||||||||||||||||||||
options.load_option(section_name + "/xkb_options"); | ||||||||||||||||||||||||||||||||||||||||||
rules.load_option(section_name + "/xkb_rules"); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
repeat_rate.load_option(section_name + "/kb_repeat_rate"); | ||||||||||||||||||||||||||||||||||||||||||
repeat_delay.load_option(section_name + "/kb_repeat_delay"); | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
// When the configuration options change, mark them as dirty. | ||||||||||||||||||||||||||||||||||||||||||
// They are applied at the config-reloaded signal. | ||||||||||||||||||||||||||||||||||||||||||
|
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.
needs API/ABI version bump :)
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 yes, I forgot to bump! :)