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-09-01 16:47:28 +10:00
|
|
|
#include <errno.h>
|
|
|
|
|
|
2014-06-03 07:51:37 +10:00
|
|
|
#include "linux/input.h"
|
2014-04-01 21:57:45 +02:00
|
|
|
|
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
|
|
|
|
2015-02-20 11:41:06 +10:00
|
|
|
#define LIBINPUT_TABLET_AXIS_MAX LIBINPUT_TABLET_AXIS_REL_WHEEL
|
2014-12-08 13:43:33 +10:00
|
|
|
|
2014-06-06 17:01:05 +02:00
|
|
|
struct libinput_source;
|
|
|
|
|
|
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);
|
2014-11-19 13:43:59 +10:00
|
|
|
int (*device_change_seat)(struct libinput_device *device,
|
|
|
|
|
const char *seat_name);
|
2013-12-13 11:37:31 +10:00
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
|
|
|
2014-06-06 17:01:05 +02:00
|
|
|
struct {
|
|
|
|
|
struct list list;
|
|
|
|
|
struct libinput_source *source;
|
|
|
|
|
int fd;
|
|
|
|
|
} timer;
|
|
|
|
|
|
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
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
struct list tool_list;
|
|
|
|
|
|
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;
|
2014-06-18 19:51:19 +10:00
|
|
|
|
|
|
|
|
libinput_log_handler log_handler;
|
|
|
|
|
enum libinput_log_priority log_priority;
|
2013-11-17 19:31:34 +01:00
|
|
|
void *user_data;
|
2014-06-25 00:06:58 +02:00
|
|
|
int refcount;
|
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
|
|
|
};
|
|
|
|
|
|
2014-01-07 11:42:32 +10:00
|
|
|
struct libinput_device_config_tap {
|
|
|
|
|
int (*count)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
|
2014-07-21 11:07:25 +10:00
|
|
|
enum libinput_config_tap_state enable);
|
|
|
|
|
enum libinput_config_tap_state (*get_enabled)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_tap_state (*get_default)(struct libinput_device *device);
|
2014-01-07 11:42:32 +10:00
|
|
|
};
|
|
|
|
|
|
2014-08-26 11:41:19 +10:00
|
|
|
struct libinput_device_config_calibration {
|
|
|
|
|
int (*has_matrix)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_matrix)(struct libinput_device *device,
|
|
|
|
|
const float matrix[6]);
|
|
|
|
|
int (*get_matrix)(struct libinput_device *device,
|
|
|
|
|
float matrix[6]);
|
|
|
|
|
int (*get_default_matrix)(struct libinput_device *device,
|
|
|
|
|
float matrix[6]);
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-30 16:18:55 +10:00
|
|
|
struct libinput_device_config_send_events {
|
|
|
|
|
uint32_t (*get_modes)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_mode)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_send_events_mode mode);
|
|
|
|
|
enum libinput_config_send_events_mode (*get_mode)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_send_events_mode (*get_default_mode)(struct libinput_device *device);
|
2014-01-07 11:42:32 +10:00
|
|
|
};
|
|
|
|
|
|
2014-05-15 15:46:19 +10:00
|
|
|
struct libinput_device_config_accel {
|
|
|
|
|
int (*available)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_speed)(struct libinput_device *device,
|
|
|
|
|
double speed);
|
|
|
|
|
double (*get_speed)(struct libinput_device *device);
|
|
|
|
|
double (*get_default_speed)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-18 15:10:19 +10:00
|
|
|
struct libinput_device_config_natural_scroll {
|
|
|
|
|
int (*has)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_enabled)(struct libinput_device *device,
|
|
|
|
|
int enabled);
|
|
|
|
|
int (*get_enabled)(struct libinput_device *device);
|
|
|
|
|
int (*get_default_enabled)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-22 16:48:41 +10:00
|
|
|
struct libinput_device_config_left_handed {
|
|
|
|
|
int (*has)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set)(struct libinput_device *device, int left_handed);
|
|
|
|
|
int (*get)(struct libinput_device *device);
|
|
|
|
|
int (*get_default)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
struct libinput_device_config_scroll_method {
|
|
|
|
|
uint32_t (*get_methods)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_method)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_scroll_method method);
|
|
|
|
|
enum libinput_config_scroll_method (*get_method)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_scroll_method (*get_default_method)(struct libinput_device *device);
|
2014-11-03 14:52:59 +01:00
|
|
|
enum libinput_config_status (*set_button)(struct libinput_device *device,
|
|
|
|
|
uint32_t button);
|
|
|
|
|
uint32_t (*get_button)(struct libinput_device *device);
|
|
|
|
|
uint32_t (*get_default_button)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-12-03 14:45:26 +10:00
|
|
|
struct libinput_device_config_click_method {
|
|
|
|
|
uint32_t (*get_methods)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_status (*set_method)(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_click_method method);
|
|
|
|
|
enum libinput_config_click_method (*get_method)(struct libinput_device *device);
|
|
|
|
|
enum libinput_config_click_method (*get_default_method)(struct libinput_device *device);
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-07 11:42:32 +10:00
|
|
|
struct libinput_device_config {
|
|
|
|
|
struct libinput_device_config_tap *tap;
|
2014-08-26 11:41:19 +10:00
|
|
|
struct libinput_device_config_calibration *calibration;
|
2014-01-30 16:18:55 +10:00
|
|
|
struct libinput_device_config_send_events *sendevents;
|
2014-05-15 15:46:19 +10:00
|
|
|
struct libinput_device_config_accel *accel;
|
2014-09-18 15:10:19 +10:00
|
|
|
struct libinput_device_config_natural_scroll *natural_scroll;
|
2014-09-22 16:48:41 +10:00
|
|
|
struct libinput_device_config_left_handed *left_handed;
|
2014-11-19 12:16:28 +10:00
|
|
|
struct libinput_device_config_scroll_method *scroll_method;
|
2014-12-03 14:45:26 +10:00
|
|
|
struct libinput_device_config_click_method *click_method;
|
2014-01-07 11:42:32 +10:00
|
|
|
};
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
struct libinput_device_group {
|
|
|
|
|
int refcount;
|
|
|
|
|
void *user_data;
|
2015-02-09 18:45:45 -05:00
|
|
|
char *identifier; /* unique identifier or NULL for singletons */
|
2015-02-05 13:39:04 +10: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 libinput_device {
|
|
|
|
|
struct libinput_seat *seat;
|
2015-02-05 13:39:04 +10:00
|
|
|
struct libinput_device_group *group;
|
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;
|
2014-09-28 13:21:02 +02:00
|
|
|
struct list event_listeners;
|
2013-11-17 19:31:34 +01:00
|
|
|
void *user_data;
|
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;
|
2014-01-07 11:42:32 +10:00
|
|
|
struct libinput_device_config config;
|
2014-06-10 16:44:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct libinput_tool {
|
|
|
|
|
struct list link;
|
|
|
|
|
uint32_t serial;
|
2015-02-19 14:56:34 +10:00
|
|
|
uint32_t tool_id;
|
2014-06-10 16:44:02 -04:00
|
|
|
enum libinput_tool_type type;
|
2015-02-10 11:29:34 +10:00
|
|
|
unsigned char axis_caps[NCHARS(LIBINPUT_TABLET_AXIS_MAX + 1)];
|
2015-02-18 13:53:31 +10:00
|
|
|
unsigned char buttons[NCHARS(KEY_MAX) + 1];
|
2014-06-10 16:44:02 -04:00
|
|
|
int refcount;
|
2014-08-05 17:49:39 -04:00
|
|
|
void *user_data;
|
2013-11-17 11:19:50 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:03 +02:00
|
|
|
struct libinput_event {
|
|
|
|
|
enum libinput_event_type type;
|
|
|
|
|
struct libinput_device *device;
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:02 +02:00
|
|
|
struct libinput_event_listener {
|
|
|
|
|
struct list link;
|
|
|
|
|
void (*notify_func)(uint64_t time, struct libinput_event *ev, void *notify_func_data);
|
|
|
|
|
void *notify_func_data;
|
|
|
|
|
};
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
typedef void (*libinput_source_dispatch_t)(void *data);
|
|
|
|
|
|
2014-06-18 19:51:19 +10:00
|
|
|
#define log_debug(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_DEBUG, __VA_ARGS__)
|
|
|
|
|
#define log_info(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_INFO, __VA_ARGS__)
|
|
|
|
|
#define log_error(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, __VA_ARGS__)
|
|
|
|
|
#define log_bug_kernel(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, "kernel bug: " __VA_ARGS__)
|
2014-09-17 15:11:41 +10:00
|
|
|
#define log_bug_libinput(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, "libinput bug: " __VA_ARGS__)
|
|
|
|
|
#define log_bug_client(li_, ...) log_msg((li_), LIBINPUT_LOG_PRIORITY_ERROR, "client bug: " __VA_ARGS__)
|
2014-02-12 14:20:18 +10:00
|
|
|
|
|
|
|
|
void
|
2014-06-18 19:51:19 +10:00
|
|
|
log_msg(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format, ...);
|
|
|
|
|
|
2014-06-10 15:08:03 +02:00
|
|
|
void
|
2014-06-18 19:51:19 +10:00
|
|
|
log_msg_va(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority,
|
2014-06-10 15:08:03 +02:00
|
|
|
const char *format,
|
|
|
|
|
va_list args);
|
2014-02-12 14:20:18 +10: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
|
|
|
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);
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
struct libinput_device_group *
|
2015-02-09 18:45:45 -05:00
|
|
|
libinput_device_group_create(const char *identifier);
|
2015-02-05 13:39:04 +10:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_set_device_group(struct libinput_device *device,
|
|
|
|
|
struct libinput_device_group *group);
|
|
|
|
|
|
2014-09-28 13:21:02 +02:00
|
|
|
void
|
|
|
|
|
libinput_device_add_event_listener(struct libinput_device *device,
|
|
|
|
|
struct libinput_event_listener *listener,
|
|
|
|
|
void (*notify_func)(
|
|
|
|
|
uint64_t time,
|
|
|
|
|
struct libinput_event *event,
|
|
|
|
|
void *notify_func_data),
|
|
|
|
|
void *notify_func_data);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_remove_event_listener(struct libinput_event_listener *listener);
|
|
|
|
|
|
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
|
|
|
|
|
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,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2013-11-10 17:55:40 +01:00
|
|
|
uint32_t key,
|
2014-06-17 07:55:35 +10:00
|
|
|
enum libinput_key_state state);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_motion(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-06-02 23:09:27 +02:00
|
|
|
double dx,
|
2014-12-04 11:44:09 +08:00
|
|
|
double dy,
|
2015-02-18 07:43:03 +10:00
|
|
|
double dx_unaccel,
|
|
|
|
|
double dy_unaccel);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_motion_absolute(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-06-02 23:09:27 +02:00
|
|
|
double x,
|
|
|
|
|
double y);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_button(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2013-11-10 17:55:40 +01:00
|
|
|
int32_t button,
|
2014-06-03 20:08:02 -04:00
|
|
|
enum libinput_button_state state);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
pointer_notify_axis(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-12-24 11:10:04 +10:00
|
|
|
uint32_t axes,
|
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-01-15 09:48:29 +10:00
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
double x_discrete,
|
|
|
|
|
double y_discrete);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
void
|
2014-02-19 21:39:26 +01:00
|
|
|
touch_notify_touch_down(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-02-19 21:39:26 +01:00
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot,
|
2014-06-02 23:09:27 +02:00
|
|
|
double x,
|
|
|
|
|
double y);
|
2014-02-19 21:39:26 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_notify_touch_motion(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-02-19 21:39:26 +01:00
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot,
|
2014-06-02 23:09:27 +02:00
|
|
|
double x,
|
|
|
|
|
double y);
|
2014-02-19 21:39:26 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
touch_notify_touch_up(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time,
|
2014-02-19 21:39:26 +01:00
|
|
|
int32_t slot,
|
|
|
|
|
int32_t seat_slot);
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
void
|
|
|
|
|
tablet_notify_axis(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
2014-06-26 21:31:52 -04:00
|
|
|
struct libinput_tool *tool,
|
2014-06-05 23:20:36 -04:00
|
|
|
unsigned char *changed_axes,
|
2015-02-20 12:03:52 +10:00
|
|
|
double *axes,
|
|
|
|
|
double *deltas);
|
2014-06-05 23:20:36 -04:00
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
void
|
2015-02-16 22:48:42 -05:00
|
|
|
tablet_notify_proximity(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
|
|
|
|
struct libinput_tool *tool,
|
|
|
|
|
enum libinput_tool_proximity_state state,
|
2015-02-16 22:48:44 -05:00
|
|
|
unsigned char *changed_axes,
|
2015-02-16 22:48:42 -05:00
|
|
|
double *axes);
|
2014-06-06 16:35:33 -04:00
|
|
|
|
2013-12-20 10:15:00 +10:00
|
|
|
void
|
2014-06-10 23:14:41 -04:00
|
|
|
tablet_notify_button(struct libinput_device *device,
|
|
|
|
|
uint32_t time,
|
2014-06-26 21:31:52 -04:00
|
|
|
struct libinput_tool *tool,
|
2014-06-26 21:31:54 -04:00
|
|
|
double *axes,
|
2014-06-10 23:14:41 -04:00
|
|
|
int32_t button,
|
|
|
|
|
enum libinput_button_state state);
|
|
|
|
|
void
|
2013-12-20 10:15:00 +10:00
|
|
|
touch_notify_frame(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time);
|
2014-09-01 16:47:28 +10:00
|
|
|
|
|
|
|
|
static inline uint64_t
|
|
|
|
|
libinput_now(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
struct timespec ts = { 0, 0 };
|
|
|
|
|
|
|
|
|
|
if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
|
|
|
|
|
log_error(libinput, "clock_gettime failed: %s\n", strerror(errno));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000;
|
|
|
|
|
}
|
2013-11-10 17:55:40 +01:00
|
|
|
#endif /* LIBINPUT_PRIVATE_H */
|