2013-11-10 17:55:40 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 Jonas Ådahl
|
2015-05-28 08:23:59 +10:00
|
|
|
* Copyright © 2013-2015 Red Hat, Inc.
|
2013-11-10 17:55:40 +01:00
|
|
|
*
|
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:
|
2013-11-10 17:55:40 +01: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.
|
2013-11-10 17:55:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef LIBINPUT_PRIVATE_H
|
|
|
|
|
#define LIBINPUT_PRIVATE_H
|
|
|
|
|
|
2016-04-27 11:32:02 +10:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2014-09-01 16:47:28 +10:00
|
|
|
#include <errno.h>
|
2015-03-24 13:14:19 +01:00
|
|
|
#include <math.h>
|
2017-12-01 09:31:07 +10:00
|
|
|
#include <stdarg.h>
|
2014-09-01 16:47:28 +10:00
|
|
|
|
2019-05-27 18:21:09 +10:00
|
|
|
#if HAVE_LIBWACOM
|
|
|
|
|
#include <libwacom/libwacom.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-06-03 07:51:37 +10:00
|
|
|
#include "linux/input.h"
|
2014-04-01 21:57:45 +02:00
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
#include "libinput.h"
|
2021-05-27 19:19:49 +02:00
|
|
|
#include "libinput-private-config.h"
|
2013-11-17 11:19:50 +01:00
|
|
|
#include "libinput-util.h"
|
2016-11-30 17:49:52 +10:00
|
|
|
#include "libinput-version.h"
|
2025-04-02 11:40:19 +10:00
|
|
|
#include "util-newtype.h"
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2014-06-06 17:01:05 +02:00
|
|
|
struct libinput_source;
|
|
|
|
|
|
2025-04-02 11:40:19 +10:00
|
|
|
/* The tablet tool pressure offset */
|
|
|
|
|
DECLARE_NEWTYPE(pressure_offset, double);
|
|
|
|
|
|
|
|
|
|
static inline pressure_offset_t
|
|
|
|
|
pressure_offset_from_range(double min, double max, double value)
|
|
|
|
|
{
|
|
|
|
|
return pressure_offset_from_double((value - min)/ (max - min));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline pressure_offset_t
|
|
|
|
|
pressure_offset_from_hundred(double hundred)
|
|
|
|
|
{
|
|
|
|
|
assert(hundred >= 0);
|
|
|
|
|
assert(hundred <= 100);
|
|
|
|
|
return pressure_offset_from_double(hundred/100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline double
|
|
|
|
|
pressure_offset_to_hundred(pressure_offset_t pressure_offset)
|
|
|
|
|
{
|
|
|
|
|
return pressure_offset_as_double(pressure_offset) * 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline pressure_offset_t
|
|
|
|
|
pressure_offset_from_absinfo(const struct input_absinfo *abs, int value)
|
|
|
|
|
{
|
|
|
|
|
return pressure_offset_from_range(abs->minimum, abs->maximum, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
|
pressure_offset_to_absinfo(pressure_offset_t pressure_offset, const struct input_absinfo *abs)
|
|
|
|
|
{
|
|
|
|
|
return (abs->maximum - abs->minimum) * pressure_offset_as_double(pressure_offset) + abs->minimum;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-11 08:35:38 +10:00
|
|
|
/* A coordinate pair in device coordinates */
|
|
|
|
|
struct device_coords {
|
|
|
|
|
int x, y;
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-24 13:14:18 +01:00
|
|
|
/*
|
2015-03-25 11:01:04 +01:00
|
|
|
* A coordinate pair in device coordinates, capable of holding non discrete
|
|
|
|
|
* values, this is necessary e.g. when device coordinates get averaged.
|
2015-03-24 13:14:18 +01:00
|
|
|
*/
|
2015-03-25 11:01:04 +01:00
|
|
|
struct device_float_coords {
|
|
|
|
|
double x, y;
|
2015-03-24 13:14:18 +01:00
|
|
|
};
|
|
|
|
|
|
2015-03-11 08:35:38 +10:00
|
|
|
/* A dpi-normalized coordinate pair */
|
|
|
|
|
struct normalized_coords {
|
|
|
|
|
double x, y;
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-11 11:30:02 +10:00
|
|
|
/* A discrete step pair (mouse wheels) */
|
|
|
|
|
struct discrete_coords {
|
|
|
|
|
int x, y;
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-14 16:28:07 +10:00
|
|
|
/* A pair of coordinates normalized to a [0,1] or [-1, 1] range */
|
|
|
|
|
struct normalized_range_coords {
|
|
|
|
|
double x, y;
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-15 17:07:17 +10:00
|
|
|
/* A [0.0, 1.0] normalized range */
|
|
|
|
|
struct normalized_range {
|
|
|
|
|
double min, max;
|
|
|
|
|
};
|
|
|
|
|
|
2016-08-16 14:48:47 +10:00
|
|
|
/* A pair of angles in degrees */
|
|
|
|
|
struct wheel_angle {
|
2016-10-28 15:08:32 +10:00
|
|
|
double x, y;
|
2016-08-16 14:48:47 +10:00
|
|
|
};
|
|
|
|
|
|
2018-11-22 10:24:54 +10:00
|
|
|
/* A pair of wheel click data for the 120-normalized range */
|
|
|
|
|
struct wheel_v120 {
|
|
|
|
|
int x, y;
|
|
|
|
|
};
|
|
|
|
|
|
2016-02-02 16:15:40 +10:00
|
|
|
/* A pair of angles in degrees */
|
|
|
|
|
struct tilt_degrees {
|
|
|
|
|
double x, y;
|
|
|
|
|
};
|
|
|
|
|
|
2015-12-11 17:40:36 +10:00
|
|
|
/* A threshold with an upper and lower limit */
|
|
|
|
|
struct threshold {
|
|
|
|
|
int upper;
|
|
|
|
|
int lower;
|
|
|
|
|
};
|
|
|
|
|
|
2016-07-15 11:04:04 +10:00
|
|
|
/* A pair of coordinates in mm */
|
|
|
|
|
struct phys_coords {
|
|
|
|
|
double x;
|
|
|
|
|
double y;
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-19 12:02:51 +10:00
|
|
|
/* A rectangle in mm, x/y is the top-left corner */
|
|
|
|
|
struct phys_rect {
|
|
|
|
|
double x, y;
|
|
|
|
|
double w, h;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* A rectangle in device coordinates, x/y is the top-left corner */
|
|
|
|
|
struct device_coord_rect {
|
|
|
|
|
int x, y;
|
|
|
|
|
int w, h;
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-13 13:26:22 +10:00
|
|
|
/* A pair of major/minor in mm */
|
|
|
|
|
struct phys_ellipsis {
|
|
|
|
|
double major;
|
|
|
|
|
double minor;
|
|
|
|
|
};
|
|
|
|
|
|
2013-12-13 11:37:31 +10:00
|
|
|
struct libinput_interface_backend {
|
|
|
|
|
int (*resume)(struct libinput *libinput);
|
|
|
|
|
void (*suspend)(struct libinput *libinput);
|
|
|
|
|
void (*destroy)(struct libinput *libinput);
|
2014-11-19 13:43:59 +10:00
|
|
|
int (*device_change_seat)(struct libinput_device *device,
|
|
|
|
|
const char *seat_name);
|
2013-12-13 11:37:31 +10:00
|
|
|
};
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput {
|
|
|
|
|
int epoll_fd;
|
|
|
|
|
struct list source_destroy_list;
|
2013-11-10 17:55:40 +01:00
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct list seat_list;
|
|
|
|
|
|
2014-06-06 17:01:05 +02:00
|
|
|
struct {
|
|
|
|
|
struct list list;
|
|
|
|
|
struct libinput_source *source;
|
|
|
|
|
int fd;
|
2017-09-19 15:51:09 +10:00
|
|
|
uint64_t next_expiry;
|
2021-12-07 11:11:32 +10:00
|
|
|
|
|
|
|
|
struct ratelimit expiry_in_past_limit;
|
2014-06-06 17:01:05 +02:00
|
|
|
} timer;
|
|
|
|
|
|
2013-11-16 19:32:46 +01:00
|
|
|
struct libinput_event **events;
|
|
|
|
|
size_t events_count;
|
|
|
|
|
size_t events_len;
|
|
|
|
|
size_t events_in;
|
|
|
|
|
size_t events_out;
|
2013-11-17 19:31:34 +01:00
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
struct list tool_list;
|
|
|
|
|
|
2013-11-17 19:31:34 +01:00
|
|
|
const struct libinput_interface *interface;
|
2013-12-13 11:37:31 +10:00
|
|
|
const struct libinput_interface_backend *interface_backend;
|
2014-06-18 19:51:19 +10:00
|
|
|
|
|
|
|
|
libinput_log_handler log_handler;
|
|
|
|
|
enum libinput_log_priority log_priority;
|
2013-11-17 19:31:34 +01:00
|
|
|
void *user_data;
|
2014-06-25 00:06:58 +02:00
|
|
|
int refcount;
|
2015-09-04 12:56:41 +10:00
|
|
|
|
|
|
|
|
struct list device_group_list;
|
2017-04-28 13:44:59 +10:00
|
|
|
|
|
|
|
|
uint64_t last_event_time;
|
2020-04-13 15:12:43 +10:00
|
|
|
uint64_t dispatch_time;
|
2018-05-24 11:46:31 +10:00
|
|
|
|
|
|
|
|
bool quirks_initialized;
|
|
|
|
|
struct quirks_context *quirks;
|
2019-05-27 18:21:09 +10:00
|
|
|
|
|
|
|
|
#if HAVE_LIBWACOM
|
|
|
|
|
struct {
|
|
|
|
|
WacomDeviceDatabase *db;
|
|
|
|
|
size_t refcount;
|
|
|
|
|
} libwacom;
|
|
|
|
|
#endif
|
2013-11-10 17:55:40 +01:00
|
|
|
};
|
|
|
|
|
|
2013-12-13 11:37:31 +10:00
|
|
|
typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct libinput_seat {
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput *libinput;
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct list link;
|
|
|
|
|
struct list devices_list;
|
|
|
|
|
void *user_data;
|
|
|
|
|
int refcount;
|
2014-03-19 23:38:45 +01:00
|
|
|
libinput_seat_destroy_func destroy;
|
|
|
|
|
|
2014-01-15 17:04:00 +10:00
|
|
|
char *physical_name;
|
|
|
|
|
char *logical_name;
|
2014-03-19 23:38:45 +01:00
|
|
|
|
|
|
|
|
uint32_t slot_map;
|
2014-04-01 21:57:45 +02:00
|
|
|
|
|
|
|
|
uint32_t button_count[KEY_CNT];
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
};
|
|
|
|
|
|
2014-01-07 11:42:32 +10:00
|
|
|
struct libinput_device_config_tap {
|
|
|
|
|
int (*count)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
|
2014-07-21 11:07:25 +10:00
|
|
|
enum libinput_config_tap_state enable);
|
|
|
|
|
enum libinput_config_tap_state (*get_enabled)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_tap_state (*get_default)(struct libinput_device *device);
|
2015-06-16 17:02:02 +10:00
|
|
|
|
2016-07-21 11:46:05 +10:00
|
|
|
enum libinput_config_status (*set_map)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_tap_button_map map);
|
|
|
|
|
enum libinput_config_tap_button_map (*get_map)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_tap_button_map (*get_default_map)(struct libinput_device *device);
|
|
|
|
|
|
2016-01-22 17:59:19 +10:00
|
|
|
enum libinput_config_status (*set_drag_enabled)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_drag_state);
|
|
|
|
|
enum libinput_config_drag_state (*get_drag_enabled)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_drag_state (*get_default_drag_enabled)(struct libinput_device *device);
|
|
|
|
|
|
2015-06-16 17:02:02 +10:00
|
|
|
enum libinput_config_status (*set_draglock_enabled)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_drag_lock_state);
|
|
|
|
|
enum libinput_config_drag_lock_state (*get_draglock_enabled)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_drag_lock_state (*get_default_draglock_enabled)(struct libinput_device *device);
|
2014-01-07 11:42:32 +10:00
|
|
|
};
|
|
|
|
|
|
2024-09-06 11:38:35 +10:00
|
|
|
struct libinput_device_config_3fg_drag {
|
|
|
|
|
int (*count)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_3fg_drag_state enable);
|
|
|
|
|
enum libinput_config_3fg_drag_state (*get_enabled)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_3fg_drag_state (*get_default)(struct libinput_device *device);
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2014-08-26 11:41:19 +10:00
|
|
|
struct libinput_device_config_calibration {
|
|
|
|
|
int (*has_matrix)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_matrix)(struct libinput_device *device,
|
|
|
|
|
const float matrix[6]);
|
|
|
|
|
int (*get_matrix)(struct libinput_device *device,
|
|
|
|
|
float matrix[6]);
|
|
|
|
|
int (*get_default_matrix)(struct libinput_device *device,
|
|
|
|
|
float matrix[6]);
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-13 09:00:21 +10:00
|
|
|
struct libinput_device_config_area {
|
|
|
|
|
int (*has_rectangle)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_rectangle)(struct libinput_device *device,
|
|
|
|
|
const struct libinput_config_area_rectangle *rectangle);
|
|
|
|
|
struct libinput_config_area_rectangle (*get_rectangle)(struct libinput_device *device);
|
|
|
|
|
struct libinput_config_area_rectangle (*get_default_rectangle)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-30 16:18:55 +10:00
|
|
|
struct libinput_device_config_send_events {
|
|
|
|
|
uint32_t (*get_modes)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_mode)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_send_events_mode mode);
|
|
|
|
|
enum libinput_config_send_events_mode (*get_mode)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_send_events_mode (*get_default_mode)(struct libinput_device *device);
|
2014-01-07 11:42:32 +10:00
|
|
|
};
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* Custom acceleration function min number of points
|
|
|
|
|
* At least 2 points are required for linear interpolation
|
|
|
|
|
*/
|
|
|
|
|
#define LIBINPUT_ACCEL_NPOINTS_MIN 2
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom acceleration function max number of points
|
|
|
|
|
* an arbitrary limit of sample points
|
|
|
|
|
* it should be more than enough for everyone
|
|
|
|
|
*/
|
|
|
|
|
#define LIBINPUT_ACCEL_NPOINTS_MAX 64
|
|
|
|
|
|
2023-01-27 01:23:35 +02:00
|
|
|
/**
|
|
|
|
|
* Custom acceleration function min point value
|
|
|
|
|
*/
|
|
|
|
|
#define LIBINPUT_ACCEL_POINT_MIN_VALUE 0
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Custom acceleration function max point value
|
|
|
|
|
*/
|
|
|
|
|
#define LIBINPUT_ACCEL_POINT_MAX_VALUE 10000
|
|
|
|
|
|
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
|
|
|
/**
|
|
|
|
|
* Custom acceleration function max step size
|
|
|
|
|
*/
|
|
|
|
|
#define LIBINPUT_ACCEL_STEP_MAX 10000
|
|
|
|
|
|
|
|
|
|
struct libinput_config_accel_custom_func {
|
|
|
|
|
double step;
|
|
|
|
|
size_t npoints;
|
|
|
|
|
double points[LIBINPUT_ACCEL_NPOINTS_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct libinput_config_accel {
|
|
|
|
|
enum libinput_config_accel_profile profile;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct libinput_config_accel_custom_func *fallback;
|
|
|
|
|
struct libinput_config_accel_custom_func *motion;
|
2023-02-18 21:12:13 +02:00
|
|
|
struct libinput_config_accel_custom_func *scroll;
|
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
|
|
|
} custom;
|
|
|
|
|
};
|
|
|
|
|
|
2014-05-15 15:46:19 +10:00
|
|
|
struct libinput_device_config_accel {
|
|
|
|
|
int (*available)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_speed)(struct libinput_device *device,
|
|
|
|
|
double speed);
|
|
|
|
|
double (*get_speed)(struct libinput_device *device);
|
|
|
|
|
double (*get_default_speed)(struct libinput_device *device);
|
2015-08-27 13:13:47 +10:00
|
|
|
|
|
|
|
|
uint32_t (*get_profiles)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_profile)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_accel_profile);
|
|
|
|
|
enum libinput_config_accel_profile (*get_profile)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_accel_profile (*get_default_profile)(struct libinput_device *device);
|
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
|
|
|
enum libinput_config_status (*set_accel_config)(struct libinput_device *device,
|
|
|
|
|
struct libinput_config_accel *accel_config);
|
2014-05-15 15:46:19 +10:00
|
|
|
};
|
|
|
|
|
|
2014-09-18 15:10:19 +10:00
|
|
|
struct libinput_device_config_natural_scroll {
|
|
|
|
|
int (*has)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
|
|
|
|
|
int enabled);
|
|
|
|
|
int (*get_enabled)(struct libinput_device *device);
|
|
|
|
|
int (*get_default_enabled)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-22 16:48:41 +10:00
|
|
|
struct libinput_device_config_left_handed {
|
|
|
|
|
int (*has)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set)(struct libinput_device *device, int left_handed);
|
|
|
|
|
int (*get)(struct libinput_device *device);
|
|
|
|
|
int (*get_default)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
struct libinput_device_config_scroll_method {
|
|
|
|
|
uint32_t (*get_methods)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_method)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_scroll_method method);
|
|
|
|
|
enum libinput_config_scroll_method (*get_method)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_scroll_method (*get_default_method)(struct libinput_device *device);
|
2014-11-03 14:52:59 +01:00
|
|
|
enum libinput_config_status (*set_button)(struct libinput_device *device,
|
|
|
|
|
uint32_t button);
|
|
|
|
|
uint32_t (*get_button)(struct libinput_device *device);
|
|
|
|
|
uint32_t (*get_default_button)(struct libinput_device *device);
|
2019-03-20 10:56:51 +10:00
|
|
|
enum libinput_config_status (*set_button_lock)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_scroll_button_lock_state);
|
|
|
|
|
enum libinput_config_scroll_button_lock_state (*get_button_lock)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_scroll_button_lock_state (*get_default_button_lock)(struct libinput_device *device);
|
2014-11-03 14:52:59 +01:00
|
|
|
};
|
|
|
|
|
|
2014-12-03 14:45:26 +10:00
|
|
|
struct libinput_device_config_click_method {
|
|
|
|
|
uint32_t (*get_methods)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_method)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_click_method method);
|
|
|
|
|
enum libinput_config_click_method (*get_method)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_click_method (*get_default_method)(struct libinput_device *device);
|
2024-04-09 18:46:42 -03:00
|
|
|
enum libinput_config_status (*set_clickfinger_map)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_clickfinger_button_map map);
|
|
|
|
|
enum libinput_config_clickfinger_button_map (*get_clickfinger_map)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_clickfinger_button_map (*get_default_clickfinger_map)(struct libinput_device *device);
|
2014-12-03 14:45:26 +10:00
|
|
|
};
|
|
|
|
|
|
2015-04-14 12:08:33 +10:00
|
|
|
struct libinput_device_config_middle_emulation {
|
|
|
|
|
int (*available)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set)(
|
|
|
|
|
struct libinput_device *device,
|
|
|
|
|
enum libinput_config_middle_emulation_state);
|
|
|
|
|
enum libinput_config_middle_emulation_state (*get)(
|
|
|
|
|
struct libinput_device *device);
|
|
|
|
|
enum libinput_config_middle_emulation_state (*get_default)(
|
|
|
|
|
struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2015-07-08 15:03:06 +10:00
|
|
|
struct libinput_device_config_dwt {
|
|
|
|
|
int (*is_available)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(
|
|
|
|
|
struct libinput_device *device,
|
|
|
|
|
enum libinput_config_dwt_state enable);
|
|
|
|
|
enum libinput_config_dwt_state (*get_enabled)(
|
|
|
|
|
struct libinput_device *device);
|
|
|
|
|
enum libinput_config_dwt_state (*get_default_enabled)(
|
|
|
|
|
struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2022-03-08 01:33:40 +00:00
|
|
|
struct libinput_device_config_dwtp {
|
|
|
|
|
int (*is_available)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(
|
|
|
|
|
struct libinput_device *device,
|
|
|
|
|
enum libinput_config_dwtp_state enable);
|
|
|
|
|
enum libinput_config_dwtp_state (*get_enabled)(
|
|
|
|
|
struct libinput_device *device);
|
|
|
|
|
enum libinput_config_dwtp_state (*get_default_enabled)(
|
|
|
|
|
struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-03 13:52:53 +10:00
|
|
|
struct libinput_device_config_rotation {
|
|
|
|
|
int (*is_available)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_angle)(
|
|
|
|
|
struct libinput_device *device,
|
|
|
|
|
unsigned int degrees_cw);
|
|
|
|
|
unsigned int (*get_angle)(struct libinput_device *device);
|
|
|
|
|
unsigned int (*get_default_angle)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-27 19:19:49 +02:00
|
|
|
struct libinput_device_config_gesture {
|
|
|
|
|
enum libinput_config_status (*set_hold_enabled)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_hold_state enabled);
|
|
|
|
|
enum libinput_config_hold_state (*get_hold_enabled)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_hold_state (*get_hold_default)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-07 11:42:32 +10:00
|
|
|
struct libinput_device_config {
|
|
|
|
|
struct libinput_device_config_tap *tap;
|
2014-08-26 11:41:19 +10:00
|
|
|
struct libinput_device_config_calibration *calibration;
|
2024-06-13 09:00:21 +10:00
|
|
|
struct libinput_device_config_area *area;
|
2014-01-30 16:18:55 +10:00
|
|
|
struct libinput_device_config_send_events *sendevents;
|
2014-05-15 15:46:19 +10:00
|
|
|
struct libinput_device_config_accel *accel;
|
2014-09-18 15:10:19 +10:00
|
|
|
struct libinput_device_config_natural_scroll *natural_scroll;
|
2014-09-22 16:48:41 +10:00
|
|
|
struct libinput_device_config_left_handed *left_handed;
|
2014-11-19 12:16:28 +10:00
|
|
|
struct libinput_device_config_scroll_method *scroll_method;
|
2014-12-03 14:45:26 +10:00
|
|
|
struct libinput_device_config_click_method *click_method;
|
2015-04-14 12:08:33 +10:00
|
|
|
struct libinput_device_config_middle_emulation *middle_emulation;
|
2015-07-08 15:03:06 +10:00
|
|
|
struct libinput_device_config_dwt *dwt;
|
2022-03-08 01:33:40 +00:00
|
|
|
struct libinput_device_config_dwtp *dwtp;
|
2016-05-03 13:52:53 +10:00
|
|
|
struct libinput_device_config_rotation *rotation;
|
2021-05-27 19:19:49 +02:00
|
|
|
struct libinput_device_config_gesture *gesture;
|
2024-09-06 11:38:35 +10:00
|
|
|
struct libinput_device_config_3fg_drag *drag_3fg;
|
2014-01-07 11:42:32 +10:00
|
|
|
};
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
struct libinput_device_group {
|
|
|
|
|
int refcount;
|
|
|
|
|
void *user_data;
|
2015-02-09 18:45:45 -05:00
|
|
|
char *identifier; /* unique identifier or NULL for singletons */
|
2015-09-04 12:56:41 +10:00
|
|
|
|
|
|
|
|
struct list link;
|
2015-02-05 13:39:04 +10:00
|
|
|
};
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct libinput_device {
|
|
|
|
|
struct libinput_seat *seat;
|
2015-02-05 13:39:04 +10:00
|
|
|
struct libinput_device_group *group;
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct list link;
|
2014-09-28 13:21:02 +02:00
|
|
|
struct list event_listeners;
|
2013-11-17 19:31:34 +01:00
|
|
|
void *user_data;
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
int refcount;
|
2014-01-07 11:42:32 +10:00
|
|
|
struct libinput_device_config config;
|
2014-06-10 16:44:02 -04:00
|
|
|
};
|
|
|
|
|
|
2015-12-14 11:51:17 +10:00
|
|
|
enum libinput_tablet_tool_axis {
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_X = 1,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_Y = 2,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE = 3,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE = 4,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_X = 5,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y = 6,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z = 7,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_SLIDER = 8,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL = 9,
|
2018-09-13 13:26:22 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MAJOR = 10,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR = 11,
|
2015-12-14 11:51:17 +10:00
|
|
|
};
|
|
|
|
|
|
2018-09-13 13:26:22 +10:00
|
|
|
#define LIBINPUT_TABLET_TOOL_AXIS_MAX LIBINPUT_TABLET_TOOL_AXIS_SIZE_MINOR
|
2015-12-14 11:51:17 +10:00
|
|
|
|
2017-03-01 15:59:44 +10:00
|
|
|
struct tablet_axes {
|
|
|
|
|
struct device_coords point;
|
|
|
|
|
struct normalized_coords delta;
|
|
|
|
|
double distance;
|
|
|
|
|
double pressure;
|
|
|
|
|
struct tilt_degrees tilt;
|
|
|
|
|
double rotation;
|
|
|
|
|
double slider;
|
|
|
|
|
double wheel;
|
|
|
|
|
int wheel_discrete;
|
2018-09-13 13:26:22 +10:00
|
|
|
struct phys_ellipsis size;
|
2017-03-01 15:59:44 +10:00
|
|
|
};
|
|
|
|
|
|
2023-06-13 13:12:53 +10:00
|
|
|
enum pressure_heuristic_state {
|
|
|
|
|
PRESSURE_HEURISTIC_STATE_PROXIN1, /** First proximity in event */
|
|
|
|
|
PRESSURE_HEURISTIC_STATE_PROXIN2, /** Second proximity in event */
|
|
|
|
|
PRESSURE_HEURISTIC_STATE_DECIDE, /** Decide on offset now */
|
|
|
|
|
PRESSURE_HEURISTIC_STATE_DONE, /** Decision's been made, live with it */
|
|
|
|
|
};
|
|
|
|
|
|
2024-01-15 17:07:17 +10:00
|
|
|
struct libinput_tablet_tool_config_pressure_range {
|
|
|
|
|
int (*is_available)(struct libinput_tablet_tool *tool);
|
|
|
|
|
enum libinput_config_status (*set)(struct libinput_tablet_tool *tool, double min, double max);
|
|
|
|
|
void (*get)(struct libinput_tablet_tool *tool, double *min, double *max);
|
|
|
|
|
void (*get_default)(struct libinput_tablet_tool *tool, double *min, double *max);
|
|
|
|
|
};
|
|
|
|
|
|
2025-02-17 15:29:26 +10:00
|
|
|
struct libinput_tablet_tool_pressure_threshold {
|
|
|
|
|
unsigned int tablet_id;
|
|
|
|
|
|
|
|
|
|
/* The configured axis we actually work with */
|
|
|
|
|
struct input_absinfo abs_pressure;
|
|
|
|
|
struct threshold threshold; /* in device coordinates */
|
2025-04-02 11:40:19 +10:00
|
|
|
pressure_offset_t offset;
|
2025-02-17 15:29:26 +10:00
|
|
|
bool has_offset;
|
|
|
|
|
|
|
|
|
|
/* This gives us per-tablet heuristic state which is arguably
|
|
|
|
|
* wrong but >99% of users have one tablet and it's easier to
|
|
|
|
|
* implement it this way */
|
|
|
|
|
enum pressure_heuristic_state heuristic_state;
|
|
|
|
|
};
|
|
|
|
|
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool {
|
2014-06-10 16:44:02 -04:00
|
|
|
struct list link;
|
|
|
|
|
uint32_t serial;
|
2015-02-19 14:56:34 +10:00
|
|
|
uint32_t tool_id;
|
2015-11-16 15:39:07 +10:00
|
|
|
enum libinput_tablet_tool_type type;
|
2015-11-16 15:36:30 +10:00
|
|
|
unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_TOOL_AXIS_MAX + 1)];
|
2015-02-18 13:53:31 +10:00
|
|
|
unsigned char buttons[NCHARS(KEY_MAX) + 1];
|
2014-06-10 16:44:02 -04:00
|
|
|
int refcount;
|
2014-08-05 17:49:39 -04:00
|
|
|
void *user_data;
|
2015-12-01 11:07:57 +10:00
|
|
|
|
2020-09-09 12:54:32 +10:00
|
|
|
struct {
|
2025-02-17 15:29:26 +10:00
|
|
|
/* We're assuming that the *configured* pressure range is per
|
|
|
|
|
* tool, not per tablet. The *adjusted* thresholds are then
|
|
|
|
|
* per-tablet. */
|
|
|
|
|
struct normalized_range range;
|
2024-01-15 17:07:17 +10:00
|
|
|
struct normalized_range wanted_range;
|
|
|
|
|
bool has_configured_range;
|
|
|
|
|
|
2025-04-02 11:40:19 +10:00
|
|
|
struct libinput_tablet_tool_pressure_threshold threshold;
|
2020-09-09 12:54:32 +10:00
|
|
|
} pressure;
|
2024-01-15 17:07:17 +10:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct libinput_tablet_tool_config_pressure_range pressure_range;
|
|
|
|
|
} config;
|
2013-11-17 11:19:50 +01:00
|
|
|
};
|
|
|
|
|
|
2016-05-26 10:05:10 +10:00
|
|
|
struct libinput_tablet_pad_mode_group {
|
2016-06-02 15:35:43 +10:00
|
|
|
struct libinput_device *device;
|
2016-05-26 10:05:10 +10:00
|
|
|
struct list link;
|
|
|
|
|
int refcount;
|
|
|
|
|
void *user_data;
|
2016-06-02 15:35:43 +10:00
|
|
|
|
|
|
|
|
unsigned int index;
|
|
|
|
|
unsigned int num_modes;
|
|
|
|
|
unsigned int current_mode;
|
|
|
|
|
|
|
|
|
|
uint32_t button_mask;
|
|
|
|
|
uint32_t ring_mask;
|
|
|
|
|
uint32_t strip_mask;
|
2024-01-30 14:43:59 +10:00
|
|
|
uint32_t dial_mask;
|
2016-06-02 15:35:43 +10:00
|
|
|
|
|
|
|
|
uint32_t toggle_button_mask;
|
|
|
|
|
|
|
|
|
|
void (*destroy)(struct libinput_tablet_pad_mode_group *group);
|
2016-05-26 10:05:10 +10:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:03 +02:00
|
|
|
struct libinput_event {
|
|
|
|
|
enum libinput_event_type type;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:02 +02:00
|
|
|
struct libinput_event_listener {
|
|
|
|
|
struct list link;
|
|
|
|
|
void (*notify_func)(uint64_t time, struct libinput_event *ev, void *notify_func_data);
|
|
|
|
|
void *notify_func_data;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
typedef void (*libinput_source_dispatch_t)(void *data);
|
|
|
|
|
|
2014-06-18 19:51:19 +10:00
|
|
|
#define log_debug(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
|
|
|
|
|
#define log_info(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
|
|
|
|
|
#define log_error(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
|
|
|
|
|
#define log_bug_kernel(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
|
2014-09-17 15:11:41 +10:00
|
|
|
#define log_bug_libinput(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__)
|
|
|
|
|
#define log_bug_client(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
|
2014-02-12 14:20:18 +10:00
|
|
|
|
2015-08-19 15:21:53 +10:00
|
|
|
#define log_debug_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
|
|
|
|
|
#define log_info_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
|
|
|
|
|
#define log_error_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
|
|
|
|
|
#define log_bug_kernel_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
|
|
|
|
|
#define log_bug_libinput_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__)
|
|
|
|
|
#define log_bug_client_ratelimit(li_, r_, ...) log_msg_ratelimit((li_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
|
|
|
|
|
|
2019-01-12 02:15:20 +03:00
|
|
|
static inline bool
|
|
|
|
|
is_logged(const struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority)
|
|
|
|
|
{
|
|
|
|
|
return libinput->log_handler &&
|
|
|
|
|
libinput->log_priority <= priority;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-19 15:21:53 +10:00
|
|
|
void
|
|
|
|
|
log_msg_ratelimit(struct libinput *libinput,
|
|
|
|
|
struct ratelimit *ratelimit,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format, ...)
|
|
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(4, 5);
|
|
|
|
|
|
2014-02-12 14:20:18 +10:00
|
|
|
void
|
2014-06-18 19:51:19 +10:00
|
|
|
log_msg(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority,
|
2015-07-21 11:01:39 +10:00
|
|
|
const char *format, ...)
|
|
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(3, 4);
|
2014-06-18 19:51:19 +10:00
|
|
|
|
2014-06-10 15:08:03 +02:00
|
|
|
void
|
2014-06-18 19:51:19 +10:00
|
|
|
log_msg_va(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority,
|
2014-06-10 15:08:03 +02:00
|
|
|
const char *format,
|
2015-07-21 11:01:39 +10:00
|
|
|
va_list args)
|
|
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
|
2014-02-12 14:20:18 +10:00
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
int
|
|
|
|
|
libinput_init(struct libinput *libinput,
|
|
|
|
|
const struct libinput_interface *interface,
|
2013-12-13 11:37:31 +10:00
|
|
|
const struct libinput_interface_backend *interface_backend,
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
void *user_data);
|
|
|
|
|
|
2018-05-24 11:46:31 +10:00
|
|
|
void
|
|
|
|
|
libinput_init_quirks(struct libinput *libinput);
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput_source *
|
|
|
|
|
libinput_add_fd(struct libinput *libinput,
|
|
|
|
|
int fd,
|
|
|
|
|
libinput_source_dispatch_t dispatch,
|
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_remove_source(struct libinput *libinput,
|
|
|
|
|
struct libinput_source *source);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
int
|
|
|
|
|
open_restricted(struct libinput *libinput,
|
|
|
|
|
const char *path, int flags);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
close_restricted(struct libinput *libinput, int fd);
|
|
|
|
|
|
2015-07-27 16:08:04 +08:00
|
|
|
bool
|
|
|
|
|
ignore_litest_test_suite_device(struct udev_device *device);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
void
|
|
|
|
|
libinput_seat_init(struct libinput_seat *seat,
|
|
|
|
|
struct libinput *libinput,
|
2014-01-15 17:04:00 +10:00
|
|
|
const char *physical_name,
|
|
|
|
|
const char *logical_name,
|
2013-12-13 11:37:31 +10:00
|
|
|
libinput_seat_destroy_func destroy);
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_init(struct libinput_device *device,
|
|
|
|
|
struct libinput_seat *seat);
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
struct libinput_device_group *
|
2015-09-04 12:56:41 +10:00
|
|
|
libinput_device_group_create(struct libinput *libinput,
|
|
|
|
|
const char *identifier);
|
|
|
|
|
|
|
|
|
|
struct libinput_device_group *
|
|
|
|
|
libinput_device_group_find_group(struct libinput *libinput,
|
|
|
|
|
const char *identifier);
|
2015-02-05 13:39:04 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_set_device_group(struct libinput_device *device,
|
|
|
|
|
struct libinput_device_group *group);
|
|
|
|
|
|
2017-01-25 15:19:50 +10:00
|
|
|
void
|
|
|
|
|
libinput_device_init_event_listener(struct libinput_event_listener *listener);
|
|
|
|
|
|
2014-09-28 13:21:02 +02:00
|
|
|
void
|
|
|
|
|
libinput_device_add_event_listener(struct libinput_device *device,
|
|
|
|
|
struct libinput_event_listener *listener,
|
|
|
|
|
void (*notify_func)(
|
|
|
|
|
uint64_t time,
|
|
|
|
|
struct libinput_event *event,
|
|
|
|
|
void *notify_func_data),
|
|
|
|
|
void *notify_func_data);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_remove_event_listener(struct libinput_event_listener *listener);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
void
|
|
|
|
|
notify_added_device(struct libinput_device *device);
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
void
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
notify_removed_device(struct libinput_device *device);
|
2013-11-17 11:19:50 +01:00
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
void
|
|
|
|
|
keyboard_notify_key(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2013-11-10 17:55:40 +01:00
|
|
|
uint32_t key,
|
2014-06-17 07:55:35 +10:00
|
|
|
enum libinput_key_state state);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_motion(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2015-03-11 10:43:18 +10:00
|
|
|
const struct normalized_coords *delta,
|
2015-06-26 09:07:24 +10:00
|
|
|
const struct device_float_coords *raw);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_motion_absolute(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2015-03-11 10:43:18 +10:00
|
|
|
const struct device_coords *point);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_button(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2013-11-10 17:55:40 +01:00
|
|
|
int32_t button,
|
2014-06-03 20:08:02 -04:00
|
|
|
enum libinput_button_state state);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
2018-11-22 10:24:54 +10:00
|
|
|
pointer_notify_axis_finger(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
uint32_t axes,
|
|
|
|
|
const struct normalized_coords *delta);
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_axis_continuous(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
uint32_t axes,
|
|
|
|
|
const struct normalized_coords *delta);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_axis_legacy_wheel(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
uint32_t axes,
|
|
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct discrete_coords *discrete);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_axis_wheel(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
uint32_t axes,
|
|
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct wheel_v120 *v120);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
2014-02-19 21:39:26 +01:00
|
|
|
touch_notify_touch_down(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-02-19 21:39:26 +01:00
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot,
|
2015-03-11 10:48:54 +10:00
|
|
|
const struct device_coords *point);
|
2014-02-19 21:39:26 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_notify_touch_motion(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-02-19 21:39:26 +01:00
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot,
|
2015-03-11 10:48:54 +10:00
|
|
|
const struct device_coords *point);
|
2014-02-19 21:39:26 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_notify_touch_up(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-02-19 21:39:26 +01:00
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2018-07-13 16:08:54 +10:00
|
|
|
void
|
|
|
|
|
touch_notify_touch_cancel(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot);
|
|
|
|
|
|
2016-01-04 10:55:37 +10:00
|
|
|
void
|
|
|
|
|
touch_notify_frame(struct libinput_device *device,
|
|
|
|
|
uint64_t time);
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
void
|
|
|
|
|
gesture_notify_swipe(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int finger_count,
|
|
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct normalized_coords *unaccel);
|
|
|
|
|
|
2015-04-29 13:19:51 +02:00
|
|
|
void
|
|
|
|
|
gesture_notify_swipe_end(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int finger_count,
|
2021-04-12 09:18:39 +02:00
|
|
|
bool cancelled);
|
2015-04-29 13:19:51 +02:00
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
void
|
|
|
|
|
gesture_notify_pinch(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_event_type type,
|
2016-01-07 13:57:03 +10:00
|
|
|
int finger_count,
|
2015-03-04 15:24:04 +01:00
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct normalized_coords *unaccel,
|
|
|
|
|
double scale,
|
|
|
|
|
double angle);
|
|
|
|
|
|
2015-04-29 13:19:51 +02:00
|
|
|
void
|
|
|
|
|
gesture_notify_pinch_end(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
2016-01-07 13:57:03 +10:00
|
|
|
int finger_count,
|
2015-05-22 10:58:56 +10:00
|
|
|
double scale,
|
2021-04-12 09:18:39 +02:00
|
|
|
bool cancelled);
|
2015-04-29 13:19:51 +02:00
|
|
|
|
2021-05-27 19:19:38 +02:00
|
|
|
void
|
2024-09-13 11:58:26 +10:00
|
|
|
gesture_notify_hold_begin(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int finger_count);
|
2021-05-27 19:19:38 +02:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gesture_notify_hold_end(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int finger_count,
|
|
|
|
|
bool cancelled);
|
|
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
void
|
|
|
|
|
tablet_notify_axis(struct libinput_device *device,
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state,
|
2014-06-05 23:20:36 -04:00
|
|
|
unsigned char *changed_axes,
|
2024-06-13 10:31:37 +10:00
|
|
|
const struct tablet_axes *axes,
|
|
|
|
|
const struct input_absinfo *x,
|
|
|
|
|
const struct input_absinfo *y);
|
2014-06-05 23:20:36 -04:00
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
void
|
2015-02-16 22:48:42 -05:00
|
|
|
tablet_notify_proximity(struct libinput_device *device,
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:41:48 +10:00
|
|
|
enum libinput_tablet_tool_proximity_state state,
|
2015-02-16 22:48:44 -05:00
|
|
|
unsigned char *changed_axes,
|
2024-06-13 10:31:37 +10:00
|
|
|
const struct tablet_axes *axes,
|
|
|
|
|
const struct input_absinfo *x,
|
|
|
|
|
const struct input_absinfo *y);
|
2014-06-06 16:35:33 -04:00
|
|
|
|
2015-11-11 13:39:43 +10:00
|
|
|
void
|
|
|
|
|
tablet_notify_tip(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state,
|
2015-12-15 08:39:56 +10:00
|
|
|
unsigned char *changed_axes,
|
2024-06-13 10:31:37 +10:00
|
|
|
const struct tablet_axes *axes,
|
|
|
|
|
const struct input_absinfo *x,
|
|
|
|
|
const struct input_absinfo *y);
|
2015-11-11 13:39:43 +10:00
|
|
|
|
2013-12-20 10:15:00 +10:00
|
|
|
void
|
2014-06-10 23:14:41 -04:00
|
|
|
tablet_notify_button(struct libinput_device *device,
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state,
|
2016-01-06 16:16:46 +10:00
|
|
|
const struct tablet_axes *axes,
|
2014-06-10 23:14:41 -04:00
|
|
|
int32_t button,
|
2024-06-13 10:31:37 +10:00
|
|
|
enum libinput_button_state state,
|
|
|
|
|
const struct input_absinfo *x,
|
|
|
|
|
const struct input_absinfo *y);
|
2014-09-01 16:47:28 +10:00
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
void
|
|
|
|
|
tablet_pad_notify_button(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int32_t button,
|
2016-06-02 15:35:43 +10:00
|
|
|
enum libinput_button_state state,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group);
|
2016-01-21 12:35:11 +10:00
|
|
|
void
|
2024-01-30 14:43:59 +10:00
|
|
|
tablet_pad_notify_dial(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
double value,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group);
|
|
|
|
|
|
|
|
|
|
void
|
2016-01-21 12:35:11 +10:00
|
|
|
tablet_pad_notify_ring(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
double value,
|
2016-06-02 15:35:43 +10:00
|
|
|
enum libinput_tablet_pad_ring_axis_source source,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group);
|
2016-01-21 12:35:11 +10:00
|
|
|
void
|
|
|
|
|
tablet_pad_notify_strip(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
double value,
|
2016-06-02 15:35:43 +10:00
|
|
|
enum libinput_tablet_pad_strip_axis_source source,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group);
|
2017-01-20 16:54:13 +11:00
|
|
|
void
|
2019-01-17 11:08:27 +10:00
|
|
|
tablet_pad_notify_key(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int32_t key,
|
|
|
|
|
enum libinput_key_state state);
|
|
|
|
|
void
|
2017-01-20 16:54:13 +11:00
|
|
|
switch_notify_toggle(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_switch sw,
|
|
|
|
|
enum libinput_switch_state state);
|
2016-01-21 12:35:11 +10:00
|
|
|
|
2014-09-01 16:47:28 +10:00
|
|
|
static inline uint64_t
|
|
|
|
|
libinput_now(struct libinput *libinput)
|
|
|
|
|
{
|
2024-10-21 11:07:14 +10:00
|
|
|
uint64_t now;
|
|
|
|
|
int rc = now_in_us(&now);
|
2014-09-01 16:47:28 +10:00
|
|
|
|
2024-10-21 11:07:14 +10:00
|
|
|
if (rc < 0) {
|
|
|
|
|
log_error(libinput, "clock_gettime failed: %s\n", strerror(-rc));
|
2014-09-01 16:47:28 +10:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-21 11:07:14 +10:00
|
|
|
return now;
|
2014-09-01 16:47:28 +10:00
|
|
|
}
|
2015-03-24 13:14:18 +01:00
|
|
|
|
2015-03-25 11:01:04 +01:00
|
|
|
static inline struct device_float_coords
|
2018-06-20 14:09:58 +03:00
|
|
|
device_delta(const struct device_coords a, const struct device_coords b)
|
2015-03-24 13:14:18 +01:00
|
|
|
{
|
2015-03-25 11:01:04 +01:00
|
|
|
struct device_float_coords delta;
|
2015-03-24 13:14:18 +01:00
|
|
|
|
2015-03-25 11:01:04 +01:00
|
|
|
delta.x = a.x - b.x;
|
|
|
|
|
delta.y = a.y - b.y;
|
2015-03-24 13:14:18 +01:00
|
|
|
|
|
|
|
|
return delta;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-05 12:44:13 +01:00
|
|
|
static inline struct device_float_coords
|
2018-06-20 14:09:58 +03:00
|
|
|
device_average(const struct device_coords a, const struct device_coords b)
|
2015-03-05 12:44:13 +01:00
|
|
|
{
|
|
|
|
|
struct device_float_coords average;
|
|
|
|
|
|
|
|
|
|
average.x = (a.x + b.x) / 2.0;
|
|
|
|
|
average.y = (a.y + b.y) / 2.0;
|
|
|
|
|
|
|
|
|
|
return average;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline struct device_float_coords
|
2018-06-20 14:09:58 +03:00
|
|
|
device_float_delta(const struct device_float_coords a, const struct device_float_coords b)
|
2015-03-05 12:44:13 +01:00
|
|
|
{
|
|
|
|
|
struct device_float_coords delta;
|
|
|
|
|
|
|
|
|
|
delta.x = a.x - b.x;
|
|
|
|
|
delta.y = a.y - b.y;
|
|
|
|
|
|
|
|
|
|
return delta;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline struct device_float_coords
|
2018-06-20 14:09:58 +03:00
|
|
|
device_float_average(const struct device_float_coords a, const struct device_float_coords b)
|
2015-03-05 12:44:13 +01:00
|
|
|
{
|
|
|
|
|
struct device_float_coords average;
|
|
|
|
|
|
|
|
|
|
average.x = (a.x + b.x) / 2.0;
|
|
|
|
|
average.y = (a.y + b.y) / 2.0;
|
|
|
|
|
|
|
|
|
|
return average;
|
|
|
|
|
}
|
|
|
|
|
|
filter: change the filter functions to take raw device coordinates
We used to normalize all deltas to equivalents of a 1000dpi mouse before
passing it into the acceleration functions. This has a bunch of drawbacks, not
least that we already have to un-normalize back into device units for a few
devices already (trackpoints, tablet, low-dpi mice).
Switch the filter code over to use device units, relying on the dpi set
earlier during filter creation to convert to normalized. To make things easy,
the output of the filter code is still normalized data, i.e. data ready to be
handed to the libinput caller.
No effective functional changes. For touchpads, we still send normalized
coordinates (for now, anyway). For the various filter methods, we either drop
the places where we unnormalized before or we normalize where needed.
Two possible changes: for trackpoints and low-dpi mice we had a max dpi factor
of 1.0 before - now we don't anymore. This was only the case if a low-dpi
mouse had more than 1000dpi (never true) or a trackpoint had a const accel
lower than 1.0 (yeah, whatever).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-15 08:36:22 +10:00
|
|
|
static inline bool
|
2018-06-20 14:09:58 +03:00
|
|
|
device_float_is_zero(const struct device_float_coords coords)
|
filter: change the filter functions to take raw device coordinates
We used to normalize all deltas to equivalents of a 1000dpi mouse before
passing it into the acceleration functions. This has a bunch of drawbacks, not
least that we already have to un-normalize back into device units for a few
devices already (trackpoints, tablet, low-dpi mice).
Switch the filter code over to use device units, relying on the dpi set
earlier during filter creation to convert to normalized. To make things easy,
the output of the filter code is still normalized data, i.e. data ready to be
handed to the libinput caller.
No effective functional changes. For touchpads, we still send normalized
coordinates (for now, anyway). For the various filter methods, we either drop
the places where we unnormalized before or we normalize where needed.
Two possible changes: for trackpoints and low-dpi mice we had a max dpi factor
of 1.0 before - now we don't anymore. This was only the case if a low-dpi
mouse had more than 1000dpi (never true) or a trackpoint had a const accel
lower than 1.0 (yeah, whatever).
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2016-12-15 08:36:22 +10:00
|
|
|
{
|
|
|
|
|
return coords.x == 0.0 && coords.y == 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-24 13:14:19 +01:00
|
|
|
static inline double
|
2018-06-20 14:09:58 +03:00
|
|
|
normalized_length(const struct normalized_coords norm)
|
2015-03-24 13:14:19 +01:00
|
|
|
{
|
|
|
|
|
return hypot(norm.x, norm.y);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-12 11:03:03 +10:00
|
|
|
static inline bool
|
2018-06-20 14:09:58 +03:00
|
|
|
normalized_is_zero(const struct normalized_coords norm)
|
2015-03-24 16:33:29 +01:00
|
|
|
{
|
|
|
|
|
return norm.x == 0.0 && norm.y == 0.0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-23 10:29:56 +10:00
|
|
|
static inline double
|
2018-06-20 14:09:58 +03:00
|
|
|
length_in_mm(const struct phys_coords mm)
|
2017-01-23 10:29:56 +10:00
|
|
|
{
|
|
|
|
|
return hypot(mm.x, mm.y);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-25 15:05:19 +01:00
|
|
|
enum directions {
|
2019-02-06 15:29:23 +10:00
|
|
|
N = bit(0),
|
|
|
|
|
NE = bit(1),
|
|
|
|
|
E = bit(2),
|
|
|
|
|
SE = bit(3),
|
|
|
|
|
S = bit(4),
|
|
|
|
|
SW = bit(5),
|
|
|
|
|
W = bit(6),
|
|
|
|
|
NW = bit(7),
|
2015-03-25 15:05:19 +01:00
|
|
|
UNDEFINED_DIRECTION = 0xff
|
|
|
|
|
};
|
|
|
|
|
|
2016-12-15 12:16:28 +10:00
|
|
|
static inline uint32_t
|
2016-12-15 09:26:42 +10:00
|
|
|
xy_get_direction(double x, double y)
|
2015-03-25 15:05:19 +01:00
|
|
|
{
|
2016-12-15 12:16:28 +10:00
|
|
|
uint32_t dir = UNDEFINED_DIRECTION;
|
2015-03-25 15:05:19 +01:00
|
|
|
int d1, d2;
|
|
|
|
|
double r;
|
|
|
|
|
|
2016-12-15 09:26:42 +10:00
|
|
|
if (fabs(x) < 2.0 && fabs(y) < 2.0) {
|
|
|
|
|
if (x > 0.0 && y > 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = S | SE | E;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (x > 0.0 && y < 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = N | NE | E;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (x < 0.0 && y > 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = S | SW | W;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (x < 0.0 && y < 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = N | NW | W;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (x > 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = NE | E | SE;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (x < 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = NW | W | SW;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (y > 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = SE | S | SW;
|
2016-12-15 09:26:42 +10:00
|
|
|
else if (y < 0.0)
|
2015-03-25 15:05:19 +01:00
|
|
|
dir = NE | N | NW;
|
|
|
|
|
} else {
|
|
|
|
|
/* Calculate r within the interval [0 to 8)
|
|
|
|
|
*
|
|
|
|
|
* r = [0 .. 2π] where 0 is North
|
|
|
|
|
* d_f = r / 2π ([0 .. 1))
|
|
|
|
|
* d_8 = 8 * d_f
|
|
|
|
|
*/
|
2016-12-15 09:26:42 +10:00
|
|
|
r = atan2(y, x);
|
2015-03-25 15:05:19 +01:00
|
|
|
r = fmod(r + 2.5*M_PI, 2*M_PI);
|
|
|
|
|
r *= 4*M_1_PI;
|
|
|
|
|
|
|
|
|
|
/* Mark one or two close enough octants */
|
|
|
|
|
d1 = (int)(r + 0.9) % 8;
|
|
|
|
|
d2 = (int)(r + 0.1) % 8;
|
|
|
|
|
|
2021-11-18 10:10:49 +10:00
|
|
|
dir = bit(d1) | bit(d2);
|
2015-03-25 15:05:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dir;
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-15 09:26:42 +10:00
|
|
|
static inline uint32_t
|
2018-06-20 14:09:58 +03:00
|
|
|
phys_get_direction(const struct phys_coords mm)
|
2016-12-15 09:26:42 +10:00
|
|
|
{
|
2017-01-23 10:43:04 +10:00
|
|
|
return xy_get_direction(mm.x, mm.y);
|
2016-12-15 09:26:42 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the direction for the given set of coordinates.
|
|
|
|
|
* assumption: coordinates are normalized to one axis resolution.
|
|
|
|
|
*/
|
|
|
|
|
static inline uint32_t
|
2018-06-20 14:09:58 +03:00
|
|
|
device_float_get_direction(const struct device_float_coords coords)
|
2016-12-15 09:26:42 +10:00
|
|
|
{
|
|
|
|
|
return xy_get_direction(coords.x, coords.y);
|
|
|
|
|
}
|
2018-09-19 12:02:51 +10:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns true if the point is within the given rectangle, including the
|
|
|
|
|
* left edge but excluding the right edge.
|
|
|
|
|
*/
|
|
|
|
|
static inline bool
|
|
|
|
|
point_in_rect(const struct device_coords *point,
|
|
|
|
|
const struct device_coord_rect *rect)
|
|
|
|
|
{
|
|
|
|
|
return (point->x >= rect->x &&
|
|
|
|
|
point->x < rect->x + rect->w &&
|
|
|
|
|
point->y >= rect->y &&
|
|
|
|
|
point->y < rect->y + rect->h);
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 18:21:09 +10:00
|
|
|
#if HAVE_LIBWACOM
|
|
|
|
|
WacomDeviceDatabase *
|
|
|
|
|
libinput_libwacom_ref(struct libinput *li);
|
|
|
|
|
void
|
|
|
|
|
libinput_libwacom_unref(struct libinput *li);
|
|
|
|
|
#else
|
|
|
|
|
static inline void *libinput_libwacom_ref(struct libinput *li) { return NULL; }
|
|
|
|
|
static inline void libinput_libwacom_unref(struct libinput *li) {}
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
#endif /* LIBINPUT_PRIVATE_H */
|