2013-11-10 17:55:40 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 Jonas Ådahl
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef LIBINPUT_PRIVATE_H
|
|
|
|
|
#define LIBINPUT_PRIVATE_H
|
|
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
#include "libinput.h"
|
2013-11-17 11:19:50 +01:00
|
|
|
#include "libinput-util.h"
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2013-12-13 11:37:31 +10:00
|
|
|
struct libinput_interface_backend {
|
|
|
|
|
int (*resume)(struct libinput *libinput);
|
|
|
|
|
void (*suspend)(struct libinput *libinput);
|
|
|
|
|
void (*destroy)(struct libinput *libinput);
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput {
|
|
|
|
|
int epoll_fd;
|
|
|
|
|
struct list source_destroy_list;
|
2013-11-10 17:55:40 +01:00
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct list seat_list;
|
|
|
|
|
|
2013-11-16 19:32:46 +01:00
|
|
|
struct libinput_event **events;
|
|
|
|
|
size_t events_count;
|
|
|
|
|
size_t events_len;
|
|
|
|
|
size_t events_in;
|
|
|
|
|
size_t events_out;
|
2013-11-17 19:31:34 +01:00
|
|
|
|
|
|
|
|
const struct libinput_interface *interface;
|
2013-12-13 11:37:31 +10:00
|
|
|
const struct libinput_interface_backend *interface_backend;
|
2013-11-17 19:31:34 +01:00
|
|
|
void *user_data;
|
2013-11-10 17:55:40 +01:00
|
|
|
};
|
|
|
|
|
|
2013-12-13 11:37:31 +10:00
|
|
|
typedef void (*libinput_seat_destroy_func) (struct libinput_seat *seat);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct libinput_seat {
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput *libinput;
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
struct list link;
|
|
|
|
|
struct list devices_list;
|
|
|
|
|
void *user_data;
|
|
|
|
|
int refcount;
|
2014-03-19 23:38:45 +01:00
|
|
|
libinput_seat_destroy_func destroy;
|
|
|
|
|
|
2014-01-15 17:04:00 +10:00
|
|
|
char *physical_name;
|
|
|
|
|
char *logical_name;
|
2014-03-19 23:38:45 +01:00
|
|
|
|
|
|
|
|
uint32_t slot_map;
|
2014-04-01 21:57:45 +02:00
|
|
|
|
|
|
|
|
uint32_t button_count[KEY_CNT];
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct libinput_device {
|
|
|
|
|
struct libinput_seat *seat;
|
|
|
|
|
struct list link;
|
2013-11-17 19:31:34 +01:00
|
|
|
void *user_data;
|
2013-11-17 16:59:09 +01:00
|
|
|
int terminated;
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
int refcount;
|
2013-11-17 11:19:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef void (*libinput_source_dispatch_t)(void *data);
|
|
|
|
|
|
|
|
|
|
struct libinput_source;
|
|
|
|
|
|
2014-02-12 14:20:18 +10:00
|
|
|
#define log_debug(...) log_msg(LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
|
|
|
|
|
#define log_info(...) log_msg(LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
|
|
|
|
|
#define log_error(...) log_msg(LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
|
2014-04-15 14:28:09 +02:00
|
|
|
#define log_bug(...) log_msg(LIBINPUT_LOG_PRIORITY_ERROR, "BUG: "__VA_ARGS__)
|
2014-02-12 14:20:18 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
log_msg(enum libinput_log_priority priority, const char *format, ...);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
int
|
|
|
|
|
libinput_init(struct libinput *libinput,
|
|
|
|
|
const struct libinput_interface *interface,
|
2013-12-13 11:37:31 +10:00
|
|
|
const struct libinput_interface_backend *interface_backend,
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
void *user_data);
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput_source *
|
|
|
|
|
libinput_add_fd(struct libinput *libinput,
|
|
|
|
|
int fd,
|
|
|
|
|
libinput_source_dispatch_t dispatch,
|
|
|
|
|
void *data);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_remove_source(struct libinput *libinput,
|
|
|
|
|
struct libinput_source *source);
|
|
|
|
|
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
int
|
|
|
|
|
open_restricted(struct libinput *libinput,
|
|
|
|
|
const char *path, int flags);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
close_restricted(struct libinput *libinput, int fd);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_seat_init(struct libinput_seat *seat,
|
|
|
|
|
struct libinput *libinput,
|
2014-01-15 17:04:00 +10:00
|
|
|
const char *physical_name,
|
|
|
|
|
const char *logical_name,
|
2013-12-13 11:37:31 +10:00
|
|
|
libinput_seat_destroy_func destroy);
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_init(struct libinput_device *device,
|
|
|
|
|
struct libinput_seat *seat);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
notify_added_device(struct libinput_device *device);
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
void
|
Port udev-seat to be used in libinput
This patch ports udev-seat from weston to libinput, including adapting
libinput internals and API to provide seat and device discovery.
The public API is extended with device discovery, object reference, a
seat object. As libinput takes care of creating and destroying its
objects user data getter/setter is added in order to make it possible
for the client to directly associate an object application side with an
object library side.
Device discovery API is made up of the 'seat added', 'seat removed',
'device added' and 'device removed' events. The seat added/removed
events contains a pointer to a libinput_seat struct, while the device
added/removed events contains a pointer to a libinput_device event.
The objects are reference counted with libinput holding one reference by
default. The application can increase the reference count with
libinput_seat_ref() and libinput_device_ref() and decrease the reference
count with libinput_seat_unref() and libinput_device_unref().
The basic event struct is changed to have a 'target' union parameter
that can be either a libinput, libinput_seat or libinput_device struct
pointer.
There is one known problem with the current API that is the potentially
racy initialization.
The problem is when a device is both discovered and lost during initial
dispatchig, causing libinput to first queue a 'added' message, creating
the device with default reference count 1, then before going back to the
application queuing a 'removed' message, while at same time decreasing
reference count of the device to 0, causing it o be destroyed. The queue
will at this state contain two messages with pointers to free:ed memory.
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2013-11-23 13:04:32 +01:00
|
|
|
notify_removed_device(struct libinput_device *device);
|
2013-11-17 11:19:50 +01:00
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
void
|
|
|
|
|
keyboard_notify_key(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
uint32_t key,
|
|
|
|
|
enum libinput_keyboard_key_state state);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_motion(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
li_fixed_t dx,
|
|
|
|
|
li_fixed_t dy);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_motion_absolute(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
li_fixed_t x,
|
|
|
|
|
li_fixed_t y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_button(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
int32_t button,
|
|
|
|
|
enum libinput_pointer_button_state state);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_axis(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
enum libinput_pointer_axis axis,
|
|
|
|
|
li_fixed_t value);
|
|
|
|
|
|
|
|
|
|
void
|
2014-02-19 21:39:26 +01:00
|
|
|
touch_notify_touch_down(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot,
|
|
|
|
|
li_fixed_t x,
|
|
|
|
|
li_fixed_t y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_notify_touch_motion(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot,
|
|
|
|
|
li_fixed_t x,
|
|
|
|
|
li_fixed_t y);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_notify_touch_up(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2013-12-20 10:15:00 +10:00
|
|
|
void
|
|
|
|
|
touch_notify_frame(struct libinput_device *device,
|
|
|
|
|
uint32_t time);
|
2013-11-10 17:55:40 +01:00
|
|
|
#endif /* LIBINPUT_PRIVATE_H */
|