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
|
2011-12-19 01:14:03 +02:00
|
|
|
*
|
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and
|
|
|
|
|
* its documentation for any purpose is hereby granted without fee, provided
|
|
|
|
|
* that the above copyright notice appear in all copies and that both that
|
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
|
* documentation, and that the name of the copyright holders not be used in
|
|
|
|
|
* advertising or publicity pertaining to distribution of the software
|
|
|
|
|
* without specific, written prior permission. The copyright holders make
|
|
|
|
|
* no representations about the suitability of this software for any
|
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
|
*
|
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
|
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
|
|
|
|
|
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
|
|
|
|
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
|
|
|
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
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-06 14:18:59 +10:00
|
|
|
/* The HW DPI rate we normalize to before calculating pointer acceleration */
|
|
|
|
|
#define DEFAULT_MOUSE_DPI 1000
|
2015-04-01 11:03:19 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The constant (linear) acceleration factor we use to normalize trackpoint
|
|
|
|
|
* deltas before calculating pointer acceleration.
|
|
|
|
|
*/
|
|
|
|
|
#define DEFAULT_TRACKPOINT_ACCEL 1.0
|
|
|
|
|
|
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),
|
|
|
|
|
EVDEV_DEVICE_TOUCH = (1 << 2)
|
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),
|
2014-09-16 16:22:38 +02:00
|
|
|
EVDEV_TAG_TRACKPOINT = (1 << 2),
|
2015-01-28 15:38:00 +10:00
|
|
|
EVDEV_TAG_TOUCHPAD_TRACKPOINT = (1 << 3),
|
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 {
|
|
|
|
|
EVDEV_MODEL_DEFAULT,
|
|
|
|
|
};
|
|
|
|
|
|
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;
|
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;
|
|
|
|
|
struct {
|
2014-06-19 11:11:36 +10:00
|
|
|
const struct input_absinfo *absinfo_x, *absinfo_y;
|
2014-07-24 16:15:43 +10:00
|
|
|
int fake_resolution;
|
2012-12-03 19:44:16 +00:00
|
|
|
|
2015-03-11 08:35:38 +10:00
|
|
|
struct device_coords point;
|
2014-01-30 22:44:49 +01:00
|
|
|
int32_t seat_slot;
|
|
|
|
|
|
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 */
|
2012-08-03 14:38:59 +03:00
|
|
|
} abs;
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
int slot;
|
2014-04-22 23:02:14 +02:00
|
|
|
struct mt_slot *slots;
|
|
|
|
|
size_t slots_len;
|
2012-08-03 14:38:59 +03:00
|
|
|
} mt;
|
|
|
|
|
struct mtdev *mtdev;
|
|
|
|
|
|
2015-03-11 08:35:38 +10:00
|
|
|
struct device_coords rel;
|
2012-08-03 14:38:59 +03:00
|
|
|
|
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;
|
|
|
|
|
/* 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);
|
2014-11-06 13:39:51 +01:00
|
|
|
bool button_scroll_active;
|
2014-09-16 16:22:35 +02:00
|
|
|
double threshold;
|
|
|
|
|
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 */
|
|
|
|
|
int wheel_click_angle;
|
2014-09-16 16:22:35 +02:00
|
|
|
} scroll;
|
|
|
|
|
|
2013-09-24 12:09:03 +01:00
|
|
|
enum evdev_event_type pending_event;
|
2013-10-17 23:04:05 +02:00
|
|
|
enum evdev_device_seat_capability seat_caps;
|
2014-09-03 15:50:28 +10:00
|
|
|
enum evdev_device_tags tags;
|
2012-08-03 14:38:59 +03:00
|
|
|
|
|
|
|
|
int is_mt;
|
2014-09-16 16:22:37 +02:00
|
|
|
int suspended;
|
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
|
|
|
|
|
|
|
|
/* Bitmask of pressed keys used to ignore initial release events from
|
|
|
|
|
* the kernel. */
|
2014-08-22 10:41:20 +10:00
|
|
|
unsigned long hw_key_mask[NLONGS(KEY_CNT)];
|
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;
|
|
|
|
|
|
2014-10-30 16:34:15 -05:00
|
|
|
int dpi; /* HW resolution */
|
2014-11-05 13:32:17 +01:00
|
|
|
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
|
2015-04-20 14:29:44 -04:00
|
|
|
|
|
|
|
|
enum evdev_device_model model;
|
2012-08-03 14:38:59 +03: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
|
|
|
|
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);
|
|
|
|
|
|
2014-09-03 15:50:28 +10:00
|
|
|
/* Tag device with one of EVDEV_TAG */
|
|
|
|
|
void (*tag_device)(struct evdev_device *device,
|
|
|
|
|
struct udev_device *udev_device);
|
2012-08-03 14:38:59 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct evdev_dispatch {
|
|
|
|
|
struct evdev_dispatch_interface *interface;
|
2014-08-26 11:41:19 +10:00
|
|
|
struct libinput_device_config_calibration calibration;
|
2014-08-22 13:40:40 +10:00
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
struct libinput_device_config_send_events config;
|
|
|
|
|
enum libinput_config_send_events_mode current_mode;
|
|
|
|
|
} sendevents;
|
2012-08-03 14:38:59 +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
|
|
|
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-03-17 10:07:00 +10:00
|
|
|
int
|
|
|
|
|
evdev_fix_abs_resolution(struct evdev_device *device,
|
|
|
|
|
unsigned int xcode,
|
|
|
|
|
unsigned int ycode,
|
|
|
|
|
int yresolution,
|
|
|
|
|
int xresolution);
|
|
|
|
|
|
2014-07-04 09:44:43 +10:00
|
|
|
int
|
2015-03-13 13:56:14 +10:00
|
|
|
evdev_device_init_pointer_acceleration(struct evdev_device *device,
|
|
|
|
|
accel_profile_func_t profile);
|
2014-07-04 09:44:43 +10: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);
|
|
|
|
|
|
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);
|
|
|
|
|
|
2014-08-26 13:44:03 +10:00
|
|
|
void
|
|
|
|
|
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
|
|
|
|
2013-12-15 17:45:02 +01:00
|
|
|
int
|
|
|
|
|
evdev_device_has_capability(struct evdev_device *device,
|
|
|
|
|
enum libinput_device_capability capability);
|
|
|
|
|
|
2014-06-17 15:45:07 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_get_size(struct evdev_device *device,
|
|
|
|
|
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);
|
|
|
|
|
|
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);
|
2014-01-30 15:34:00 +10:00
|
|
|
int
|
|
|
|
|
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_keyboard_notify_key(struct evdev_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
int key,
|
|
|
|
|
enum libinput_key_state state);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
evdev_pointer_notify_button(struct evdev_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
int button,
|
|
|
|
|
enum libinput_button_state state);
|
2015-04-13 14:47:26 +10:00
|
|
|
void
|
|
|
|
|
evdev_pointer_notify_physical_button(struct evdev_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
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);
|
|
|
|
|
|
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-09-16 16:22:35 +02: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);
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-23 13:48:06 +10:00
|
|
|
int
|
|
|
|
|
evdev_init_left_handed(struct evdev_device *device,
|
|
|
|
|
void (*change_to_left_handed)(struct evdev_device *));
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
#endif /* EVDEV_H */
|