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"
|
|
|
|
|
|
2012-08-03 14:38:59 +03: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"
|
|
|
|
|
|
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-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;
|
2013-12-06 12:01:47 +10:00
|
|
|
const char *devname;
|
2012-08-03 14:38:59 +03:00
|
|
|
int fd;
|
|
|
|
|
struct {
|
|
|
|
|
int min_x, max_x, min_y, max_y;
|
|
|
|
|
int32_t x, y;
|
2012-12-03 19:44:16 +00:00
|
|
|
|
2014-01-30 22:44:49 +01:00
|
|
|
int32_t seat_slot;
|
|
|
|
|
|
2012-12-03 19:44:16 +00:00
|
|
|
int apply_calibration;
|
|
|
|
|
float calibration[6];
|
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 {
|
2013-11-10 17:55:40 +01:00
|
|
|
li_fixed_t dx, dy;
|
2012-08-03 14:38:59 +03:00
|
|
|
} rel;
|
|
|
|
|
|
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;
|
2012-08-03 14:38:59 +03:00
|
|
|
|
|
|
|
|
int is_mt;
|
|
|
|
|
};
|
|
|
|
|
|
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);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct evdev_dispatch {
|
|
|
|
|
struct evdev_dispatch_interface *interface;
|
|
|
|
|
};
|
|
|
|
|
|
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 14:54:31 +10:00
|
|
|
const char *sysname);
|
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);
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
void
|
|
|
|
|
evdev_device_proces_event(struct libinput_event *event);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
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);
|
|
|
|
|
|
2012-08-03 14:39:05 +03:00
|
|
|
void
|
2013-11-10 17:55:40 +01:00
|
|
|
evdev_device_calibrate(struct evdev_device *device, 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-01-25 11:53:53 +01:00
|
|
|
li_fixed_t
|
|
|
|
|
evdev_device_transform_x(struct evdev_device *device,
|
|
|
|
|
li_fixed_t x,
|
|
|
|
|
uint32_t width);
|
|
|
|
|
|
|
|
|
|
li_fixed_t
|
|
|
|
|
evdev_device_transform_y(struct evdev_device *device,
|
|
|
|
|
li_fixed_t y,
|
|
|
|
|
uint32_t height);
|
|
|
|
|
|
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
|
|
|
|
2012-08-03 14:38:59 +03:00
|
|
|
#endif /* EVDEV_H */
|