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"
|
2013-11-10 17:55:40 +01: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),
|
2014-09-03 15:50:28 +10:00
|
|
|
};
|
|
|
|
|
|
2014-04-22 23:02:14 +02:00
|
|
|
struct mt_slot {
|
|
|
|
|
int32_t seat_slot;
|
|
|
|
|
int32_t x, y;
|
|
|
|
|
};
|
|
|
|
|
|
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;
|
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;
|
2012-08-03 14:38:59 +03:00
|
|
|
char *devnode;
|
2013-12-15 17:50:04 +01:00
|
|
|
char *sysname;
|
2014-01-30 16:33:24 +10:00
|
|
|
char *syspath;
|
2013-12-06 12:01:47 +10:00
|
|
|
const char *devname;
|
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
|
|
|
|
2014-07-24 16:15:43 +10:00
|
|
|
int32_t x, y;
|
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;
|
|
|
|
|
|
|
|
|
|
struct {
|
2014-06-02 23:09:27 +02:00
|
|
|
int dx, dy;
|
2012-08-03 14:38:59 +03:00
|
|
|
} rel;
|
|
|
|
|
|
2014-09-16 16:22:35 +02:00
|
|
|
struct {
|
2014-09-16 16:22:36 +02:00
|
|
|
struct libinput_timer timer;
|
|
|
|
|
bool has_middle_button_scroll;
|
|
|
|
|
bool middle_button_scroll_active;
|
2014-09-16 16:22:35 +02:00
|
|
|
double threshold;
|
|
|
|
|
uint32_t direction;
|
|
|
|
|
} 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 {
|
|
|
|
|
struct libinput_device_config_left_handed config_left_handed;
|
|
|
|
|
/* left-handed currently enabled */
|
|
|
|
|
bool left_handed;
|
|
|
|
|
/* set during device init if we want left_handed config,
|
|
|
|
|
* used at runtime to delay the effect until buttons are up */
|
|
|
|
|
bool want_left_handed;
|
|
|
|
|
/* Checks if buttons are down and commits the setting */
|
|
|
|
|
void (*change_to_left_handed)(struct evdev_device *device);
|
|
|
|
|
} buttons;
|
2014-10-29 09:56:27 -05:00
|
|
|
|
|
|
|
|
/* The number of times libevdev processes a SYN_DROPPED, so we can
|
|
|
|
|
* stop logging them to avoid flooding the logs. */
|
|
|
|
|
int syn_drops_received;
|
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
|
|
|
|
|
|
|
|
/* 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,
|
|
|
|
|
const char *devnode,
|
2014-01-30 16:33:24 +10:00
|
|
|
const char *sysname,
|
|
|
|
|
const char *syspath);
|
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-07-04 09:44:43 +10:00
|
|
|
int
|
|
|
|
|
evdev_device_init_pointer_acceleration(struct evdev_device *device);
|
|
|
|
|
|
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-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-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);
|
|
|
|
|
|
2014-09-16 16:22:35 +02:00
|
|
|
void
|
|
|
|
|
evdev_post_scroll(struct evdev_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
double dx,
|
|
|
|
|
double dy);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
evdev_stop_scroll(struct evdev_device *device, uint64_t time);
|
|
|
|
|
|
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
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (device->buttons.left_handed) {
|
|
|
|
|
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 */
|