2011-12-19 01:14:03 +02:00
|
|
|
/*
|
2012-08-03 14:38:59 +03:00
|
|
|
* Copyright © 2011, 2012 Intel Corporation
|
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.
|
2011-12-19 01:14:03 +02: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:
|
2011-12-19 01:14:03 +02: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.
|
2011-12-19 01:14:03 +02:00
|
|
|
*/
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
#ifndef EVDEV_H
|
|
|
|
|
#define EVDEV_H
|
|
|
|
|
|
2013-08-15 01:10:24 +01:00
|
|
|
#include "config.h"
|
|
|
|
|
|
2014-09-16 16:22:36 +02:00
|
|
|
#include <stdbool.h>
|
2014-06-03 07:51:37 +10:00
|
|
|
#include "linux/input.h"
|
2013-12-06 12:01:47 +10:00
|
|
|
#include <libevdev/libevdev.h>
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
#include "libinput-private.h"
|
2014-09-16 16:22:36 +02:00
|
|
|
#include "timer.h"
|
2015-03-13 13:56:14 +10:00
|
|
|
#include "filter.h"
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2015-03-17 10:07:00 +10:00
|
|
|
/* The fake resolution value for abs devices without resolution */
|
|
|
|
|
#define EVDEV_FAKE_RESOLUTION 1
|
2015-03-06 14:18:59 +10:00
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
enum evdev_event_type {
|
2013-09-24 12:09:03 +01:00
|
|
|
EVDEV_NONE,
|
2013-09-24 20:05:07 +01:00
|
|
|
EVDEV_ABSOLUTE_TOUCH_DOWN,
|
2013-09-24 12:09:03 +01:00
|
|
|
EVDEV_ABSOLUTE_MOTION,
|
2013-09-24 20:05:07 +01:00
|
|
|
EVDEV_ABSOLUTE_TOUCH_UP,
|
2013-09-24 12:09:03 +01:00
|
|
|
EVDEV_ABSOLUTE_MT_DOWN,
|
|
|
|
|
EVDEV_ABSOLUTE_MT_MOTION,
|
|
|
|
|
EVDEV_ABSOLUTE_MT_UP,
|
|
|
|
|
EVDEV_RELATIVE_MOTION,
|
2012-08-03 14:38:59 +03:00
|
|
|
};
|
|
|
|
|
|
2013-10-17 23:04:05 +02:00
|
|
|
enum evdev_device_seat_capability {
|
2013-11-13 22:11:34 +01:00
|
|
|
EVDEV_DEVICE_POINTER = (1 << 0),
|
|
|
|
|
EVDEV_DEVICE_KEYBOARD = (1 << 1),
|
2014-04-21 19:11:17 +02:00
|
|
|
EVDEV_DEVICE_TOUCH = (1 << 2),
|
|
|
|
|
EVDEV_DEVICE_TABLET = (1 << 3),
|
2016-02-05 15:16:38 +10:00
|
|
|
EVDEV_DEVICE_TABLET_PAD = (1 << 4),
|
2015-01-22 16:41:50 +01:00
|
|
|
EVDEV_DEVICE_GESTURE = (1 << 5),
|
2017-01-20 16:54:14 +11:00
|
|
|
EVDEV_DEVICE_SWITCH = (1 << 6),
|
2013-10-17 23:04:05 +02:00
|
|
|
};
|
|
|
|
|
|
2014-09-03 15:50:28 +10:00
|
|
|
enum evdev_device_tags {
|
|
|
|
|
EVDEV_TAG_EXTERNAL_MOUSE = (1 << 0),
|
|
|
|
|
EVDEV_TAG_INTERNAL_TOUCHPAD = (1 << 1),
|
2016-06-30 12:05:35 +10:00
|
|
|
EVDEV_TAG_EXTERNAL_TOUCHPAD = (1 << 2),
|
|
|
|
|
EVDEV_TAG_TRACKPOINT = (1 << 3),
|
|
|
|
|
EVDEV_TAG_KEYBOARD = (1 << 4),
|
2017-01-20 16:54:14 +11:00
|
|
|
EVDEV_TAG_LID_SWITCH = (1 << 5),
|
2017-05-22 13:34:10 +10:00
|
|
|
EVDEV_TAG_INTERNAL_KEYBOARD = (1 << 6),
|
|
|
|
|
EVDEV_TAG_EXTERNAL_KEYBOARD = (1 << 7),
|
2017-04-21 17:52:37 +10:00
|
|
|
EVDEV_TAG_TABLET_MODE_SWITCH = (1 << 8),
|
2014-09-03 15:50:28 +10:00
|
|
|
};
|
|
|
|
|
|
2015-04-13 16:38:44 +10:00
|
|
|
enum evdev_middlebutton_state {
|
|
|
|
|
MIDDLEBUTTON_IDLE,
|
|
|
|
|
MIDDLEBUTTON_LEFT_DOWN,
|
|
|
|
|
MIDDLEBUTTON_RIGHT_DOWN,
|
|
|
|
|
MIDDLEBUTTON_MIDDLE,
|
|
|
|
|
MIDDLEBUTTON_LEFT_UP_PENDING,
|
|
|
|
|
MIDDLEBUTTON_RIGHT_UP_PENDING,
|
|
|
|
|
MIDDLEBUTTON_IGNORE_LR,
|
|
|
|
|
MIDDLEBUTTON_IGNORE_L,
|
|
|
|
|
MIDDLEBUTTON_IGNORE_R,
|
|
|
|
|
MIDDLEBUTTON_PASSTHROUGH,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum evdev_middlebutton_event {
|
|
|
|
|
MIDDLEBUTTON_EVENT_L_DOWN,
|
|
|
|
|
MIDDLEBUTTON_EVENT_R_DOWN,
|
|
|
|
|
MIDDLEBUTTON_EVENT_OTHER,
|
|
|
|
|
MIDDLEBUTTON_EVENT_L_UP,
|
|
|
|
|
MIDDLEBUTTON_EVENT_R_UP,
|
|
|
|
|
MIDDLEBUTTON_EVENT_TIMEOUT,
|
|
|
|
|
MIDDLEBUTTON_EVENT_ALL_UP,
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-20 14:29:44 -04:00
|
|
|
enum evdev_device_model {
|
2015-07-16 15:59:01 +10:00
|
|
|
EVDEV_MODEL_DEFAULT = 0,
|
|
|
|
|
EVDEV_MODEL_LENOVO_X230 = (1 << 0),
|
|
|
|
|
EVDEV_MODEL_CHROMEBOOK = (1 << 1),
|
|
|
|
|
EVDEV_MODEL_SYSTEM76_BONOBO = (1 << 2),
|
|
|
|
|
EVDEV_MODEL_SYSTEM76_GALAGO = (1 << 3),
|
|
|
|
|
EVDEV_MODEL_SYSTEM76_KUDU = (1 << 4),
|
|
|
|
|
EVDEV_MODEL_CLEVO_W740SU = (1 << 5),
|
|
|
|
|
EVDEV_MODEL_APPLE_TOUCHPAD = (1 << 6),
|
|
|
|
|
EVDEV_MODEL_WACOM_TOUCHPAD = (1 << 7),
|
|
|
|
|
EVDEV_MODEL_ALPS_TOUCHPAD = (1 << 8),
|
2015-07-16 16:05:48 +10:00
|
|
|
EVDEV_MODEL_SYNAPTICS_SERIAL_TOUCHPAD = (1 << 9),
|
2015-07-14 10:27:46 +10:00
|
|
|
EVDEV_MODEL_JUMPING_SEMI_MT = (1 << 10),
|
2015-12-11 11:10:25 +10:00
|
|
|
EVDEV_MODEL_LENOVO_X220_TOUCHPAD_FW81 = (1 << 12),
|
2016-01-29 10:09:13 +10:00
|
|
|
EVDEV_MODEL_CYBORG_RAT = (1 << 14),
|
2016-08-18 10:48:31 +10:00
|
|
|
EVDEV_MODEL_HP_STREAM11_TOUCHPAD = (1 << 16),
|
2016-03-07 16:05:25 +10:00
|
|
|
EVDEV_MODEL_LENOVO_T450_TOUCHPAD= (1 << 17),
|
2017-01-09 11:27:06 +10:00
|
|
|
EVDEV_MODEL_TOUCHPAD_VISIBLE_MARKER = (1 << 18),
|
2016-05-03 15:03:40 +10:00
|
|
|
EVDEV_MODEL_TRACKBALL = (1 << 19),
|
2016-06-15 19:36:56 +10:00
|
|
|
EVDEV_MODEL_APPLE_MAGICMOUSE = (1 << 20),
|
2016-08-30 17:51:30 +10:00
|
|
|
EVDEV_MODEL_HP8510_TOUCHPAD = (1 << 21),
|
2016-11-02 21:11:00 +10:00
|
|
|
EVDEV_MODEL_HP6910_TOUCHPAD = (1 << 22),
|
2016-10-13 19:05:00 +10:00
|
|
|
EVDEV_MODEL_HP_ZBOOK_STUDIO_G3 = (1 << 23),
|
2016-11-02 09:40:42 +10:00
|
|
|
EVDEV_MODEL_HP_PAVILION_DM4_TOUCHPAD = (1 << 24),
|
2017-01-10 09:22:16 +10:00
|
|
|
EVDEV_MODEL_APPLE_TOUCHPAD_ONEBUTTON = (1 << 25),
|
2017-02-17 08:39:51 +10:00
|
|
|
EVDEV_MODEL_LOGITECH_MARBLE_MOUSE = (1 << 26),
|
2016-12-22 12:11:43 +10:00
|
|
|
EVDEV_MODEL_TABLET_NO_PROXIMITY_OUT = (1 << 27),
|
2015-04-20 14:29:44 -04:00
|
|
|
};
|
|
|
|
|
|
2017-02-20 13:31:23 +10:00
|
|
|
enum evdev_button_scroll_state {
|
|
|
|
|
BUTTONSCROLL_IDLE,
|
|
|
|
|
BUTTONSCROLL_BUTTON_DOWN, /* button is down */
|
2017-02-20 13:32:07 +10:00
|
|
|
BUTTONSCROLL_READY, /* ready for scroll events */
|
|
|
|
|
BUTTONSCROLL_SCROLLING, /* have sent scroll events */
|
2017-02-20 13:31:23 +10:00
|
|
|
};
|
|
|
|
|
|
2017-07-14 13:42:53 +10:00
|
|
|
enum evdev_debounce_state {
|
|
|
|
|
/**
|
|
|
|
|
* Initial state, no debounce but monitoring events
|
|
|
|
|
*/
|
|
|
|
|
DEBOUNCE_INIT,
|
|
|
|
|
/**
|
|
|
|
|
* Bounce detected, future events need debouncing
|
|
|
|
|
*/
|
|
|
|
|
DEBOUNCE_NEEDED,
|
|
|
|
|
/**
|
|
|
|
|
* Debounce is enabled, but no event is currently being filtered
|
|
|
|
|
*/
|
|
|
|
|
DEBOUNCE_ON,
|
|
|
|
|
/**
|
|
|
|
|
* Debounce is enabled and we are currently filtering an event
|
|
|
|
|
*/
|
|
|
|
|
DEBOUNCE_ACTIVE,
|
|
|
|
|
};
|
|
|
|
|
|
2014-04-22 23:02:14 +02:00
|
|
|
struct mt_slot {
|
|
|
|
|
int32_t seat_slot;
|
2015-03-11 08:35:38 +10:00
|
|
|
struct device_coords point;
|
2016-04-14 15:21:50 +10:00
|
|
|
struct device_coords hysteresis_center;
|
2014-04-22 23:02:14 +02:00
|
|
|
};
|
|
|
|
|
|
2012-08-06 14:57:08 +03:00
|
|
|
struct evdev_device {
|
2013-11-10 17:55:40 +01:00
|
|
|
struct libinput_device base;
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput_source *source;
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
struct evdev_dispatch *dispatch;
|
2013-12-06 12:01:47 +10:00
|
|
|
struct libevdev *evdev;
|
2014-11-20 13:55:48 +10:00
|
|
|
struct udev_device *udev_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
|
|
|
char *output_name;
|
2013-12-06 12:01:47 +10:00
|
|
|
const char *devname;
|
2014-11-20 13:55:48 +10:00
|
|
|
bool was_removed;
|
2012-08-03 14:38:59 +03:00
|
|
|
int fd;
|
2016-07-04 15:32:54 +10:00
|
|
|
enum evdev_device_seat_capability seat_caps;
|
|
|
|
|
enum evdev_device_tags tags;
|
2016-07-04 15:41:37 +10:00
|
|
|
bool is_mt;
|
|
|
|
|
bool is_suspended;
|
2016-07-04 15:32:54 +10:00
|
|
|
int dpi; /* HW resolution */
|
2017-05-12 14:39:24 +10:00
|
|
|
int trackpoint_range; /* trackpoint max delta */
|
2016-07-04 15:32:54 +10:00
|
|
|
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
|
|
|
|
|
struct ratelimit nonpointer_rel_limit; /* ratelimit for REL_* events from non-pointer devices */
|
|
|
|
|
uint32_t model_flags;
|
|
|
|
|
struct mtdev *mtdev;
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
struct {
|
2014-06-19 11:11:36 +10:00
|
|
|
const struct input_absinfo *absinfo_x, *absinfo_y;
|
2016-07-04 15:41:37 +10:00
|
|
|
bool is_fake_resolution;
|
2012-12-03 19:44:16 +00:00
|
|
|
|
|
|
|
|
int apply_calibration;
|
2014-08-26 10:34:05 +10:00
|
|
|
struct matrix calibration;
|
2014-08-26 13:44:03 +10:00
|
|
|
struct matrix default_calibration; /* from LIBINPUT_CALIBRATION_MATRIX */
|
2014-08-26 11:41:19 +10:00
|
|
|
struct matrix usermatrix; /* as supplied by the caller */
|
2015-06-25 14:10:38 +10:00
|
|
|
|
|
|
|
|
struct device_coords dimensions;
|
2016-11-28 14:58:18 +10:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct device_coords min, max;
|
|
|
|
|
struct ratelimit range_warn_limit;
|
|
|
|
|
} warning_range;
|
2012-08-03 14:38:59 +03:00
|
|
|
} abs;
|
|
|
|
|
|
2014-09-16 16:22:35 +02:00
|
|
|
struct {
|
2014-09-16 16:22:36 +02:00
|
|
|
struct libinput_timer timer;
|
2014-11-19 12:16:28 +10:00
|
|
|
struct libinput_device_config_scroll_method config;
|
|
|
|
|
/* Currently enabled method, button */
|
|
|
|
|
enum libinput_config_scroll_method method;
|
2014-11-06 13:39:51 +01:00
|
|
|
uint32_t button;
|
2015-06-01 14:38:29 +10:00
|
|
|
uint64_t button_down_time;
|
|
|
|
|
|
2014-11-06 13:39:51 +01:00
|
|
|
/* set during device init, used at runtime to delay changes
|
|
|
|
|
* until all buttons are up */
|
2014-11-19 12:16:28 +10:00
|
|
|
enum libinput_config_scroll_method want_method;
|
2014-11-06 13:39:51 +01:00
|
|
|
uint32_t want_button;
|
|
|
|
|
/* Checks if buttons are down and commits the setting */
|
2014-11-19 12:16:28 +10:00
|
|
|
void (*change_scroll_method)(struct evdev_device *device);
|
2017-02-20 13:31:23 +10:00
|
|
|
enum evdev_button_scroll_state button_scroll_state;
|
2014-09-16 16:22:35 +02:00
|
|
|
double threshold;
|
2015-08-05 10:55:39 +10:00
|
|
|
double direction_lock_threshold;
|
2014-09-16 16:22:35 +02:00
|
|
|
uint32_t direction;
|
2015-03-11 10:36:44 +10:00
|
|
|
struct normalized_coords buildup;
|
2014-11-18 11:01:10 +10:00
|
|
|
|
|
|
|
|
struct libinput_device_config_natural_scroll config_natural;
|
2014-11-18 11:38:38 +10:00
|
|
|
/* set during device init if we want natural scrolling,
|
|
|
|
|
* used at runtime to enable/disable the feature */
|
2014-11-18 11:01:10 +10:00
|
|
|
bool natural_scrolling_enabled;
|
2015-01-12 08:39:47 +10:00
|
|
|
|
|
|
|
|
/* angle per REL_WHEEL click in degrees */
|
2016-08-16 14:48:47 +10:00
|
|
|
struct wheel_angle wheel_click_angle;
|
2016-11-28 10:52:16 +10:00
|
|
|
|
|
|
|
|
struct wheel_tilt_flags is_tilt;
|
2014-09-16 16:22:35 +02:00
|
|
|
} scroll;
|
|
|
|
|
|
2014-05-18 19:20:39 +02:00
|
|
|
struct {
|
2014-09-19 15:09:31 +10:00
|
|
|
struct libinput_device_config_accel config;
|
2014-05-18 19:20:39 +02:00
|
|
|
struct motion_filter *filter;
|
|
|
|
|
} pointer;
|
2014-07-27 15:43:59 +02:00
|
|
|
|
2014-07-27 15:54:49 +02:00
|
|
|
/* Key counter used for multiplexing button events internally in
|
|
|
|
|
* libinput. */
|
|
|
|
|
uint8_t key_count[KEY_CNT];
|
2014-09-23 13:48:06 +10:00
|
|
|
|
|
|
|
|
struct {
|
2015-01-06 21:20:22 -05:00
|
|
|
struct libinput_device_config_left_handed config;
|
2014-09-23 13:48:06 +10:00
|
|
|
/* left-handed currently enabled */
|
2015-01-06 21:20:22 -05:00
|
|
|
bool enabled;
|
2014-09-23 13:48:06 +10:00
|
|
|
/* set during device init if we want left_handed config,
|
|
|
|
|
* used at runtime to delay the effect until buttons are up */
|
2015-01-06 21:20:22 -05:00
|
|
|
bool want_enabled;
|
2014-09-23 13:48:06 +10:00
|
|
|
/* Checks if buttons are down and commits the setting */
|
2015-01-06 21:20:22 -05:00
|
|
|
void (*change_to_enabled)(struct evdev_device *device);
|
|
|
|
|
} left_handed;
|
2014-10-29 09:56:27 -05:00
|
|
|
|
2015-04-13 16:38:44 +10:00
|
|
|
struct {
|
|
|
|
|
struct libinput_device_config_middle_emulation config;
|
|
|
|
|
/* middle-button emulation enabled */
|
|
|
|
|
bool enabled;
|
|
|
|
|
bool enabled_default;
|
|
|
|
|
bool want_enabled;
|
|
|
|
|
enum evdev_middlebutton_state state;
|
|
|
|
|
struct libinput_timer timer;
|
|
|
|
|
uint32_t button_mask;
|
|
|
|
|
uint64_t first_event_time;
|
|
|
|
|
} middlebutton;
|
2012-08-03 14:38:59 +03:00
|
|
|
};
|
|
|
|
|
|
2017-01-30 19:48:33 +10:00
|
|
|
static inline struct evdev_device *
|
|
|
|
|
evdev_device(struct libinput_device *device)
|
|
|
|
|
{
|
2017-05-15 13:08:17 +02:00
|
|
|
return container_of(device, struct evdev_device, base);
|
2017-01-30 19:48:33 +10:00
|
|
|
}
|
|
|
|
|
|
2013-02-16 14:29:24 -05:00
|
|
|
#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
struct evdev_dispatch;
|
|
|
|
|
|
|
|
|
|
struct evdev_dispatch_interface {
|
|
|
|
|
/* Process an evdev input event. */
|
|
|
|
|
void (*process)(struct evdev_dispatch *dispatch,
|
2012-08-06 14:57:08 +03:00
|
|
|
struct evdev_device *device,
|
2012-08-03 14:38:59 +03:00
|
|
|
struct input_event *event,
|
2014-04-08 12:29:45 +02:00
|
|
|
uint64_t time);
|
2012-08-03 14:38:59 +03:00
|
|
|
|
2015-05-19 15:57:11 +10:00
|
|
|
/* Device is being suspended */
|
|
|
|
|
void (*suspend)(struct evdev_dispatch *dispatch,
|
|
|
|
|
struct evdev_device *device);
|
|
|
|
|
|
2014-12-05 12:39:16 +01:00
|
|
|
/* Device is being removed (may be NULL) */
|
|
|
|
|
void (*remove)(struct evdev_dispatch *dispatch);
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
/* Destroy an event dispatch handler and free all its resources. */
|
|
|
|
|
void (*destroy)(struct evdev_dispatch *dispatch);
|
2014-09-03 14:34:52 +10:00
|
|
|
|
|
|
|
|
/* A new device was added */
|
|
|
|
|
void (*device_added)(struct evdev_device *device,
|
|
|
|
|
struct evdev_device *added_device);
|
|
|
|
|
|
|
|
|
|
/* A device was removed */
|
|
|
|
|
void (*device_removed)(struct evdev_device *device,
|
|
|
|
|
struct evdev_device *removed_device);
|
2014-09-03 15:50:28 +10:00
|
|
|
|
2014-09-16 16:22:37 +02:00
|
|
|
/* A device was suspended */
|
|
|
|
|
void (*device_suspended)(struct evdev_device *device,
|
|
|
|
|
struct evdev_device *suspended_device);
|
|
|
|
|
|
|
|
|
|
/* A device was resumed */
|
|
|
|
|
void (*device_resumed)(struct evdev_device *device,
|
|
|
|
|
struct evdev_device *resumed_device);
|
|
|
|
|
|
2015-02-26 13:55:08 +10:00
|
|
|
/* Called immediately after the LIBINPUT_EVENT_DEVICE_ADDED event
|
|
|
|
|
* was sent */
|
|
|
|
|
void (*post_added)(struct evdev_device *device,
|
|
|
|
|
struct evdev_dispatch *dispatch);
|
2016-06-28 11:28:34 +10:00
|
|
|
|
2017-09-19 13:23:48 +10:00
|
|
|
/* For touch arbitration, called on the device that should
|
|
|
|
|
* enable/disable touch capabilities */
|
2016-06-28 11:28:34 +10:00
|
|
|
void (*toggle_touch)(struct evdev_dispatch *dispatch,
|
|
|
|
|
struct evdev_device *device,
|
|
|
|
|
bool enable);
|
2017-09-19 13:45:22 +10:00
|
|
|
|
|
|
|
|
/* Return the state of the given switch */
|
|
|
|
|
enum libinput_switch_state
|
|
|
|
|
(*get_switch_state)(struct evdev_dispatch *dispatch,
|
|
|
|
|
enum libinput_switch which);
|
2012-08-03 14:38:59 +03:00
|
|
|
};
|
|
|
|
|
|
2017-01-30 18:01:09 +10:00
|
|
|
enum evdev_dispatch_type {
|
|
|
|
|
DISPATCH_FALLBACK,
|
|
|
|
|
DISPATCH_TOUCHPAD,
|
|
|
|
|
DISPATCH_TABLET,
|
|
|
|
|
DISPATCH_TABLET_PAD,
|
|
|
|
|
};
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
struct evdev_dispatch {
|
2017-01-30 18:01:09 +10:00
|
|
|
enum evdev_dispatch_type dispatch_type;
|
2012-08-03 14:38:59 +03:00
|
|
|
struct evdev_dispatch_interface *interface;
|
2016-07-04 14:34:56 +10:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct libinput_device_config_send_events config;
|
|
|
|
|
enum libinput_config_send_events_mode current_mode;
|
|
|
|
|
} sendevents;
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-30 18:01:09 +10:00
|
|
|
static inline void
|
|
|
|
|
evdev_verify_dispatch_type(struct evdev_dispatch *dispatch,
|
|
|
|
|
enum evdev_dispatch_type type)
|
|
|
|
|
{
|
|
|
|
|
if (dispatch->dispatch_type != type)
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
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 evdev_device *
|
|
|
|
|
evdev_device_create(struct libinput_seat *seat,
|
2014-11-20 13:55:48 +10:00
|
|
|
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
|
|
|
|
2015-12-01 15:46:44 +10:00
|
|
|
void
|
|
|
|
|
evdev_transform_absolute(struct evdev_device *device,
|
2016-01-06 15:26:49 +10:00
|
|
|
struct device_coords *point);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
evdev_transform_relative(struct evdev_device *device,
|
2015-12-01 15:46:44 +10:00
|
|
|
struct device_coords *point);
|
|
|
|
|
|
2015-12-01 14:05:16 +10:00
|
|
|
void
|
|
|
|
|
evdev_init_calibration(struct evdev_device *device,
|
2016-07-04 14:34:56 +10:00
|
|
|
struct libinput_device_config_calibration *calibration);
|
2015-12-01 14:05:16 +10:00
|
|
|
|
2016-11-25 13:54:35 +10:00
|
|
|
void
|
|
|
|
|
evdev_read_calibration_prop(struct evdev_device *device);
|
|
|
|
|
|
2017-09-19 13:57:50 +10:00
|
|
|
enum switch_reliability
|
|
|
|
|
evdev_read_switch_reliability_prop(struct evdev_device *device);
|
|
|
|
|
|
2017-01-25 14:31:05 +10:00
|
|
|
void
|
|
|
|
|
evdev_init_sendevents(struct evdev_device *device,
|
|
|
|
|
struct evdev_dispatch *dispatch);
|
|
|
|
|
|
2016-07-13 07:55:13 +10:00
|
|
|
void
|
2015-03-13 13:56:14 +10:00
|
|
|
evdev_device_init_pointer_acceleration(struct evdev_device *device,
|
2015-07-28 15:06:13 +10:00
|
|
|
struct motion_filter *filter);
|
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
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
struct evdev_dispatch *
|
2012-08-06 14:57:08 +03:00
|
|
|
evdev_touchpad_create(struct evdev_device *device);
|
2012-08-03 14:38:59 +03:00
|
|
|
|
2014-02-06 15:05:36 +10:00
|
|
|
struct evdev_dispatch *
|
|
|
|
|
evdev_mt_touchpad_create(struct evdev_device *device);
|
|
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
struct evdev_dispatch *
|
|
|
|
|
evdev_tablet_create(struct evdev_device *device);
|
|
|
|
|
|
2016-02-05 15:16:38 +10:00
|
|
|
struct evdev_dispatch *
|
|
|
|
|
evdev_tablet_pad_create(struct evdev_device *device);
|
|
|
|
|
|
2017-01-25 14:31:05 +10:00
|
|
|
struct evdev_dispatch *
|
|
|
|
|
evdev_lid_switch_dispatch_create(struct evdev_device *device);
|
|
|
|
|
|
2017-09-19 13:57:50 +10:00
|
|
|
struct evdev_dispatch *
|
|
|
|
|
fallback_dispatch_create(struct libinput_device *libinput_device);
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
evdev_is_fake_mt_device(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
evdev_need_mtdev(struct evdev_device *device);
|
|
|
|
|
|
2012-08-03 14:39:05 +03:00
|
|
|
void
|
2013-11-10 17:55:40 +01:00
|
|
|
evdev_device_led_update(struct evdev_device *device, enum libinput_led leds);
|
2012-08-03 14:39:05 +03:00
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
int
|
|
|
|
|
evdev_device_get_keys(struct evdev_device *device, char *keys, size_t size);
|
2012-08-03 14:39:05 +03: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
|
|
|
const char *
|
|
|
|
|
evdev_device_get_output(struct evdev_device *device);
|
|
|
|
|
|
2013-12-15 17:50:04 +01:00
|
|
|
const char *
|
|
|
|
|
evdev_device_get_sysname(struct evdev_device *device);
|
|
|
|
|
|
2014-06-27 12:55:29 +10:00
|
|
|
const char *
|
|
|
|
|
evdev_device_get_name(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
|
evdev_device_get_id_product(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
|
evdev_device_get_id_vendor(struct evdev_device *device);
|
|
|
|
|
|
2014-10-31 10:53:53 +10:00
|
|
|
struct udev_device *
|
|
|
|
|
evdev_device_get_udev_device(struct evdev_device *device);
|
|
|
|
|
|
2012-08-03 14:39:05 +03:00
|
|
|
void
|
2014-08-26 13:44:03 +10:00
|
|
|
evdev_device_set_default_calibration(struct evdev_device *device,
|
|
|
|
|
const float calibration[6]);
|
2012-08-03 14:39:05 +03:00
|
|
|
void
|
2014-08-26 12:57:41 +10:00
|
|
|
evdev_device_calibrate(struct evdev_device *device,
|
|
|
|
|
const float calibration[6]);
|
2012-08-03 14:39:05 +03:00
|
|
|
|
2016-07-12 11:03:03 +10:00
|
|
|
bool
|
2013-12-15 17:45:02 +01:00
|
|
|
evdev_device_has_capability(struct evdev_device *device,
|
|
|
|
|
enum libinput_device_capability capability);
|
|
|
|
|
|
2014-06-17 15:45:07 +10:00
|
|
|
int
|
2016-07-15 11:13:06 +10:00
|
|
|
evdev_device_get_size(const struct evdev_device *device,
|
2014-06-17 15:45:07 +10:00
|
|
|
double *w,
|
|
|
|
|
double *h);
|
|
|
|
|
|
2014-11-06 12:27:35 +01:00
|
|
|
int
|
|
|
|
|
evdev_device_has_button(struct evdev_device *device, uint32_t code);
|
|
|
|
|
|
2015-04-22 14:36:25 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_has_key(struct evdev_device *device, uint32_t code);
|
|
|
|
|
|
2017-04-21 16:57:39 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_has_switch(struct evdev_device *device,
|
|
|
|
|
enum libinput_switch sw);
|
|
|
|
|
|
2016-02-05 15:16:38 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_tablet_pad_get_num_buttons(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
evdev_device_tablet_pad_get_num_rings(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
evdev_device_tablet_pad_get_num_strips(struct evdev_device *device);
|
|
|
|
|
|
2016-06-02 15:35:43 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_tablet_pad_get_num_mode_groups(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
struct libinput_tablet_pad_mode_group *
|
|
|
|
|
evdev_device_tablet_pad_get_mode_group(struct evdev_device *device,
|
|
|
|
|
unsigned int index);
|
|
|
|
|
|
2017-09-01 17:30:08 +10:00
|
|
|
enum libinput_switch_state
|
|
|
|
|
evdev_device_switch_get_state(struct evdev_device *device,
|
|
|
|
|
enum libinput_switch sw);
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
double
|
2014-01-25 11:53:53 +01:00
|
|
|
evdev_device_transform_x(struct evdev_device *device,
|
2014-06-02 23:09:27 +02:00
|
|
|
double x,
|
2014-01-25 11:53:53 +01:00
|
|
|
uint32_t width);
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
double
|
2014-01-25 11:53:53 +01:00
|
|
|
evdev_device_transform_y(struct evdev_device *device,
|
2014-06-02 23:09:27 +02:00
|
|
|
double y,
|
2014-01-25 11:53:53 +01:00
|
|
|
uint32_t height);
|
2016-07-13 07:39:59 +10:00
|
|
|
void
|
2014-01-30 15:34:00 +10:00
|
|
|
evdev_device_suspend(struct evdev_device *device);
|
2014-01-25 11:53:53 +01:00
|
|
|
|
2014-08-22 13:40:40 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_resume(struct evdev_device *device);
|
|
|
|
|
|
2014-09-16 16:22:37 +02:00
|
|
|
void
|
|
|
|
|
evdev_notify_suspended_device(struct evdev_device *device);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
evdev_notify_resumed_device(struct evdev_device *device);
|
|
|
|
|
|
2014-07-27 15:54:49 +02:00
|
|
|
void
|
|
|
|
|
evdev_pointer_notify_button(struct evdev_device *device,
|
2015-07-27 11:52:44 +08:00
|
|
|
uint64_t time,
|
2016-04-11 10:06:36 +10:00
|
|
|
unsigned int button,
|
2014-07-27 15:54:49 +02:00
|
|
|
enum libinput_button_state state);
|
2015-04-13 14:47:26 +10:00
|
|
|
void
|
|
|
|
|
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
2015-07-27 11:52:44 +08:00
|
|
|
uint64_t time,
|
2015-04-13 14:47:26 +10:00
|
|
|
int button,
|
|
|
|
|
enum libinput_button_state state);
|
2014-07-27 15:54:49 +02:00
|
|
|
|
2014-11-18 11:01:10 +10:00
|
|
|
void
|
|
|
|
|
evdev_init_natural_scroll(struct evdev_device *device);
|
|
|
|
|
|
2017-09-19 13:57:50 +10:00
|
|
|
void
|
|
|
|
|
evdev_init_button_scroll(struct evdev_device *device,
|
|
|
|
|
void (*change_scroll_method)(struct evdev_device *));
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
evdev_update_key_down_count(struct evdev_device *device,
|
|
|
|
|
int code,
|
|
|
|
|
int pressed);
|
|
|
|
|
|
2015-08-11 12:40:45 +10:00
|
|
|
void
|
|
|
|
|
evdev_notify_axis(struct evdev_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
uint32_t axes,
|
|
|
|
|
enum libinput_pointer_axis_source source,
|
|
|
|
|
const struct normalized_coords *delta_in,
|
|
|
|
|
const struct discrete_coords *discrete_in);
|
2014-09-16 16:22:35 +02:00
|
|
|
void
|
|
|
|
|
evdev_post_scroll(struct evdev_device *device,
|
|
|
|
|
uint64_t time,
|
Add pointer axis sources to the API
For a caller to implement/provide kinetic scrolling ("inertial scrolling",
"fling scrolling"), it needs to know how the scrolling motion was implemented,
and what to expect in the future. Add this information to the pointer axis
event.
The three scroll sources we have are:
* wheels: scrolling is in discreet steps, you don't know when it ends, the
wheel will just stop sending events
* fingers: scrolling is continuous coordinate space, we know when it stops and
we can tell the caller
* continuous: scrolling is in continuous coordinate space but we may or may not
know when it stops. if scroll lock is used, the device may never technically
get out of scroll mode even if it doesn't send events at any given moment
Use case: trackpoint/trackball scroll emulation on button press
The stop event is now codified in the API documentation, so callers can use
that for kinetic scrolling. libinput does not implement kinetic scrolling
itself.
Not covered by this patch:
* The wheel event is currently defined as "typical mouse wheel step", this is
different to Qt where the step value is 1/8 of a degree. Some better
definition here may help.
* It is unclear how an absolute device would map into relative motion if the
device itself is not controlling absolute motion.
* For diagonal scrolling, the vertical/horizontal terminator events would come
in separately. The caller would have to deal with that somehow.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Original patch, before the rebase onto today's master:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-11-05 16:22:07 +10:00
|
|
|
enum libinput_pointer_axis_source source,
|
2015-03-11 10:36:44 +10:00
|
|
|
const struct normalized_coords *delta);
|
2014-09-16 16:22:35 +02:00
|
|
|
|
|
|
|
|
void
|
Add pointer axis sources to the API
For a caller to implement/provide kinetic scrolling ("inertial scrolling",
"fling scrolling"), it needs to know how the scrolling motion was implemented,
and what to expect in the future. Add this information to the pointer axis
event.
The three scroll sources we have are:
* wheels: scrolling is in discreet steps, you don't know when it ends, the
wheel will just stop sending events
* fingers: scrolling is continuous coordinate space, we know when it stops and
we can tell the caller
* continuous: scrolling is in continuous coordinate space but we may or may not
know when it stops. if scroll lock is used, the device may never technically
get out of scroll mode even if it doesn't send events at any given moment
Use case: trackpoint/trackball scroll emulation on button press
The stop event is now codified in the API documentation, so callers can use
that for kinetic scrolling. libinput does not implement kinetic scrolling
itself.
Not covered by this patch:
* The wheel event is currently defined as "typical mouse wheel step", this is
different to Qt where the step value is 1/8 of a degree. Some better
definition here may help.
* It is unclear how an absolute device would map into relative motion if the
device itself is not controlling absolute motion.
* For diagonal scrolling, the vertical/horizontal terminator events would come
in separately. The caller would have to deal with that somehow.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Original patch, before the rebase onto today's master:
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
2014-11-05 16:22:07 +10:00
|
|
|
evdev_stop_scroll(struct evdev_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_pointer_axis_source source);
|
2014-01-25 11:53:53 +01:00
|
|
|
|
2013-11-17 16:59:09 +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
|
|
|
evdev_device_remove(struct evdev_device *device);
|
2013-11-17 16:59:09 +01:00
|
|
|
|
2012-08-03 14:39:05 +03:00
|
|
|
void
|
2013-11-10 17:55:40 +01:00
|
|
|
evdev_device_destroy(struct evdev_device *device);
|
2012-08-03 14:39:05 +03:00
|
|
|
|
2015-04-13 16:38:44 +10:00
|
|
|
bool
|
|
|
|
|
evdev_middlebutton_filter_button(struct evdev_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int button,
|
|
|
|
|
enum libinput_button_state state);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
evdev_init_middlebutton(struct evdev_device *device,
|
|
|
|
|
bool enabled,
|
|
|
|
|
bool want_config);
|
|
|
|
|
|
2016-06-30 15:49:40 +10:00
|
|
|
enum libinput_config_middle_emulation_state
|
|
|
|
|
evdev_middlebutton_get(struct libinput_device *device);
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
evdev_middlebutton_is_available(struct libinput_device *device);
|
|
|
|
|
|
|
|
|
|
enum libinput_config_middle_emulation_state
|
|
|
|
|
evdev_middlebutton_get_default(struct libinput_device *device);
|
|
|
|
|
|
2014-06-19 11:30:21 +10:00
|
|
|
static inline double
|
|
|
|
|
evdev_convert_to_mm(const struct input_absinfo *absinfo, double v)
|
|
|
|
|
{
|
|
|
|
|
double value = v - absinfo->minimum;
|
|
|
|
|
return value/absinfo->resolution;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-13 07:55:13 +10:00
|
|
|
void
|
2014-09-23 13:48:06 +10:00
|
|
|
evdev_init_left_handed(struct evdev_device *device,
|
|
|
|
|
void (*change_to_left_handed)(struct evdev_device *));
|
|
|
|
|
|
2016-02-10 12:29:55 +10:00
|
|
|
bool
|
|
|
|
|
evdev_tablet_has_left_handed(struct evdev_device *device);
|
|
|
|
|
|
2014-09-23 13:48:06 +10:00
|
|
|
static inline uint32_t
|
|
|
|
|
evdev_to_left_handed(struct evdev_device *device,
|
|
|
|
|
uint32_t button)
|
|
|
|
|
{
|
2015-01-06 21:20:22 -05:00
|
|
|
if (device->left_handed.enabled) {
|
2014-09-23 13:48:06 +10:00
|
|
|
if (button == BTN_LEFT)
|
|
|
|
|
return BTN_RIGHT;
|
|
|
|
|
else if (button == BTN_RIGHT)
|
|
|
|
|
return BTN_LEFT;
|
|
|
|
|
}
|
|
|
|
|
return button;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 12:24:45 +10:00
|
|
|
/**
|
|
|
|
|
* Apply a hysteresis filtering to the coordinate in, based on the current
|
2017-01-31 10:06:32 +10:00
|
|
|
* hysteresis center and the margin. If 'in' is within 'margin' of center,
|
2016-11-21 12:24:45 +10:00
|
|
|
* return the center (and thus filter the motion). If 'in' is outside,
|
|
|
|
|
* return a point on the edge of the new margin. So for a point x in the
|
|
|
|
|
* space outside c + margin we return r:
|
|
|
|
|
* +---+ +---+
|
|
|
|
|
* | c | x → | r x
|
|
|
|
|
* +---+ +---+
|
|
|
|
|
*
|
|
|
|
|
* The effect of this is that initial small motions are filtered. Once we
|
|
|
|
|
* move into one direction we lag the real coordinates by 'margin' but any
|
|
|
|
|
* movement that continues into that direction will always be just outside
|
|
|
|
|
* margin - we get responsive movement. Once we move back into the other
|
|
|
|
|
* direction, the first movements are filtered again.
|
|
|
|
|
*
|
|
|
|
|
* Returning the edge rather than the point avoids cursor jumps, as the
|
|
|
|
|
* first reachable coordinate is the point next to the center (center + 1).
|
|
|
|
|
* Otherwise, the center has a dead zone of size margin around it and the
|
|
|
|
|
* first reachable point is the margin edge.
|
|
|
|
|
*
|
|
|
|
|
* Hysteresis is handled separately per axis (and the window is thus
|
|
|
|
|
* rectangular, not circular). It is unkown if that's an issue, but the
|
|
|
|
|
* calculation to do circular hysteresis are nontrivial, especially since
|
|
|
|
|
* many touchpads have uneven x/y resolutions.
|
|
|
|
|
*
|
|
|
|
|
* @param in The input coordinate
|
|
|
|
|
* @param center Current center of the hysteresis
|
|
|
|
|
* @param margin Hysteresis width (on each side)
|
|
|
|
|
*
|
|
|
|
|
* @return The new center of the hysteresis
|
|
|
|
|
*/
|
2016-04-13 15:23:44 +10:00
|
|
|
static inline int
|
|
|
|
|
evdev_hysteresis(int in, int center, int margin)
|
|
|
|
|
{
|
|
|
|
|
int diff = in - center;
|
|
|
|
|
if (abs(diff) <= margin)
|
|
|
|
|
return center;
|
|
|
|
|
|
2016-11-21 12:24:45 +10:00
|
|
|
if (diff > 0)
|
|
|
|
|
return in - margin;
|
2016-04-13 15:23:44 +10:00
|
|
|
else
|
2016-11-21 12:24:45 +10:00
|
|
|
return in + margin;
|
2016-04-13 15:23:44 +10:00
|
|
|
}
|
|
|
|
|
|
2016-06-09 08:54:00 +10:00
|
|
|
static inline struct libinput *
|
|
|
|
|
evdev_libinput_context(const struct evdev_device *device)
|
|
|
|
|
{
|
|
|
|
|
return device->base.seat->libinput;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 20:59:07 +10:00
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
|
2017-02-13 14:17:52 +10:00
|
|
|
static inline void
|
|
|
|
|
evdev_log_msg_va(struct evdev_device *device,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format,
|
|
|
|
|
va_list args)
|
|
|
|
|
{
|
|
|
|
|
log_msg(evdev_libinput_context(device),
|
|
|
|
|
priority,
|
|
|
|
|
"%-7s - ",
|
|
|
|
|
evdev_device_get_sysname(device));
|
|
|
|
|
|
|
|
|
|
/* Anything info and above is user-visible, use the device name */
|
|
|
|
|
if (priority > LIBINPUT_LOG_PRIORITY_DEBUG)
|
|
|
|
|
log_msg(evdev_libinput_context(device),
|
|
|
|
|
priority,
|
|
|
|
|
"%s: ",
|
|
|
|
|
device->devname);
|
|
|
|
|
|
|
|
|
|
log_msg_va(evdev_libinput_context(device),
|
|
|
|
|
priority,
|
|
|
|
|
format,
|
|
|
|
|
args);
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 20:59:07 +10:00
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(3, 4)
|
2017-02-13 14:17:52 +10:00
|
|
|
static inline void
|
|
|
|
|
evdev_log_msg(struct evdev_device *device,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
evdev_log_msg_va(device, priority, format, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-22 20:59:07 +10:00
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(4, 5)
|
2017-02-13 14:17:52 +10:00
|
|
|
static inline void
|
|
|
|
|
evdev_log_msg_ratelimit(struct evdev_device *device,
|
|
|
|
|
struct ratelimit *ratelimit,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
enum ratelimit_state state;
|
|
|
|
|
|
|
|
|
|
state = ratelimit_test(ratelimit);
|
|
|
|
|
if (state == RATELIMIT_EXCEEDED)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
evdev_log_msg_va(device, priority, format, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
if (state == RATELIMIT_THRESHOLD)
|
|
|
|
|
evdev_log_msg(device,
|
|
|
|
|
priority,
|
|
|
|
|
"WARNING: log rate limit exceeded (%d msgs per %dms). Discarding future messages.\n",
|
|
|
|
|
ratelimit->burst,
|
|
|
|
|
us2ms(ratelimit->interval));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define evdev_log_debug(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
|
|
|
|
|
#define evdev_log_info(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
|
|
|
|
|
#define evdev_log_error(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
|
|
|
|
|
#define evdev_log_bug_kernel(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
|
|
|
|
|
#define evdev_log_bug_libinput(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__)
|
|
|
|
|
#define evdev_log_bug_client(d_, ...) evdev_log_msg((d_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
#define evdev_log_debug_ratelimit(d_, r_, ...) \
|
|
|
|
|
evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
|
|
|
|
|
#define evdev_log_info_ratelimit(d_, r_, ...) \
|
|
|
|
|
evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
|
|
|
|
|
#define evdev_log_error_ratelimit(d_, r_, ...) \
|
|
|
|
|
evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
|
|
|
|
|
#define evdev_log_bug_kernel_ratelimit(d_, r_, ...) \
|
|
|
|
|
evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
|
|
|
|
|
#define evdev_log_bug_libinput_ratelimit(d_, r_, ...) \
|
|
|
|
|
evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__)
|
|
|
|
|
#define evdev_log_bug_client_ratelimit(d_, r_, ...) \
|
|
|
|
|
evdev_log_msg_ratelimit((d_), (r_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
|
|
|
|
|
|
2016-12-13 10:01:02 +10:00
|
|
|
/**
|
|
|
|
|
* Convert the pair of delta coordinates in device space to mm.
|
|
|
|
|
*/
|
|
|
|
|
static inline struct phys_coords
|
|
|
|
|
evdev_device_unit_delta_to_mm(const struct evdev_device* device,
|
|
|
|
|
const struct device_coords *units)
|
|
|
|
|
{
|
|
|
|
|
struct phys_coords mm = { 0, 0 };
|
|
|
|
|
const struct input_absinfo *absx, *absy;
|
|
|
|
|
|
|
|
|
|
if (device->abs.absinfo_x == NULL ||
|
|
|
|
|
device->abs.absinfo_y == NULL) {
|
|
|
|
|
log_bug_libinput(evdev_libinput_context(device),
|
|
|
|
|
"%s: is not an abs device\n",
|
|
|
|
|
device->devname);
|
|
|
|
|
return mm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
absx = device->abs.absinfo_x;
|
|
|
|
|
absy = device->abs.absinfo_y;
|
|
|
|
|
|
|
|
|
|
mm.x = 1.0 * units->x/absx->resolution;
|
|
|
|
|
mm.y = 1.0 * units->y/absy->resolution;
|
|
|
|
|
|
|
|
|
|
return mm;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-15 11:04:04 +10:00
|
|
|
/**
|
|
|
|
|
* Convert the pair of coordinates in device space to mm. This takes the
|
|
|
|
|
* axis min into account, i.e. a unit of min is equivalent to 0 mm.
|
|
|
|
|
*/
|
|
|
|
|
static inline struct phys_coords
|
|
|
|
|
evdev_device_units_to_mm(const struct evdev_device* device,
|
|
|
|
|
const struct device_coords *units)
|
|
|
|
|
{
|
|
|
|
|
struct phys_coords mm = { 0, 0 };
|
|
|
|
|
const struct input_absinfo *absx, *absy;
|
|
|
|
|
|
|
|
|
|
if (device->abs.absinfo_x == NULL ||
|
|
|
|
|
device->abs.absinfo_y == NULL) {
|
|
|
|
|
log_bug_libinput(evdev_libinput_context(device),
|
|
|
|
|
"%s: is not an abs device\n",
|
|
|
|
|
device->devname);
|
|
|
|
|
return mm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
absx = device->abs.absinfo_x;
|
|
|
|
|
absy = device->abs.absinfo_y;
|
|
|
|
|
|
|
|
|
|
mm.x = (units->x - absx->minimum)/absx->resolution;
|
|
|
|
|
mm.y = (units->y - absy->minimum)/absy->resolution;
|
|
|
|
|
|
|
|
|
|
return mm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert the pair of coordinates in mm to device units. This takes the
|
|
|
|
|
* axis min into account, i.e. 0 mm is equivalent to the min.
|
|
|
|
|
*/
|
|
|
|
|
static inline struct device_coords
|
|
|
|
|
evdev_device_mm_to_units(const struct evdev_device *device,
|
|
|
|
|
const struct phys_coords *mm)
|
|
|
|
|
{
|
|
|
|
|
struct device_coords units = { 0, 0 };
|
|
|
|
|
const struct input_absinfo *absx, *absy;
|
|
|
|
|
|
|
|
|
|
if (device->abs.absinfo_x == NULL ||
|
|
|
|
|
device->abs.absinfo_y == NULL) {
|
|
|
|
|
log_bug_libinput(evdev_libinput_context(device),
|
|
|
|
|
"%s: is not an abs device\n",
|
|
|
|
|
device->devname);
|
|
|
|
|
return units;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
absx = device->abs.absinfo_x;
|
|
|
|
|
absy = device->abs.absinfo_y;
|
|
|
|
|
|
|
|
|
|
units.x = mm->x * absx->resolution + absx->minimum;
|
|
|
|
|
units.y = mm->y * absy->resolution + absy->minimum;
|
|
|
|
|
|
|
|
|
|
return units;
|
|
|
|
|
}
|
2016-11-28 14:58:18 +10:00
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
evdev_device_init_abs_range_warnings(struct evdev_device *device)
|
|
|
|
|
{
|
|
|
|
|
const struct input_absinfo *x, *y;
|
|
|
|
|
int width, height;
|
|
|
|
|
|
|
|
|
|
x = device->abs.absinfo_x;
|
|
|
|
|
y = device->abs.absinfo_y;
|
|
|
|
|
width = device->abs.dimensions.x;
|
|
|
|
|
height = device->abs.dimensions.y;
|
|
|
|
|
|
|
|
|
|
device->abs.warning_range.min.x = x->minimum - 0.05 * width;
|
|
|
|
|
device->abs.warning_range.min.y = y->minimum - 0.05 * height;
|
|
|
|
|
device->abs.warning_range.max.x = x->maximum + 0.05 * width;
|
|
|
|
|
device->abs.warning_range.max.y = y->maximum + 0.05 * height;
|
|
|
|
|
|
|
|
|
|
/* One warning every 5 min is enough */
|
|
|
|
|
ratelimit_init(&device->abs.warning_range.range_warn_limit,
|
|
|
|
|
s2us(3000),
|
|
|
|
|
1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
|
evdev_device_check_abs_axis_range(struct evdev_device *device,
|
|
|
|
|
unsigned int code,
|
|
|
|
|
int value)
|
|
|
|
|
{
|
|
|
|
|
int min, max;
|
|
|
|
|
|
|
|
|
|
switch(code) {
|
|
|
|
|
case ABS_X:
|
|
|
|
|
case ABS_MT_POSITION_X:
|
|
|
|
|
min = device->abs.warning_range.min.x;
|
|
|
|
|
max = device->abs.warning_range.max.x;
|
|
|
|
|
break;
|
|
|
|
|
case ABS_Y:
|
|
|
|
|
case ABS_MT_POSITION_Y:
|
|
|
|
|
min = device->abs.warning_range.min.y;
|
|
|
|
|
max = device->abs.warning_range.max.y;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value < min || value > max) {
|
|
|
|
|
log_info_ratelimit(evdev_libinput_context(device),
|
|
|
|
|
&device->abs.warning_range.range_warn_limit,
|
|
|
|
|
"Axis %#x value %d is outside expected range [%d, %d]\n"
|
|
|
|
|
"See %s/absolute_coordinate_ranges.html for details\n",
|
|
|
|
|
code, value, min, max,
|
|
|
|
|
HTTP_DOC_LINK);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
#endif /* EVDEV_H */
|