From f87e7b88038d769def90403ebc5a7dfbdc94348c Mon Sep 17 00:00:00 2001 From: Ilia Bozhinov Date: Mon, 24 Feb 2025 17:15:09 +0100 Subject: [PATCH] input: small changes to documentation and XML --- metadata/input-device.xml | 2 ++ src/api/wayfire/config-backend.hpp | 4 ++-- src/core/seat/input-manager.cpp | 15 ++++++--------- src/core/seat/seat-impl.hpp | 2 +- src/core/seat/seat.cpp | 4 ++-- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/metadata/input-device.xml b/metadata/input-device.xml index 54a8f45f4..a49546479 100644 --- a/metadata/input-device.xml +++ b/metadata/input-device.xml @@ -6,6 +6,8 @@ diff --git a/src/api/wayfire/config-backend.hpp b/src/api/wayfire/config-backend.hpp index 54db71bb6..37501386c 100644 --- a/src/api/wayfire/config-backend.hpp +++ b/src/api/wayfire/config-backend.hpp @@ -45,8 +45,8 @@ class config_backend_t /** * Find the output section for a given input device. * - * The returned section must be a valid output object as - * described in input-device.xml + * The returned section must be a valid config object as described + * in <@prefix>.xml (typically input.xml or input-device.xml). */ virtual std::shared_ptr get_input_device_section( std::string const & prefix, wlr_input_device *device); diff --git a/src/core/seat/input-manager.cpp b/src/core/seat/input-manager.cpp index e198717f2..5961f401d 100644 --- a/src/core/seat/input-manager.cpp +++ b/src/core/seat/input-manager.cpp @@ -4,14 +4,11 @@ #include "wayfire/core.hpp" #include "wayfire/signal-definitions.hpp" #include "../core-impl.hpp" -#include "../../output/output-impl.hpp" -#include "touch.hpp" #include "keyboard.hpp" #include "cursor.hpp" #include "input-manager.hpp" #include "wayfire/output-layout.hpp" #include "wayfire/view.hpp" -#include "wayfire/workspace-set.hpp" #include #include @@ -62,6 +59,12 @@ void wf::input_manager_t::configure_input_device(std::unique_ptrget_input_device_section("input-device", dev); + auto calibration_matrix = section->get_option("calibration")->get_value_str(); + if (!calibration_matrix.empty()) + { + device->calibrate_touch_device(calibration_matrix); + } + auto mapped_output = section->get_option("output")->get_value_str(); if (mapped_output.empty()) { @@ -79,12 +82,6 @@ void wf::input_manager_t::configure_input_device(std::unique_ptrget_option("calibration")->get_value_str(); - if (!cal.empty()) - { - device->calibrate_touch_device(cal); - } - auto wo = wf::get_core().output_layout->find_output(mapped_output); if (wo) { diff --git a/src/core/seat/seat-impl.hpp b/src/core/seat/seat-impl.hpp index 3665f195d..90eed88e1 100644 --- a/src/core/seat/seat-impl.hpp +++ b/src/core/seat/seat-impl.hpp @@ -34,7 +34,7 @@ class input_device_impl_t : public wf::input_device_t * 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(std::string const & cal); + void calibrate_touch_device(const std::string& calibration_matrix); }; class pointer_t; diff --git a/src/core/seat/seat.cpp b/src/core/seat/seat.cpp index cab6eacc9..6d2a6291b 100644 --- a/src/core/seat/seat.cpp +++ b/src/core/seat/seat.cpp @@ -578,7 +578,7 @@ bool input_device_t::is_enabled() return mode == LIBINPUT_CONFIG_SEND_EVENTS_ENABLED; } -void input_device_impl_t::calibrate_touch_device(std::string const & cal) +void input_device_impl_t::calibrate_touch_device(const std::string& calibration_matrix) { wlr_input_device *dev = handle; if (!wlr_input_device_is_libinput(dev) || (dev->type != WLR_INPUT_DEVICE_TOUCH)) @@ -588,7 +588,7 @@ void input_device_impl_t::calibrate_touch_device(std::string const & cal) float m[6]; auto libinput_dev = wlr_libinput_get_device_handle(dev); - if (sscanf(cal.c_str(), "%f %f %f %f %f %f", + if (sscanf(calibration_matrix.c_str(), "%f %f %f %f %f %f", &m[0], &m[1], &m[2], &m[3], &m[4], &m[5]) == 6) { enum libinput_config_status status;