2015-04-15 11:44:54 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2015 Red Hat, Inc.
|
|
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2015-04-15 11:44:54 +10:00
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2015-04-15 11:44:54 +10:00
|
|
|
*/
|
|
|
|
|
|
2016-12-05 20:56:23 +10:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
#include <errno.h>
|
2025-02-10 13:42:45 +10:00
|
|
|
#include <getopt.h>
|
2015-04-15 11:44:54 +10:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <libudev.h>
|
2025-02-10 14:37:20 +10:00
|
|
|
#include <libevdev/libevdev.h>
|
2015-04-15 11:44:54 +10:00
|
|
|
|
|
|
|
|
#include <libinput.h>
|
2015-04-29 07:53:56 +10:00
|
|
|
#include <libinput-version.h>
|
2019-09-06 11:42:09 +10:00
|
|
|
#include "util-strings.h"
|
2015-04-15 11:44:54 +10:00
|
|
|
|
|
|
|
|
#include "shared.h"
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
|
tap_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_tap_get_finger_count(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_default_enabled(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2015-04-15 11:44:54 +10:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
static const char *
|
|
|
|
|
tap_button_map(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_tap_get_finger_count(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
switch (libinput_device_config_tap_get_button_map(device)) {
|
|
|
|
|
case LIBINPUT_CONFIG_TAP_MAP_LRM: return "left/right/middle";
|
|
|
|
|
case LIBINPUT_CONFIG_TAP_MAP_LMR: return "left/middle/right";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "<invalid value>";
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 17:59:19 +10:00
|
|
|
static const char *
|
|
|
|
|
drag_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_tap_get_finger_count(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_default_drag_enabled(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2016-01-22 17:59:19 +10:00
|
|
|
}
|
|
|
|
|
|
2015-06-16 17:02:02 +10:00
|
|
|
static const char *
|
|
|
|
|
draglock_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_tap_get_finger_count(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_default_drag_lock_enabled(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2015-06-16 17:02:02 +10:00
|
|
|
}
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
static const char*
|
|
|
|
|
left_handed_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_left_handed_is_available(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_left_handed_get_default(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2015-04-15 11:44:54 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
|
nat_scroll_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_scroll_has_natural_scroll(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_scroll_get_default_natural_scroll_enabled(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2015-04-15 11:44:54 +10:00
|
|
|
}
|
|
|
|
|
|
2015-04-23 17:33:17 +10:00
|
|
|
static const char *
|
|
|
|
|
middle_emulation_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_middle_emulation_get_default_enabled(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2015-04-23 17:33:17 +10:00
|
|
|
}
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
static char *
|
|
|
|
|
calibration_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
float calibration[6];
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_calibration_has_matrix(device)) {
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str, "n/a");
|
2015-04-15 11:44:54 +10:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_calibration_get_default_matrix(device,
|
|
|
|
|
calibration) == 0) {
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str, "identity matrix");
|
2015-04-15 11:44:54 +10:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str,
|
2015-04-15 11:44:54 +10:00
|
|
|
"%.2f %.2f %.2f %.2f %.2f %.2f",
|
|
|
|
|
calibration[0],
|
|
|
|
|
calibration[1],
|
|
|
|
|
calibration[2],
|
|
|
|
|
calibration[3],
|
|
|
|
|
calibration[4],
|
|
|
|
|
calibration[5]);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static char *
|
|
|
|
|
scroll_defaults(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t scroll_methods;
|
|
|
|
|
char *str;
|
|
|
|
|
enum libinput_config_scroll_method method;
|
|
|
|
|
|
|
|
|
|
scroll_methods = libinput_device_config_scroll_get_methods(device);
|
|
|
|
|
if (scroll_methods == LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str, "none");
|
2015-04-15 11:44:54 +10:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
method = libinput_device_config_scroll_get_default_method(device);
|
|
|
|
|
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str,
|
2015-04-15 11:44:54 +10:00
|
|
|
"%s%s%s%s%s%s",
|
|
|
|
|
(method == LIBINPUT_CONFIG_SCROLL_2FG) ? "*" : "",
|
|
|
|
|
(scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG) ? "two-finger " : "",
|
|
|
|
|
(method == LIBINPUT_CONFIG_SCROLL_EDGE) ? "*" : "",
|
|
|
|
|
(scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE) ? "edge " : "",
|
|
|
|
|
(method == LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) ? "*" : "",
|
|
|
|
|
(scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) ? "button" : "");
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
static const char *
|
|
|
|
|
scroll_button_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t scroll_methods = libinput_device_config_scroll_get_methods(device);
|
|
|
|
|
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
|
|
|
|
|
uint32_t button = libinput_device_config_scroll_get_default_button(device);
|
|
|
|
|
return libevdev_event_code_get_name(EV_KEY, button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "n/a";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
|
scroll_button_lock_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t scroll_methods = libinput_device_config_scroll_get_methods(device);
|
|
|
|
|
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) {
|
|
|
|
|
switch (libinput_device_config_scroll_get_default_button_lock(device)) {
|
|
|
|
|
case LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_ENABLED: return "enabled";
|
|
|
|
|
case LIBINPUT_CONFIG_SCROLL_BUTTON_LOCK_DISABLED: return "disabled";
|
|
|
|
|
}
|
|
|
|
|
return "<invalid value>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "n/a";
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
static char*
|
|
|
|
|
click_defaults(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t click_methods;
|
|
|
|
|
char *str;
|
|
|
|
|
enum libinput_config_click_method method;
|
|
|
|
|
|
|
|
|
|
click_methods = libinput_device_config_click_get_methods(device);
|
|
|
|
|
if (click_methods == LIBINPUT_CONFIG_CLICK_METHOD_NONE) {
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str, "none");
|
2015-04-15 11:44:54 +10:00
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
method = libinput_device_config_click_get_default_method(device);
|
2015-05-28 19:01:01 -07:00
|
|
|
xasprintf(&str,
|
2015-04-15 11:44:54 +10:00
|
|
|
"%s%s%s%s",
|
|
|
|
|
(method == LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) ? "*" : "",
|
|
|
|
|
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) ? "button-areas " : "",
|
|
|
|
|
(method == LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) ? "*" : "",
|
|
|
|
|
(click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) ? "clickfinger " : "");
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
static const char *
|
|
|
|
|
clickfinger_button_map(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t click_methods = libinput_device_config_click_get_methods(device);
|
|
|
|
|
if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) {
|
|
|
|
|
switch (libinput_device_config_click_get_default_clickfinger_button_map(device)) {
|
|
|
|
|
case LIBINPUT_CONFIG_CLICKFINGER_MAP_LMR: return "left/middle/right";
|
|
|
|
|
case LIBINPUT_CONFIG_CLICKFINGER_MAP_LRM: return "left/right/middle";
|
|
|
|
|
}
|
|
|
|
|
return "<invalid value>";
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
return "n/a";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 13:13:47 +10:00
|
|
|
static char*
|
|
|
|
|
accel_profiles(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t profiles;
|
|
|
|
|
char *str;
|
|
|
|
|
enum libinput_config_accel_profile profile;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device)) {
|
|
|
|
|
xasprintf(&str, "n/a");
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
profiles = libinput_device_config_accel_get_profiles(device);
|
|
|
|
|
if (profiles == LIBINPUT_CONFIG_ACCEL_PROFILE_NONE) {
|
|
|
|
|
xasprintf(&str, "none");
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
profile = libinput_device_config_accel_get_default_profile(device);
|
|
|
|
|
xasprintf(&str,
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
"%s%s %s%s %s%s",
|
2015-08-27 13:13:47 +10:00
|
|
|
(profile == LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT) ? "*" : "",
|
|
|
|
|
(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT) ? "flat" : "",
|
|
|
|
|
(profile == LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) ? "*" : "",
|
Introduce custom acceleration profile
The custom acceleration profile allow the user to define custom
acceleration functions for each movement type per device, giving
full control over accelerations behavior at different speeds.
This commit introduces 2 movement types which corresponds to the
2 profiles currently in use by libinput.
regular filter is Motion type.
constant filter is Fallback type.
This allows possible expansion of new movement types for the
different devices.
The custom pointer acceleration profile gives the user full control over the
acceleration behavior at different speeds.
The user needs to provide a custom acceleration function f(x) where
the x-axis is the device speed and the y-axis is the pointer speed.
The user should take into account the native device dpi and screen dpi in
order to achieve the desired behavior/feel of the acceleration.
The custom acceleration function is defined using n points which are spaced
uniformly along the x-axis, starting from 0 and continuing in constant steps.
There by the points defining the custom function are:
(0 * step, f[0]), (1 * step, f[1]), ..., ((n-1) * step, f[n-1])
where f is a list of n unitless values defining the acceleration
factor for each velocity.
When a velocity value does not lie exactly on those points, a linear
interpolation of the two closest points will be calculated.
When a velocity value is greater than the max point defined, a linear
extrapolation of the two biggest points will be calculated.
Signed-off-by: Yinon Burgansky <51504-Yinon@users.noreply.gitlab.freedesktop.org>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-12-13 00:23:59 +02:00
|
|
|
(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE) ? "adaptive" : "",
|
|
|
|
|
(profile == LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) ? "*" : "",
|
|
|
|
|
(profiles & LIBINPUT_CONFIG_ACCEL_PROFILE_CUSTOM) ? "custom" : "");
|
2015-08-27 13:13:47 +10:00
|
|
|
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 15:03:06 +10:00
|
|
|
static const char *
|
|
|
|
|
dwt_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_dwt_is_available(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_dwt_get_default_enabled(device))
|
|
|
|
|
return "enabled";
|
2020-08-27 01:17:24 -07:00
|
|
|
|
|
|
|
|
return "disabled";
|
2015-07-08 15:03:06 +10:00
|
|
|
}
|
|
|
|
|
|
2022-03-08 01:33:40 +00:00
|
|
|
static const char *
|
|
|
|
|
dwtp_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_dwtp_is_available(device))
|
|
|
|
|
return "n/a";
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_dwtp_get_default_enabled(device))
|
|
|
|
|
return "enabled";
|
|
|
|
|
|
|
|
|
|
return "disabled";
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-30 15:19:37 +10:00
|
|
|
static char *
|
|
|
|
|
rotation_default(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
char *str;
|
|
|
|
|
double angle;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_rotation_is_available(device)) {
|
|
|
|
|
xasprintf(&str, "n/a");
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
angle = libinput_device_config_rotation_get_angle(device);
|
|
|
|
|
xasprintf(&str, "%.1f", angle);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
static char *
|
|
|
|
|
area_rectangle(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_area_has_rectangle(device)) {
|
|
|
|
|
struct libinput_config_area_rectangle rect =
|
|
|
|
|
libinput_device_config_area_get_default_rectangle(device);
|
|
|
|
|
|
|
|
|
|
char *str;
|
|
|
|
|
xasprintf(&str, "(%.2f, %.2f) - (%.2f, %.2f)",
|
|
|
|
|
rect.x1, rect.y1, rect.x2, rect.y2);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return safe_strdup("n/a");
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-27 14:56:09 +10:00
|
|
|
static void
|
|
|
|
|
print_pad_info(struct libinput_device *device)
|
|
|
|
|
{
|
2024-10-22 11:54:45 +10:00
|
|
|
int nbuttons, nrings, nstrips, ndials, ngroups, nmodes;
|
2017-02-24 10:15:23 +10:00
|
|
|
struct libinput_tablet_pad_mode_group *group;
|
2016-05-27 14:56:09 +10:00
|
|
|
|
|
|
|
|
nbuttons = libinput_device_tablet_pad_get_num_buttons(device);
|
|
|
|
|
nrings = libinput_device_tablet_pad_get_num_rings(device);
|
|
|
|
|
nstrips = libinput_device_tablet_pad_get_num_strips(device);
|
2024-10-22 11:54:45 +10:00
|
|
|
ndials = libinput_device_tablet_pad_get_num_dials(device);
|
2017-02-24 10:15:23 +10:00
|
|
|
ngroups = libinput_device_tablet_pad_get_num_mode_groups(device);
|
|
|
|
|
|
2016-05-27 14:56:09 +10:00
|
|
|
printf("Pad:\n");
|
2024-10-22 11:55:09 +10:00
|
|
|
printf(" Rings: %d\n", nrings);
|
|
|
|
|
printf(" Strips: %d\n", nstrips);
|
|
|
|
|
printf(" Dials: %d\n", ndials);
|
|
|
|
|
printf(" Buttons: %d\n", nbuttons);
|
|
|
|
|
printf(" Mode groups: %d\n", ngroups);
|
|
|
|
|
for (int g = 0; g < ngroups; g++) {
|
|
|
|
|
group = libinput_device_tablet_pad_get_mode_group(device, g);
|
|
|
|
|
nmodes = libinput_tablet_pad_mode_group_get_num_modes(group);
|
|
|
|
|
printf(" Group %d:\n", g);
|
|
|
|
|
printf(" Modes: %d\n", nmodes);
|
|
|
|
|
if (nbuttons > 0) {
|
|
|
|
|
printf(" Buttons:");
|
|
|
|
|
for (int b = 0; b < nbuttons; b++) {
|
|
|
|
|
if (libinput_tablet_pad_mode_group_has_button(group, b))
|
|
|
|
|
printf("%s%s%d",
|
|
|
|
|
b == 0 ? " " : ", ",
|
|
|
|
|
libinput_tablet_pad_mode_group_button_is_toggle(group, b) ? "*" : "",
|
|
|
|
|
b);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
if (nrings > 0) {
|
|
|
|
|
printf(" Rings:");
|
|
|
|
|
for (int r = 0; r < nrings; r++) {
|
|
|
|
|
if (libinput_tablet_pad_mode_group_has_ring(group, r))
|
|
|
|
|
printf("%s%d", r == 0 ? " " : ", ", r);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
if (nstrips > 0) {
|
|
|
|
|
printf(" Strips:");
|
|
|
|
|
for (int s = 0; s < nstrips; s++) {
|
|
|
|
|
if (libinput_tablet_pad_mode_group_has_strip(group, s))
|
|
|
|
|
printf("%s%d", s == 0 ? " " : ", ", s);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
if (ndials > 0) {
|
|
|
|
|
printf(" Dials:");
|
|
|
|
|
for (int d = 0; d < ndials; d++) {
|
|
|
|
|
if (libinput_tablet_pad_mode_group_has_dial(group, d))
|
|
|
|
|
printf("%s%d", d == 0 ? " " : ", ", d);
|
|
|
|
|
}
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-05-27 14:56:09 +10:00
|
|
|
}
|
|
|
|
|
|
2025-02-10 14:15:06 +10:00
|
|
|
#define print_aligned(topic, fmt, ...) do {\
|
|
|
|
|
printf("%-25s" fmt "\n", topic ":", __VA_ARGS__); \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
static void
|
|
|
|
|
print_device_notify(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *dev = libinput_event_get_device(ev);
|
|
|
|
|
struct libinput_seat *seat = libinput_device_get_seat(dev);
|
|
|
|
|
struct libinput_device_group *group;
|
2018-06-20 09:54:25 +10:00
|
|
|
struct udev_device *udev_device;
|
2015-04-15 11:44:54 +10:00
|
|
|
double w, h;
|
|
|
|
|
static int next_group_id = 0;
|
|
|
|
|
intptr_t group_id;
|
|
|
|
|
const char *devnode;
|
|
|
|
|
char *str;
|
2025-03-09 19:31:33 +10:00
|
|
|
const char *bustype = "<unknown>";
|
2015-04-15 11:44:54 +10:00
|
|
|
|
|
|
|
|
group = libinput_device_get_device_group(dev);
|
|
|
|
|
group_id = (intptr_t)libinput_device_group_get_user_data(group);
|
|
|
|
|
if (!group_id) {
|
|
|
|
|
group_id = ++next_group_id;
|
|
|
|
|
libinput_device_group_set_user_data(group, (void*)group_id);
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-20 09:54:25 +10:00
|
|
|
udev_device = libinput_device_get_udev_device(dev);
|
|
|
|
|
devnode = udev_device_get_devnode(udev_device);
|
2015-04-15 11:44:54 +10:00
|
|
|
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Device", "%s", libinput_device_get_name(dev));
|
|
|
|
|
print_aligned("Kernel", "%s", devnode);
|
2025-03-09 19:31:33 +10:00
|
|
|
|
|
|
|
|
switch (libinput_device_get_id_bustype(dev)) {
|
|
|
|
|
case BUS_USB: bustype = "usb"; break;
|
|
|
|
|
case BUS_BLUETOOTH: bustype = "bluetooth"; break;
|
|
|
|
|
case BUS_VIRTUAL: bustype = "virtual"; break;
|
|
|
|
|
case BUS_I2C: bustype = "i2c"; break;
|
|
|
|
|
case BUS_HOST: bustype = "host"; break;
|
|
|
|
|
case BUS_I8042: bustype = "serial"; break;
|
|
|
|
|
}
|
|
|
|
|
print_aligned("Id", "%s:%04x:%04x",
|
|
|
|
|
bustype,
|
|
|
|
|
libinput_device_get_id_vendor(dev),
|
|
|
|
|
libinput_device_get_id_product(dev));
|
|
|
|
|
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Group" , "%d", (int)group_id);
|
|
|
|
|
print_aligned("Seat",
|
|
|
|
|
"%s, %s",
|
|
|
|
|
libinput_seat_get_physical_name(seat),
|
|
|
|
|
libinput_seat_get_logical_name(seat));
|
2015-04-15 11:44:54 +10:00
|
|
|
|
2018-06-20 09:54:25 +10:00
|
|
|
udev_device_unref(udev_device);
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
if (libinput_device_get_size(dev, &w, &h) == 0)
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Size", "%.fx%.fmm", w, h);
|
|
|
|
|
|
|
|
|
|
print_aligned("Capabilities", "%s%s%s%s%s%s%s",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_KEYBOARD) ? "keyboard " : "",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_POINTER) ? "pointer " : "",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TOUCH) ? "touch " : "",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL) ? "tablet " : "",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_TABLET_PAD) ? "tablet-pad" : "",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_GESTURE) ? "gesture" : "",
|
|
|
|
|
libinput_device_has_capability(dev, LIBINPUT_DEVICE_CAP_SWITCH) ? "switch" : "");
|
|
|
|
|
|
|
|
|
|
print_aligned("Tap-to-click", "%s", tap_default(dev));
|
|
|
|
|
print_aligned("Tap-and-drag", "%s", drag_default(dev));
|
2025-02-10 14:37:20 +10:00
|
|
|
print_aligned("Tap button map", "%s", tap_button_map(dev));
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Tap drag lock", "%s", draglock_default(dev));
|
|
|
|
|
print_aligned("Left-handed", "%s", left_handed_default(dev));
|
|
|
|
|
print_aligned("Nat.scrolling", "%s", nat_scroll_default(dev));
|
|
|
|
|
print_aligned("Middle emulation", "%s", middle_emulation_default(dev));
|
2015-04-15 11:44:54 +10:00
|
|
|
str = calibration_default(dev);
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Calibration", "%s", str);
|
2015-04-15 11:44:54 +10:00
|
|
|
free(str);
|
|
|
|
|
|
|
|
|
|
str = scroll_defaults(dev);
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Scroll methods", "%s", str);
|
2015-04-15 11:44:54 +10:00
|
|
|
free(str);
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
print_aligned("Scroll button", "%s", scroll_button_default(dev));
|
|
|
|
|
print_aligned("Scroll button lock", "%s", scroll_button_lock_default(dev));
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
str = click_defaults(dev);
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Click methods", "%s", str);
|
2015-04-15 11:44:54 +10:00
|
|
|
free(str);
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
print_aligned("Clickfinger button map", "%s", clickfinger_button_map(dev));
|
|
|
|
|
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Disable-w-typing", "%s", dwt_default(dev));
|
|
|
|
|
print_aligned("Disable-w-trackpointing", "%s", dwtp_default(dev));
|
2015-07-08 15:03:06 +10:00
|
|
|
|
2015-08-27 13:13:47 +10:00
|
|
|
str = accel_profiles(dev);
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Accel profiles", "%s", str);
|
2015-08-27 13:13:47 +10:00
|
|
|
free(str);
|
|
|
|
|
|
2016-05-30 15:19:37 +10:00
|
|
|
str = rotation_default(dev);
|
2025-02-10 14:15:06 +10:00
|
|
|
print_aligned("Rotation", "%s", str);
|
2016-05-30 15:19:37 +10:00
|
|
|
free(str);
|
|
|
|
|
|
2025-02-10 14:37:20 +10:00
|
|
|
str = area_rectangle(dev);
|
|
|
|
|
print_aligned("Area rectangle", "%s", str);
|
|
|
|
|
free(str);
|
|
|
|
|
|
2016-05-27 14:56:09 +10:00
|
|
|
if (libinput_device_has_capability(dev,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_TABLET_PAD))
|
|
|
|
|
print_pad_info(dev);
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 07:53:56 +10:00
|
|
|
static inline void
|
|
|
|
|
usage(void)
|
|
|
|
|
{
|
2017-06-19 17:13:38 +10:00
|
|
|
printf("Usage: libinput list-devices [--help|--version]\n");
|
2017-05-11 13:11:23 +10:00
|
|
|
printf("\n"
|
2017-06-19 17:13:38 +10:00
|
|
|
"--help ...... show this help and exit\n"
|
|
|
|
|
"--version ... show version information and exit\n"
|
|
|
|
|
"\n");
|
2015-04-29 07:53:56 +10:00
|
|
|
}
|
|
|
|
|
|
2015-04-15 11:44:54 +10:00
|
|
|
int
|
2017-05-25 10:12:26 +10:00
|
|
|
main(int argc, char **argv)
|
2015-04-15 11:44:54 +10:00
|
|
|
{
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct libinput_event *ev;
|
2018-06-20 07:56:05 +10:00
|
|
|
bool grab = false;
|
2015-04-15 11:44:54 +10:00
|
|
|
|
2025-02-10 13:42:45 +10:00
|
|
|
while (1) {
|
|
|
|
|
int c;
|
|
|
|
|
int option_index = 0;
|
|
|
|
|
enum {
|
|
|
|
|
OPT_HELP = 1,
|
|
|
|
|
OPT_VERBOSE,
|
|
|
|
|
};
|
|
|
|
|
static struct option opts[] = {
|
|
|
|
|
CONFIGURATION_OPTIONS,
|
|
|
|
|
{ "help", no_argument, 0, 'h' },
|
|
|
|
|
{ "verbose", no_argument, 0, OPT_VERBOSE },
|
|
|
|
|
{ 0, 0, 0, 0}
|
|
|
|
|
};
|
|
|
|
|
c = getopt_long(argc, argv, "h", opts, &option_index);
|
|
|
|
|
if (c == -1)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
switch(c) {
|
|
|
|
|
case '?':
|
|
|
|
|
return EXIT_INVALID_USAGE;
|
|
|
|
|
case 'h':
|
|
|
|
|
case OPT_HELP:
|
2017-05-25 10:12:26 +10:00
|
|
|
usage();
|
2025-02-10 13:42:45 +10:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
default:
|
|
|
|
|
return EXIT_INVALID_USAGE;
|
2020-08-27 01:17:24 -07:00
|
|
|
}
|
2015-04-15 11:44:54 +10:00
|
|
|
}
|
2025-02-10 13:42:45 +10:00
|
|
|
if (optind < argc) {
|
|
|
|
|
const char *devices[32] = {NULL};
|
|
|
|
|
size_t ndevices = 0;
|
|
|
|
|
do {
|
|
|
|
|
if (ndevices >= ARRAY_LENGTH(devices) - 1) {
|
|
|
|
|
usage();
|
|
|
|
|
return EXIT_INVALID_USAGE;
|
|
|
|
|
}
|
|
|
|
|
devices[ndevices++] = argv[optind];
|
|
|
|
|
} while (++optind < argc);
|
|
|
|
|
li = tools_open_backend(BACKEND_DEVICE, devices, false, &grab);
|
|
|
|
|
} else {
|
|
|
|
|
const char *seat[2] = {"seat0", NULL};
|
|
|
|
|
li = tools_open_backend(BACKEND_UDEV, seat, false, &grab);
|
|
|
|
|
}
|
2015-04-15 11:44:54 +10:00
|
|
|
if (!li)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
while ((ev = libinput_get_event(li))) {
|
|
|
|
|
|
|
|
|
|
if (libinput_event_get_type(ev) == LIBINPUT_EVENT_DEVICE_ADDED)
|
|
|
|
|
print_device_notify(ev);
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libinput_unref(li);
|
|
|
|
|
|
2017-05-11 13:11:23 +10:00
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|