Skip to content

Commit

Permalink
input: small changes to documentation and XML
Browse files Browse the repository at this point in the history
  • Loading branch information
ammen99 committed Feb 24, 2025
1 parent 4da60bd commit f87e7b8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
2 changes: 2 additions & 0 deletions metadata/input-device.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<default></default>
</option>
<option name="calibration" type="string">
<_short>Calibration matrix</_short>
<_long>Calibration matrix for touch devices, used udev/libinput format (2x3 matrix, 6 floats separated by space).</_long>
<default></default>
</option>
</object>
Expand Down
4 changes: 2 additions & 2 deletions src/api/wayfire/config-backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<config::section_t> get_input_device_section(
std::string const & prefix, wlr_input_device *device);
Expand Down
15 changes: 6 additions & 9 deletions src/core/seat/input-manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <wayfire/util/log.hpp>
#include <wayfire/debug.hpp>

Expand Down Expand Up @@ -62,6 +59,12 @@ void wf::input_manager_t::configure_input_device(std::unique_ptr<wf::input_devic
auto section =
wf::get_core().config_backend->get_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())
{
Expand All @@ -79,12 +82,6 @@ void wf::input_manager_t::configure_input_device(std::unique_ptr<wf::input_devic
}
}

auto cal = section->get_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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/seat/seat-impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/core/seat/seat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
Expand Down

0 comments on commit f87e7b8

Please sign in to comment.