#include "libinput.h"
#include "libinput-private.h"
#include "evdev.h"
+#include "timer.h"
struct libinput_source {
libinput_source_dispatch_t dispatch;
struct libinput_event_device_notify {
struct libinput_event base;
- struct libinput_device *device;
};
struct libinput_event_keyboard {
struct libinput_event base;
uint32_t time;
uint32_t key;
- enum libinput_keyboard_key_state state;
+ uint32_t seat_key_count;
+ enum libinput_key_state state;
};
struct libinput_event_pointer {
struct libinput_event base;
uint32_t time;
- li_fixed_t x;
- li_fixed_t y;
+ double x;
+ double y;
uint32_t button;
- enum libinput_pointer_button_state state;
+ uint32_t seat_button_count;
+ enum libinput_button_state state;
enum libinput_pointer_axis axis;
- li_fixed_t value;
+ double value;
};
struct libinput_event_touch {
struct libinput_event base;
uint32_t time;
- uint32_t slot;
- li_fixed_t x;
- li_fixed_t y;
- enum libinput_touch_type touch_type;
+ int32_t slot;
+ int32_t seat_slot;
+ double x;
+ double y;
};
static void
+libinput_default_log_func(struct libinput *libinput,
+ enum libinput_log_priority priority,
+ const char *format, va_list args)
+{
+ const char *prefix;
+
+ switch(priority) {
+ case LIBINPUT_LOG_PRIORITY_DEBUG: prefix = "debug"; break;
+ case LIBINPUT_LOG_PRIORITY_INFO: prefix = "info"; break;
+ case LIBINPUT_LOG_PRIORITY_ERROR: prefix = "error"; break;
+ default: prefix="<invalid priority>"; break;
+ }
+
+ fprintf(stderr, "libinput %s: ", prefix);
+ vfprintf(stderr, format, args);
+}
+
+void
+log_msg_va(struct libinput *libinput,
+ enum libinput_log_priority priority,
+ const char *format,
+ va_list args)
+{
+ if (libinput->log_handler &&
+ libinput->log_priority <= priority)
+ libinput->log_handler(libinput, priority, format, args);
+}
+
+void
+log_msg(struct libinput *libinput,
+ enum libinput_log_priority priority,
+ const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+ log_msg_va(libinput, priority, format, args);
+ va_end(args);
+}
+
+LIBINPUT_EXPORT void
+libinput_log_set_priority(struct libinput *libinput,
+ enum libinput_log_priority priority)
+{
+ libinput->log_priority = priority;
+}
+
+LIBINPUT_EXPORT enum libinput_log_priority
+libinput_log_get_priority(const struct libinput *libinput)
+{
+ return libinput->log_priority;
+}
+
+LIBINPUT_EXPORT void
+libinput_log_set_handler(struct libinput *libinput,
+ libinput_log_handler log_handler)
+{
+ libinput->log_handler = log_handler;
+}
+
+static void
libinput_post_event(struct libinput *libinput,
struct libinput_event *event);
return event->type;
}
-LIBINPUT_EXPORT struct libinput*
+LIBINPUT_EXPORT struct libinput *
libinput_event_get_context(struct libinput_event *event)
{
return event->device->seat->libinput;
}
-LIBINPUT_EXPORT struct libinput_device*
+LIBINPUT_EXPORT struct libinput_device *
libinput_event_get_device(struct libinput_event *event)
{
return event->device;
}
-LIBINPUT_EXPORT struct libinput_event_pointer*
+LIBINPUT_EXPORT struct libinput_event_pointer *
libinput_event_get_pointer_event(struct libinput_event *event)
{
switch (event->type) {
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
- return (struct libinput_event_pointer*)event;
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ return (struct libinput_event_pointer *) event;
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
}
return NULL;
}
-LIBINPUT_EXPORT struct libinput_event_keyboard*
+LIBINPUT_EXPORT struct libinput_event_keyboard *
libinput_event_get_keyboard_event(struct libinput_event *event)
{
switch (event->type) {
case LIBINPUT_EVENT_DEVICE_REMOVED:
break;
case LIBINPUT_EVENT_KEYBOARD_KEY:
- return (struct libinput_event_keyboard*)event;
+ return (struct libinput_event_keyboard *) event;
case LIBINPUT_EVENT_POINTER_MOTION:
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
}
return NULL;
}
-LIBINPUT_EXPORT struct libinput_event_touch*
+LIBINPUT_EXPORT struct libinput_event_touch *
libinput_event_get_touch_event(struct libinput_event *event)
{
switch (event->type) {
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
break;
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
- return (struct libinput_event_touch*)event;
+ return (struct libinput_event_touch *) event;
}
return NULL;
}
-LIBINPUT_EXPORT struct libinput_event_device_notify*
+LIBINPUT_EXPORT struct libinput_event_device_notify *
libinput_event_get_device_notify_event(struct libinput_event *event)
{
switch (event->type) {
abort(); /* not used as actual event type */
case LIBINPUT_EVENT_DEVICE_ADDED:
case LIBINPUT_EVENT_DEVICE_REMOVED:
- return (struct libinput_event_device_notify*)event;
+ return (struct libinput_event_device_notify *) event;
case LIBINPUT_EVENT_KEYBOARD_KEY:
case LIBINPUT_EVENT_POINTER_MOTION:
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
case LIBINPUT_EVENT_POINTER_BUTTON:
case LIBINPUT_EVENT_POINTER_AXIS:
- case LIBINPUT_EVENT_TOUCH_TOUCH:
+ case LIBINPUT_EVENT_TOUCH_DOWN:
+ case LIBINPUT_EVENT_TOUCH_UP:
+ case LIBINPUT_EVENT_TOUCH_MOTION:
+ case LIBINPUT_EVENT_TOUCH_CANCEL:
case LIBINPUT_EVENT_TOUCH_FRAME:
break;
}
}
LIBINPUT_EXPORT uint32_t
-libinput_event_keyboard_get_time(
- struct libinput_event_keyboard *event)
+libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
{
return event->time;
}
LIBINPUT_EXPORT uint32_t
-libinput_event_keyboard_get_key(
- struct libinput_event_keyboard *event)
+libinput_event_keyboard_get_key(struct libinput_event_keyboard *event)
{
return event->key;
}
-LIBINPUT_EXPORT enum libinput_keyboard_key_state
-libinput_event_keyboard_get_key_state(
- struct libinput_event_keyboard *event)
+LIBINPUT_EXPORT enum libinput_key_state
+libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event)
{
return event->state;
}
LIBINPUT_EXPORT uint32_t
-libinput_event_pointer_get_time(
- struct libinput_event_pointer *event)
+libinput_event_keyboard_get_seat_key_count(
+ struct libinput_event_keyboard *event)
+{
+ return event->seat_key_count;
+}
+
+LIBINPUT_EXPORT uint32_t
+libinput_event_pointer_get_time(struct libinput_event_pointer *event)
{
return event->time;
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_pointer_get_dx(
- struct libinput_event_pointer *event)
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
{
return event->x;
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_pointer_get_dy(
- struct libinput_event_pointer *event)
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
{
return event->y;
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_pointer_get_absolute_x(
- struct libinput_event_pointer *event)
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
{
- return event->x;
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_convert_to_mm(device->abs.absinfo_x, event->x);
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_pointer_get_absolute_y(
- struct libinput_event_pointer *event)
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
{
- return event->y;
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_convert_to_mm(device->abs.absinfo_y, event->y);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_absolute_x_transformed(
+ struct libinput_event_pointer *event,
+ uint32_t width)
+{
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_device_transform_x(device, event->x, width);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_absolute_y_transformed(
+ struct libinput_event_pointer *event,
+ uint32_t height)
+{
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_device_transform_y(device, event->y, height);
}
LIBINPUT_EXPORT uint32_t
-libinput_event_pointer_get_button(
- struct libinput_event_pointer *event)
+libinput_event_pointer_get_button(struct libinput_event_pointer *event)
{
return event->button;
}
-LIBINPUT_EXPORT enum libinput_pointer_button_state
-libinput_event_pointer_get_button_state(
- struct libinput_event_pointer *event)
+LIBINPUT_EXPORT enum libinput_button_state
+libinput_event_pointer_get_button_state(struct libinput_event_pointer *event)
{
return event->state;
}
-LIBINPUT_EXPORT enum libinput_pointer_axis
-libinput_event_pointer_get_axis(
+LIBINPUT_EXPORT uint32_t
+libinput_event_pointer_get_seat_button_count(
struct libinput_event_pointer *event)
{
+ return event->seat_button_count;
+}
+
+LIBINPUT_EXPORT enum libinput_pointer_axis
+libinput_event_pointer_get_axis(struct libinput_event_pointer *event)
+{
return event->axis;
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_pointer_get_axis_value(
- struct libinput_event_pointer *event)
+LIBINPUT_EXPORT double
+libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event)
{
return event->value;
}
LIBINPUT_EXPORT uint32_t
-libinput_event_touch_get_time(
- struct libinput_event_touch *event)
+libinput_event_touch_get_time(struct libinput_event_touch *event)
{
return event->time;
}
-LIBINPUT_EXPORT uint32_t
-libinput_event_touch_get_slot(
- struct libinput_event_touch *event)
+LIBINPUT_EXPORT int32_t
+libinput_event_touch_get_slot(struct libinput_event_touch *event)
{
return event->slot;
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_touch_get_x(
- struct libinput_event_touch *event)
+LIBINPUT_EXPORT int32_t
+libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
{
- return event->x;
+ return event->seat_slot;
}
-LIBINPUT_EXPORT li_fixed_t
-libinput_event_touch_get_y(
- struct libinput_event_touch *event)
+LIBINPUT_EXPORT double
+libinput_event_touch_get_x(struct libinput_event_touch *event)
{
- return event->y;
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_convert_to_mm(device->abs.absinfo_x, event->x);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
+ uint32_t width)
+{
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_device_transform_x(device, event->x, width);
+}
+
+LIBINPUT_EXPORT double
+libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
+ uint32_t height)
+{
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_device_transform_y(device, event->y, height);
}
-LIBINPUT_EXPORT enum libinput_touch_type
-libinput_event_touch_get_touch_type(
- struct libinput_event_touch *event)
+LIBINPUT_EXPORT double
+libinput_event_touch_get_y(struct libinput_event_touch *event)
{
- return event->touch_type;
+ struct evdev_device *device =
+ (struct evdev_device *) event->base.device;
+
+ return evdev_convert_to_mm(device->abs.absinfo_y, event->y);
}
struct libinput_source *
struct libinput_source *source)
{
epoll_ctl(libinput->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
- close(source->fd);
source->fd = -1;
list_insert(&libinput->source_destroy_list, &source->link);
}
return -1;
}
+ libinput->log_handler = libinput_default_log_func;
+ libinput->log_priority = LIBINPUT_LOG_PRIORITY_ERROR;
libinput->interface = interface;
libinput->interface_backend = interface_backend;
libinput->user_data = user_data;
+ libinput->refcount = 1;
list_init(&libinput->source_destroy_list);
list_init(&libinput->seat_list);
+ if (libinput_timer_subsys_init(libinput) != 0) {
+ free(libinput->events);
+ close(libinput->epoll_fd);
+ return -1;
+ }
+
return 0;
}
list_init(&libinput->source_destroy_list);
}
-LIBINPUT_EXPORT void
-libinput_destroy(struct libinput *libinput)
+LIBINPUT_EXPORT struct libinput *
+libinput_ref(struct libinput *libinput)
+{
+ libinput->refcount++;
+ return libinput;
+}
+
+LIBINPUT_EXPORT struct libinput *
+libinput_unref(struct libinput *libinput)
{
struct libinput_event *event;
struct libinput_device *device, *next_device;
struct libinput_seat *seat, *next_seat;
if (libinput == NULL)
- return;
+ return NULL;
+
+ assert(libinput->refcount > 0);
+ libinput->refcount--;
+ if (libinput->refcount > 0)
+ return libinput;
libinput_suspend(libinput);
while ((event = libinput_get_event(libinput)))
libinput_event_destroy(event);
- libinput_drop_destroyed_sources(libinput);
-
free(libinput->events);
list_for_each_safe(seat, next_seat, &libinput->seat_list, link) {
libinput_seat_destroy(seat);
}
+ libinput_timer_subsys_destroy(libinput);
+ libinput_drop_destroyed_sources(libinput);
close(libinput->epoll_fd);
free(libinput);
+
+ return NULL;
}
LIBINPUT_EXPORT void
if (event == NULL)
return;
- switch (libinput_event_get_type(event)) {
- case LIBINPUT_EVENT_NONE:
- abort(); /* not used as actual event type */
- case LIBINPUT_EVENT_DEVICE_ADDED:
- case LIBINPUT_EVENT_DEVICE_REMOVED:
- break;
- case LIBINPUT_EVENT_KEYBOARD_KEY:
- case LIBINPUT_EVENT_POINTER_MOTION:
- case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
- case LIBINPUT_EVENT_POINTER_BUTTON:
- case LIBINPUT_EVENT_POINTER_AXIS:
- case LIBINPUT_EVENT_TOUCH_TOUCH:
- case LIBINPUT_EVENT_TOUCH_FRAME:
+ if (event->device)
libinput_device_unref(event->device);
- break;
- }
free(event);
}
seat->logical_name = strdup(logical_name);
seat->destroy = destroy;
list_init(&seat->devices_list);
+ list_insert(&libinput->seat_list, &seat->link);
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_seat *
libinput_seat_ref(struct libinput_seat *seat)
{
seat->refcount++;
+ return seat;
}
static void
seat->destroy(seat);
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_seat *
libinput_seat_unref(struct libinput_seat *seat)
{
assert(seat->refcount > 0);
seat->refcount--;
- if (seat->refcount == 0)
+ if (seat->refcount == 0) {
libinput_seat_destroy(seat);
+ return NULL;
+ } else {
+ return seat;
+ }
}
LIBINPUT_EXPORT void
device->refcount = 1;
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_device *
libinput_device_ref(struct libinput_device *device)
{
device->refcount++;
+ return device;
}
static void
evdev_device_destroy((struct evdev_device *) device);
}
-LIBINPUT_EXPORT void
+LIBINPUT_EXPORT struct libinput_device *
libinput_device_unref(struct libinput_device *device)
{
assert(device->refcount > 0);
device->refcount--;
- if (device->refcount == 0)
+ if (device->refcount == 0) {
libinput_device_destroy(device);
+ return NULL;
+ } else {
+ return device;
+ }
}
LIBINPUT_EXPORT int
return 0;
}
+static uint32_t
+update_seat_key_count(struct libinput_seat *seat,
+ int32_t key,
+ enum libinput_key_state state)
+{
+ assert(key >= 0 && key <= KEY_MAX);
+
+ switch (state) {
+ case LIBINPUT_KEY_STATE_PRESSED:
+ return ++seat->button_count[key];
+ case LIBINPUT_KEY_STATE_RELEASED:
+ /* We might not have received the first PRESSED event. */
+ if (seat->button_count[key] == 0)
+ return 0;
+
+ return --seat->button_count[key];
+ }
+
+ return 0;
+}
+
+static uint32_t
+update_seat_button_count(struct libinput_seat *seat,
+ int32_t button,
+ enum libinput_button_state state)
+{
+ assert(button >= 0 && button <= KEY_MAX);
+
+ switch (state) {
+ case LIBINPUT_BUTTON_STATE_PRESSED:
+ return ++seat->button_count[button];
+ case LIBINPUT_BUTTON_STATE_RELEASED:
+ /* We might not have received the first PRESSED event. */
+ if (seat->button_count[button] == 0)
+ return 0;
+
+ return --seat->button_count[button];
+ }
+
+ return 0;
+}
+
static void
init_event_base(struct libinput_event *event,
struct libinput_device *device,
if (!added_device_event)
return;
- *added_device_event = (struct libinput_event_device_notify) {
- .device = device,
- };
-
post_base_event(device,
LIBINPUT_EVENT_DEVICE_ADDED,
&added_device_event->base);
if (!removed_device_event)
return;
- *removed_device_event = (struct libinput_event_device_notify) {
- .device = device,
- };
-
post_base_event(device,
LIBINPUT_EVENT_DEVICE_REMOVED,
&removed_device_event->base);
keyboard_notify_key(struct libinput_device *device,
uint32_t time,
uint32_t key,
- enum libinput_keyboard_key_state state)
+ enum libinput_key_state state)
{
struct libinput_event_keyboard *key_event;
+ uint32_t seat_key_count;
key_event = zalloc(sizeof *key_event);
if (!key_event)
return;
+ seat_key_count = update_seat_key_count(device->seat, key, state);
+
*key_event = (struct libinput_event_keyboard) {
.time = time,
.key = key,
.state = state,
+ .seat_key_count = seat_key_count,
};
post_device_event(device,
void
pointer_notify_motion(struct libinput_device *device,
uint32_t time,
- li_fixed_t dx,
- li_fixed_t dy)
+ double dx,
+ double dy)
{
struct libinput_event_pointer *motion_event;
void
pointer_notify_motion_absolute(struct libinput_device *device,
uint32_t time,
- li_fixed_t x,
- li_fixed_t y)
+ double x,
+ double y)
{
struct libinput_event_pointer *motion_absolute_event;
pointer_notify_button(struct libinput_device *device,
uint32_t time,
int32_t button,
- enum libinput_pointer_button_state state)
+ enum libinput_button_state state)
{
struct libinput_event_pointer *button_event;
+ int32_t seat_button_count;
button_event = zalloc(sizeof *button_event);
if (!button_event)
return;
+ seat_button_count = update_seat_button_count(device->seat,
+ button,
+ state);
+
*button_event = (struct libinput_event_pointer) {
.time = time,
.button = button,
.state = state,
+ .seat_button_count = seat_button_count,
};
post_device_event(device,
pointer_notify_axis(struct libinput_device *device,
uint32_t time,
enum libinput_pointer_axis axis,
- li_fixed_t value)
+ double value)
{
struct libinput_event_pointer *axis_event;
}
void
-touch_notify_touch(struct libinput_device *device,
- uint32_t time,
- int32_t slot,
- li_fixed_t x,
- li_fixed_t y,
- enum libinput_touch_type touch_type)
+touch_notify_touch_down(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot,
+ double x,
+ double y)
{
struct libinput_event_touch *touch_event;
*touch_event = (struct libinput_event_touch) {
.time = time,
.slot = slot,
+ .seat_slot = seat_slot,
.x = x,
.y = y,
- .touch_type = touch_type,
};
post_device_event(device,
- LIBINPUT_EVENT_TOUCH_TOUCH,
+ LIBINPUT_EVENT_TOUCH_DOWN,
+ &touch_event->base);
+}
+
+void
+touch_notify_touch_motion(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot,
+ double x,
+ double y)
+{
+ struct libinput_event_touch *touch_event;
+
+ touch_event = zalloc(sizeof *touch_event);
+ if (!touch_event)
+ return;
+
+ *touch_event = (struct libinput_event_touch) {
+ .time = time,
+ .slot = slot,
+ .seat_slot = seat_slot,
+ .x = x,
+ .y = y,
+ };
+
+ post_device_event(device,
+ LIBINPUT_EVENT_TOUCH_MOTION,
+ &touch_event->base);
+}
+
+void
+touch_notify_touch_up(struct libinput_device *device,
+ uint32_t time,
+ int32_t slot,
+ int32_t seat_slot)
+{
+ struct libinput_event_touch *touch_event;
+
+ touch_event = zalloc(sizeof *touch_event);
+ if (!touch_event)
+ return;
+
+ *touch_event = (struct libinput_event_touch) {
+ .time = time,
+ .slot = slot,
+ .seat_slot = seat_slot,
+ };
+
+ post_device_event(device,
+ LIBINPUT_EVENT_TOUCH_UP,
&touch_event->base);
}
&touch_event->base);
}
-
static void
libinput_post_event(struct libinput *libinput,
struct libinput_event *event)
libinput->events_len = events_len;
}
- switch (libinput_event_get_type(event)) {
- case LIBINPUT_EVENT_NONE:
- abort(); /* not used as actual event type */
- case LIBINPUT_EVENT_DEVICE_ADDED:
- case LIBINPUT_EVENT_DEVICE_REMOVED:
- break;
- case LIBINPUT_EVENT_KEYBOARD_KEY:
- case LIBINPUT_EVENT_POINTER_MOTION:
- case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
- case LIBINPUT_EVENT_POINTER_BUTTON:
- case LIBINPUT_EVENT_POINTER_AXIS:
- case LIBINPUT_EVENT_TOUCH_TOUCH:
- case LIBINPUT_EVENT_TOUCH_FRAME:
+ if (event->device)
libinput_device_ref(event->device);
- break;
- }
libinput->events_count = events_count;
events[libinput->events_in] = event;
}
LIBINPUT_EXPORT const char *
+libinput_device_get_name(struct libinput_device *device)
+{
+ return evdev_device_get_name((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT unsigned int
+libinput_device_get_id_product(struct libinput_device *device)
+{
+ return evdev_device_get_id_product((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT unsigned int
+libinput_device_get_id_vendor(struct libinput_device *device)
+{
+ return evdev_device_get_id_vendor((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT const char *
libinput_device_get_output_name(struct libinput_device *device)
{
return evdev_device_get_output((struct evdev_device *) device);
return evdev_device_has_capability((struct evdev_device *) device,
capability);
}
+
+LIBINPUT_EXPORT int
+libinput_device_get_size(struct libinput_device *device,
+ double *width,
+ double *height)
+{
+ return evdev_device_get_size((struct evdev_device *)device,
+ width,
+ height);
+}
+
+LIBINPUT_EXPORT struct libinput_event *
+libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
+{
+ return &event->base;
+}
+
+LIBINPUT_EXPORT struct libinput_event *
+libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event)
+{
+ return &event->base;
+}
+
+LIBINPUT_EXPORT struct libinput_event *
+libinput_event_pointer_get_base_event(struct libinput_event_pointer *event)
+{
+ return &event->base;
+}
+
+LIBINPUT_EXPORT struct libinput_event *
+libinput_event_touch_get_base_event(struct libinput_event_touch *event)
+{
+ return &event->base;
+}
+
+LIBINPUT_EXPORT const char *
+libinput_config_status_to_str(enum libinput_config_status status)
+{
+ const char *str = NULL;
+
+ switch(status) {
+ case LIBINPUT_CONFIG_STATUS_SUCCESS:
+ str = "Success";
+ break;
+ case LIBINPUT_CONFIG_STATUS_UNSUPPORTED:
+ str = "Unsupported configuration option";
+ break;
+ case LIBINPUT_CONFIG_STATUS_INVALID:
+ str = "Invalid argument range";
+ break;
+ }
+
+ return str;
+}
+
+LIBINPUT_EXPORT int
+libinput_device_config_tap_get_finger_count(struct libinput_device *device)
+{
+ return device->config.tap ? device->config.tap->count(device) : 0;
+}
+
+LIBINPUT_EXPORT enum libinput_config_status
+libinput_device_config_tap_set_enabled(struct libinput_device *device,
+ enum libinput_config_tap_state enable)
+{
+ if (enable != LIBINPUT_CONFIG_TAP_ENABLED &&
+ enable != LIBINPUT_CONFIG_TAP_DISABLED)
+ return LIBINPUT_CONFIG_STATUS_INVALID;
+
+ if (enable &&
+ libinput_device_config_tap_get_finger_count(device) == 0)
+ return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
+
+ return device->config.tap->set_enabled(device, enable);
+}
+
+LIBINPUT_EXPORT enum libinput_config_tap_state
+libinput_device_config_tap_get_enabled(struct libinput_device *device)
+{
+ if (libinput_device_config_tap_get_finger_count(device) == 0)
+ return LIBINPUT_CONFIG_TAP_DISABLED;
+
+ return device->config.tap->get_enabled(device);
+}
+
+LIBINPUT_EXPORT enum libinput_config_tap_state
+libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
+{
+ if (libinput_device_config_tap_get_finger_count(device) == 0)
+ return LIBINPUT_CONFIG_TAP_DISABLED;
+
+ return device->config.tap->get_default(device);
+}