2013-11-10 17:55:40 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2013 Jonas Ådahl
|
2015-05-28 08:23:59 +10:00
|
|
|
* Copyright © 2013-2015 Red Hat, Inc.
|
2013-11-10 17:55:40 +01:00
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
2013-11-10 17:55:40 +01:00
|
|
|
*
|
2015-06-11 12:09:18 +10:00
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
2013-11-10 17:55:40 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2013-12-05 17:26:40 +10:00
|
|
|
#include <errno.h>
|
2017-04-28 13:44:59 +10:00
|
|
|
#include <inttypes.h>
|
2013-11-16 19:32:46 +01:00
|
|
|
#include <stdio.h>
|
2013-11-10 17:55:40 +01:00
|
|
|
#include <stdlib.h>
|
2013-11-16 19:32:46 +01:00
|
|
|
#include <string.h>
|
2013-11-17 11:19:50 +01:00
|
|
|
#include <sys/epoll.h>
|
|
|
|
|
#include <unistd.h>
|
2013-11-17 16:59:09 +01:00
|
|
|
#include <assert.h>
|
2013-11-10 17:55:40 +01:00
|
|
|
|
|
|
|
|
#include "libinput.h"
|
|
|
|
|
#include "libinput-private.h"
|
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
|
|
|
#include "evdev.h"
|
2014-06-06 17:01:05 +02:00
|
|
|
#include "timer.h"
|
2013-11-10 17:55:40 +01:00
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
#define require_event_type(li_, type_, retval_, ...) \
|
|
|
|
|
if (type_ == LIBINPUT_EVENT_NONE) abort(); \
|
|
|
|
|
if (!check_event_type(li_, __func__, type_, __VA_ARGS__, -1)) \
|
|
|
|
|
return retval_; \
|
|
|
|
|
|
2017-05-10 12:50:21 +10:00
|
|
|
#define ASSERT_INT_SIZE(type_) \
|
|
|
|
|
static_assert(sizeof(type_) == sizeof(unsigned int), \
|
|
|
|
|
"sizeof(" #type_ ") must be sizeof(uint)")
|
|
|
|
|
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_log_priority);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_device_capability);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_key_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_led);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_button_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_pointer_axis);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_pointer_axis_source);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_tablet_pad_ring_axis_source);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_tablet_pad_strip_axis_source);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_tablet_tool_type);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_tablet_tool_proximity_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_tablet_tool_tip_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_switch_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_switch);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_event_type);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_status);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_tap_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_tap_button_map);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_drag_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_drag_lock_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_send_events_mode);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_accel_profile);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_click_method);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_middle_emulation_state);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_scroll_method);
|
|
|
|
|
ASSERT_INT_SIZE(enum libinput_config_dwt_state);
|
|
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
static inline bool
|
|
|
|
|
check_event_type(struct libinput *libinput,
|
|
|
|
|
const char *function_name,
|
2017-05-10 12:39:26 +10:00
|
|
|
unsigned int type_in,
|
2015-03-13 09:32:37 +10:00
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
bool rc = false;
|
|
|
|
|
va_list args;
|
|
|
|
|
unsigned int type_permitted;
|
|
|
|
|
|
|
|
|
|
va_start(args, type_in);
|
|
|
|
|
type_permitted = va_arg(args, unsigned int);
|
|
|
|
|
|
|
|
|
|
while (type_permitted != (unsigned int)-1) {
|
|
|
|
|
if (type_permitted == type_in) {
|
|
|
|
|
rc = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
type_permitted = va_arg(args, unsigned int);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
if (!rc)
|
|
|
|
|
log_bug_client(libinput,
|
|
|
|
|
"Invalid event type %d passed to %s()\n",
|
|
|
|
|
type_in, function_name);
|
|
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-28 13:44:59 +10:00
|
|
|
static inline const char *
|
|
|
|
|
event_type_to_str(enum libinput_event_type type)
|
|
|
|
|
{
|
|
|
|
|
switch(type) {
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_ADDED);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_DEVICE_REMOVED);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_BUTTON);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_DOWN);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_UP);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_MOTION);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_CANCEL);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_AXIS);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_TIP);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_RING);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_TABLET_PAD_STRIP);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_BEGIN);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_UPDATE);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_GESTURE_PINCH_END);
|
|
|
|
|
CASE_RETURN_STRING(LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
case LIBINPUT_EVENT_NONE:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput_source {
|
|
|
|
|
libinput_source_dispatch_t dispatch;
|
|
|
|
|
void *user_data;
|
|
|
|
|
int fd;
|
|
|
|
|
struct list link;
|
|
|
|
|
};
|
|
|
|
|
|
2014-01-15 17:10:30 +10:00
|
|
|
struct libinput_event_device_notify {
|
2013-12-08 12:36:27 +01:00
|
|
|
struct libinput_event base;
|
|
|
|
|
};
|
|
|
|
|
|
2013-12-19 16:40:48 +10:00
|
|
|
struct libinput_event_keyboard {
|
2013-12-08 12:36:27 +01:00
|
|
|
struct libinput_event base;
|
2015-07-27 17:51:52 +08:00
|
|
|
uint64_t time;
|
2013-12-08 12:36:27 +01:00
|
|
|
uint32_t key;
|
2014-04-01 21:57:45 +02:00
|
|
|
uint32_t seat_key_count;
|
2014-06-17 07:55:35 +10:00
|
|
|
enum libinput_key_state state;
|
2013-12-08 12:36:27 +01:00
|
|
|
};
|
|
|
|
|
|
2013-12-19 13:15:28 +10:00
|
|
|
struct libinput_event_pointer {
|
2013-12-08 12:36:27 +01:00
|
|
|
struct libinput_event base;
|
2015-07-27 17:51:52 +08:00
|
|
|
uint64_t time;
|
2015-03-11 11:19:24 +10:00
|
|
|
struct normalized_coords delta;
|
2015-06-26 09:07:24 +10:00
|
|
|
struct device_float_coords delta_raw;
|
2015-03-11 11:19:24 +10:00
|
|
|
struct device_coords absolute;
|
2015-03-11 11:30:02 +10:00
|
|
|
struct discrete_coords discrete;
|
2013-12-08 12:36:27 +01:00
|
|
|
uint32_t button;
|
2014-04-01 21:57:45 +02:00
|
|
|
uint32_t seat_button_count;
|
2014-06-03 20:08:02 -04:00
|
|
|
enum libinput_button_state state;
|
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;
|
2014-12-24 11:10:04 +10:00
|
|
|
uint32_t axes;
|
2013-12-08 12:36:27 +01:00
|
|
|
};
|
|
|
|
|
|
2013-12-19 17:16:19 +10:00
|
|
|
struct libinput_event_touch {
|
2013-12-08 12:36:27 +01:00
|
|
|
struct libinput_event base;
|
2015-07-27 17:51:52 +08:00
|
|
|
uint64_t time;
|
2014-02-12 20:52:14 +01:00
|
|
|
int32_t slot;
|
2014-01-30 22:44:49 +01:00
|
|
|
int32_t seat_slot;
|
2015-03-11 10:48:54 +10:00
|
|
|
struct device_coords point;
|
2013-12-08 12:36:27 +01:00
|
|
|
};
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
struct libinput_event_gesture {
|
|
|
|
|
struct libinput_event base;
|
2015-07-27 17:51:52 +08:00
|
|
|
uint64_t time;
|
2015-01-22 16:41:50 +01:00
|
|
|
int finger_count;
|
2015-04-29 13:19:51 +02:00
|
|
|
int cancelled;
|
2015-01-22 16:41:50 +01:00
|
|
|
struct normalized_coords delta;
|
|
|
|
|
struct normalized_coords delta_unaccel;
|
2015-03-04 15:24:04 +01:00
|
|
|
double scale;
|
|
|
|
|
double angle;
|
2015-01-22 16:41:50 +01:00
|
|
|
};
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool {
|
2014-06-05 23:20:36 -04:00
|
|
|
struct libinput_event base;
|
2014-06-10 23:14:41 -04:00
|
|
|
uint32_t button;
|
|
|
|
|
enum libinput_button_state state;
|
|
|
|
|
uint32_t seat_button_count;
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time;
|
2016-01-06 16:16:46 +10:00
|
|
|
struct tablet_axes axes;
|
2015-11-16 15:36:30 +10:00
|
|
|
unsigned char changed_axes[NCHARS(LIBINPUT_TABLET_TOOL_AXIS_MAX + 1)];
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool;
|
2015-11-16 15:41:48 +10:00
|
|
|
enum libinput_tablet_tool_proximity_state proximity_state;
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state;
|
2014-06-05 23:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
struct libinput_event_tablet_pad {
|
|
|
|
|
struct libinput_event base;
|
2016-05-26 10:05:10 +10:00
|
|
|
unsigned int mode;
|
|
|
|
|
struct libinput_tablet_pad_mode_group *mode_group;
|
2016-01-21 12:35:11 +10:00
|
|
|
uint64_t time;
|
2016-05-26 10:03:47 +10:00
|
|
|
struct {
|
|
|
|
|
uint32_t number;
|
|
|
|
|
enum libinput_button_state state;
|
|
|
|
|
} button;
|
2016-01-21 12:35:11 +10:00
|
|
|
struct {
|
|
|
|
|
enum libinput_tablet_pad_ring_axis_source source;
|
|
|
|
|
double position;
|
|
|
|
|
int number;
|
|
|
|
|
} ring;
|
|
|
|
|
struct {
|
|
|
|
|
enum libinput_tablet_pad_strip_axis_source source;
|
|
|
|
|
double position;
|
|
|
|
|
int number;
|
|
|
|
|
} strip;
|
|
|
|
|
};
|
|
|
|
|
|
2017-01-20 16:54:13 +11:00
|
|
|
struct libinput_event_switch {
|
|
|
|
|
struct libinput_event base;
|
|
|
|
|
uint64_t time;
|
|
|
|
|
enum libinput_switch sw;
|
|
|
|
|
enum libinput_switch_state state;
|
|
|
|
|
};
|
|
|
|
|
|
2016-10-24 11:06:23 +10:00
|
|
|
LIBINPUT_ATTRIBUTE_PRINTF(3, 0)
|
2014-02-12 14:20:18 +10:00
|
|
|
static void
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput_default_log_func(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority,
|
2014-02-12 14:20:18 +10:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
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-06-18 19:51:19 +10:00
|
|
|
if (libinput->log_handler &&
|
|
|
|
|
libinput->log_priority <= priority)
|
|
|
|
|
libinput->log_handler(libinput, priority, format, args);
|
2014-06-10 15:08:03 +02:00
|
|
|
}
|
|
|
|
|
|
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-02-12 14:20:18 +10:00
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
|
2014-06-10 15:08:03 +02:00
|
|
|
va_start(args, format);
|
2014-06-18 19:51:19 +10:00
|
|
|
log_msg_va(libinput, priority, format, args);
|
2014-06-10 15:08:03 +02:00
|
|
|
va_end(args);
|
2014-02-12 14:20:18 +10:00
|
|
|
}
|
|
|
|
|
|
2015-08-19 15:21:53 +10:00
|
|
|
void
|
|
|
|
|
log_msg_ratelimit(struct libinput *libinput,
|
|
|
|
|
struct ratelimit *ratelimit,
|
|
|
|
|
enum libinput_log_priority priority,
|
|
|
|
|
const char *format, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
enum ratelimit_state state;
|
|
|
|
|
|
|
|
|
|
state = ratelimit_test(ratelimit);
|
|
|
|
|
if (state == RATELIMIT_EXCEEDED)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
log_msg_va(libinput, priority, format, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
if (state == RATELIMIT_THRESHOLD)
|
|
|
|
|
log_msg(libinput,
|
|
|
|
|
priority,
|
|
|
|
|
"WARNING: log rate limit exceeded (%d msgs per %dms). Discarding future messages.\n",
|
|
|
|
|
ratelimit->burst,
|
|
|
|
|
us2ms(ratelimit->interval));
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 14:20:18 +10:00
|
|
|
LIBINPUT_EXPORT void
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput_log_set_priority(struct libinput *libinput,
|
|
|
|
|
enum libinput_log_priority priority)
|
2014-02-12 14:20:18 +10:00
|
|
|
{
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput->log_priority = priority;
|
2014-02-12 14:20:18 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_log_priority
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput_log_get_priority(const struct libinput *libinput)
|
2014-02-12 14:20:18 +10:00
|
|
|
{
|
2014-06-18 19:51:19 +10:00
|
|
|
return libinput->log_priority;
|
2014-02-12 14:20:18 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput_log_set_handler(struct libinput *libinput,
|
|
|
|
|
libinput_log_handler log_handler)
|
2014-02-12 14:20:18 +10:00
|
|
|
{
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput->log_handler = log_handler;
|
2014-02-12 14:20:18 +10:00
|
|
|
}
|
|
|
|
|
|
2015-09-04 12:56:41 +10:00
|
|
|
static void
|
|
|
|
|
libinput_device_group_destroy(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
|
|
|
static void
|
|
|
|
|
libinput_post_event(struct libinput *libinput,
|
|
|
|
|
struct libinput_event *event);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
LIBINPUT_EXPORT enum libinput_event_type
|
|
|
|
|
libinput_event_get_type(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
return event->type;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-25 11:33:09 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput *
|
2013-12-19 11:22:53 +10:00
|
|
|
libinput_event_get_context(struct libinput_event *event)
|
|
|
|
|
{
|
2014-01-17 17:59:30 +10:00
|
|
|
return event->device->seat->libinput;
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-25 11:33:09 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_device *
|
2014-01-17 17:59:30 +10:00
|
|
|
libinput_event_get_device(struct libinput_event *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
|
|
|
|
return event->device;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-25 11:33:09 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_pointer *
|
2013-12-20 09:22:32 +10:00
|
|
|
libinput_event_get_pointer_event(struct libinput_event *event)
|
|
|
|
|
{
|
2015-03-13 09:32:37 +10:00
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
2013-12-20 09:22:32 +10:00
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
return (struct libinput_event_pointer *) event;
|
2013-12-20 09:22:32 +10:00
|
|
|
}
|
|
|
|
|
|
2014-01-25 11:33:09 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_keyboard *
|
2013-12-20 09:22:32 +10:00
|
|
|
libinput_event_get_keyboard_event(struct libinput_event *event)
|
|
|
|
|
{
|
2015-03-13 09:32:37 +10:00
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
2013-12-20 09:22:32 +10:00
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
return (struct libinput_event_keyboard *) event;
|
2013-12-20 09:22:32 +10:00
|
|
|
}
|
|
|
|
|
|
2014-01-25 11:33:09 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_touch *
|
2013-12-20 09:22:32 +10:00
|
|
|
libinput_event_get_touch_event(struct libinput_event *event)
|
|
|
|
|
{
|
2015-03-13 09:32:37 +10:00
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_CANCEL,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
return (struct libinput_event_touch *) event;
|
2014-06-05 23:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_gesture *
|
|
|
|
|
libinput_event_get_gesture_event(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
2015-03-04 15:24:04 +01:00
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END);
|
2015-01-22 16:41:50 +01:00
|
|
|
|
|
|
|
|
return (struct libinput_event_gesture *) event;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_tablet_tool *
|
|
|
|
|
libinput_event_get_tablet_tool_event(struct libinput_event *event)
|
2014-06-05 23:20:36 -04:00
|
|
|
{
|
2015-03-18 14:37:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
|
2015-07-08 13:50:24 +10:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
return (struct libinput_event_tablet_tool *) event;
|
2013-12-20 09:22:32 +10:00
|
|
|
}
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_tablet_pad *
|
|
|
|
|
libinput_event_get_tablet_pad_event(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
|
|
|
|
return (struct libinput_event_tablet_pad *) event;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-25 11:33:09 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_device_notify *
|
2013-12-20 09:22:32 +10:00
|
|
|
libinput_event_get_device_notify_event(struct libinput_event *event)
|
|
|
|
|
{
|
2015-03-13 09:32:37 +10:00
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_DEVICE_ADDED,
|
|
|
|
|
LIBINPUT_EVENT_DEVICE_REMOVED);
|
2013-12-20 09:22:32 +10:00
|
|
|
|
2015-03-13 09:32:37 +10:00
|
|
|
return (struct libinput_event_device_notify *) event;
|
2013-12-20 09:22:32 +10:00
|
|
|
}
|
|
|
|
|
|
2017-01-20 16:54:13 +11:00
|
|
|
LIBINPUT_EXPORT struct libinput_event_switch *
|
|
|
|
|
libinput_event_get_switch_event(struct libinput_event *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(event),
|
|
|
|
|
event->type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
|
|
|
|
|
return (struct libinput_event_switch *) event;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
|
2015-07-27 17:51:52 +08:00
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
|
|
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
|
|
|
|
libinput_event_keyboard_get_time_usec(struct libinput_event_keyboard *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_keyboard_get_key(struct libinput_event_keyboard *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->key;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-17 07:55:35 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_key_state
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->state;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_event_keyboard_get_seat_key_count(
|
|
|
|
|
struct libinput_event_keyboard *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
return event->seat_key_count;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_time(struct libinput_event_pointer *event)
|
2015-07-27 17:51:52 +08:00
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
|
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
|
|
|
|
libinput_event_pointer_get_time_usec(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
|
2015-03-11 11:19:24 +10:00
|
|
|
return event->delta.x;
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
|
2015-03-11 11:19:24 +10:00
|
|
|
return event->delta.y;
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-12-04 11:44:09 +08:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_pointer_get_dx_unaccelerated(
|
|
|
|
|
struct libinput_event_pointer *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
|
2015-06-26 09:07:24 +10:00
|
|
|
return event->delta_raw.x;
|
2014-12-04 11:44:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_pointer_get_dy_unaccelerated(
|
|
|
|
|
struct libinput_event_pointer *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION);
|
|
|
|
|
|
2015-06-26 09:07:24 +10:00
|
|
|
return event->delta_raw.y;
|
2014-12-04 11:44:09 +08:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-06-19 11:30:21 +10:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
|
|
|
|
|
2015-03-11 11:19:24 +10:00
|
|
|
return evdev_convert_to_mm(device->abs.absinfo_x, event->absolute.x);
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-06-19 11:30:21 +10:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
|
|
|
|
|
2015-03-11 11:19:24 +10:00
|
|
|
return evdev_convert_to_mm(device->abs.absinfo_y, event->absolute.y);
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-01-25 11:53:53 +01:00
|
|
|
libinput_event_pointer_get_absolute_x_transformed(
|
|
|
|
|
struct libinput_event_pointer *event,
|
|
|
|
|
uint32_t width)
|
|
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-01-25 11:53:53 +01:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
|
|
|
|
|
2015-03-11 11:19:24 +10:00
|
|
|
return evdev_device_transform_x(device, event->absolute.x, width);
|
2014-01-25 11:53:53 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-01-25 11:53:53 +01:00
|
|
|
libinput_event_pointer_get_absolute_y_transformed(
|
|
|
|
|
struct libinput_event_pointer *event,
|
|
|
|
|
uint32_t height)
|
|
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-01-25 11:53:53 +01:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE);
|
|
|
|
|
|
2015-03-11 11:19:24 +10:00
|
|
|
return evdev_device_transform_y(device, event->absolute.y, height);
|
2014-01-25 11:53:53 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_button(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->button;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-03 20:08:02 -04:00
|
|
|
LIBINPUT_EXPORT enum libinput_button_state
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_pointer_get_button_state(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->state;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_event_pointer_get_seat_button_count(
|
|
|
|
|
struct libinput_event_pointer *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON);
|
|
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
return event->seat_button_count;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-24 11:10:04 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_pointer_has_axis(struct libinput_event_pointer *event,
|
|
|
|
|
enum libinput_pointer_axis axis)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
|
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
|
|
|
|
return !!(event->axes & AS_MASK(axis));
|
2014-12-24 11:10:04 +10:00
|
|
|
}
|
2015-03-13 10:07:53 +10:00
|
|
|
|
2014-12-24 11:10:04 +10:00
|
|
|
return 0;
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-12-24 11:10:04 +10:00
|
|
|
libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event,
|
|
|
|
|
enum libinput_pointer_axis axis)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2014-12-24 11:10:04 +10:00
|
|
|
struct libinput *libinput = event->base.device->seat->libinput;
|
|
|
|
|
double value = 0;
|
|
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
2014-12-24 11:10:04 +10:00
|
|
|
if (!libinput_event_pointer_has_axis(event, axis)) {
|
|
|
|
|
log_bug_client(libinput, "value requested for unset axis\n");
|
|
|
|
|
} else {
|
|
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
2015-03-11 11:19:24 +10:00
|
|
|
value = event->delta.x;
|
2014-12-24 11:10:04 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
2015-03-11 11:19:24 +10:00
|
|
|
value = event->delta.y;
|
2014-12-24 11:10:04 +10:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2015-01-15 09:48:29 +10:00
|
|
|
libinput_event_pointer_get_axis_value_discrete(struct libinput_event_pointer *event,
|
|
|
|
|
enum libinput_pointer_axis axis)
|
2015-01-13 15:15:02 +10:00
|
|
|
{
|
2015-01-15 09:48:29 +10:00
|
|
|
struct libinput *libinput = event->base.device->seat->libinput;
|
|
|
|
|
double value = 0;
|
|
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
2015-01-15 09:48:29 +10:00
|
|
|
if (!libinput_event_pointer_has_axis(event, axis)) {
|
|
|
|
|
log_bug_client(libinput, "value requested for unset axis\n");
|
|
|
|
|
} else {
|
|
|
|
|
switch (axis) {
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
|
2015-03-11 11:30:02 +10:00
|
|
|
value = event->discrete.x;
|
2015-01-15 09:48:29 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
|
2015-03-11 11:30:02 +10:00
|
|
|
value = event->discrete.y;
|
2015-01-15 09:48:29 +10:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return value;
|
2015-01-13 15:15:02 +10:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
LIBINPUT_EXPORT enum libinput_pointer_axis_source
|
|
|
|
|
libinput_event_pointer_get_axis_source(struct libinput_event_pointer *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
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
|
|
|
return event->source;
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_touch_get_time(struct libinput_event_touch *event)
|
2015-07-27 17:51:52 +08:00
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_CANCEL,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
|
|
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
|
|
|
|
libinput_event_touch_get_time_usec(struct libinput_event_touch *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_CANCEL,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-12 20:52:14 +01:00
|
|
|
LIBINPUT_EXPORT int32_t
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_touch_get_slot(struct libinput_event_touch *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_CANCEL);
|
|
|
|
|
|
2013-12-08 12:36:27 +01:00
|
|
|
return event->slot;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-30 22:44:49 +01:00
|
|
|
LIBINPUT_EXPORT int32_t
|
|
|
|
|
libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_CANCEL);
|
|
|
|
|
|
2014-01-30 22:44:49 +01:00
|
|
|
return event->seat_slot;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_touch_get_x(struct libinput_event_touch *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-06-19 11:30:21 +10:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION);
|
|
|
|
|
|
2015-03-11 10:48:54 +10:00
|
|
|
return evdev_convert_to_mm(device->abs.absinfo_x, event->point.x);
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
|
|
|
|
|
uint32_t width)
|
2014-01-25 11:53:53 +01:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-01-25 11:53:53 +01:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION);
|
|
|
|
|
|
2015-03-11 10:48:54 +10:00
|
|
|
return evdev_device_transform_x(device, event->point.x, width);
|
2014-01-25 11:53:53 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
|
|
|
|
|
uint32_t height)
|
2014-01-25 11:53:53 +01:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-01-25 11:53:53 +01:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION);
|
|
|
|
|
|
2015-03-11 10:48:54 +10:00
|
|
|
return evdev_device_transform_y(device, event->point.y, height);
|
2014-01-25 11:53:53 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
LIBINPUT_EXPORT double
|
2014-02-11 23:29:34 +01:00
|
|
|
libinput_event_touch_get_y(struct libinput_event_touch *event)
|
2013-12-08 12:36:27 +01:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-06-19 11:30:21 +10:00
|
|
|
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION);
|
|
|
|
|
|
2015-03-11 10:48:54 +10:00
|
|
|
return evdev_convert_to_mm(device->abs.absinfo_y, event->point.y);
|
2013-12-08 12:36:27 +01:00
|
|
|
}
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_event_gesture_get_time(struct libinput_event_gesture *event)
|
2015-07-27 17:51:52 +08:00
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
|
|
|
|
|
|
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
|
|
|
|
libinput_event_gesture_get_time_usec(struct libinput_event_gesture *event)
|
2015-01-22 16:41:50 +01:00
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_gesture_get_finger_count(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return event->finger_count;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 13:19:51 +02:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_gesture_get_cancelled(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
|
|
|
|
|
2015-04-29 13:19:51 +02:00
|
|
|
return event->cancelled;
|
|
|
|
|
}
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_gesture_get_dx(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
2015-05-22 10:58:56 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
2015-05-22 10:58:56 +10:00
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return event->delta.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_gesture_get_dy(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
2015-05-22 10:58:56 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
2015-05-22 10:58:56 +10:00
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return event->delta.y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_gesture_get_dx_unaccelerated(
|
|
|
|
|
struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
2015-05-22 10:58:56 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
2015-05-22 10:58:56 +10:00
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return event->delta_unaccel.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_gesture_get_dy_unaccelerated(
|
|
|
|
|
struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
2015-05-22 10:58:56 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END);
|
2015-05-22 10:58:56 +10:00
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return event->delta_unaccel.y;
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_gesture_get_scale(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END);
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
return event->scale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_gesture_get_angle_delta(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2015-05-22 10:58:56 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
2015-06-09 14:23:07 +10:00
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END);
|
2015-05-22 10:58:56 +10:00
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
return event->angle;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
LIBINPUT_EXPORT int
|
2015-12-14 09:05:37 +10:00
|
|
|
libinput_event_tablet_tool_x_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
2014-06-05 23:20:36 -04:00
|
|
|
{
|
2015-11-05 14:35:00 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-11-05 14:35:00 +10:00
|
|
|
|
2015-12-14 09:05:37 +10:00
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_X);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_y_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_pressure_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_distance_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_tilt_x_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_tilt_y_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_rotation_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_slider_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_wheel_has_changed(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-12-14 09:05:37 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return bit_is_set(event->changed_axes,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
|
2014-06-05 23:20:36 -04:00
|
|
|
}
|
|
|
|
|
|
2016-01-06 16:16:46 +10:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_x(struct libinput_event_tablet_tool *event)
|
2014-06-05 23:20:36 -04:00
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-07-20 22:20:41 -04:00
|
|
|
|
2015-11-05 14:33:58 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2014-06-24 15:10:34 +10:00
|
|
|
|
2016-01-06 16:16:46 +10:00
|
|
|
return evdev_convert_to_mm(device->abs.absinfo_x,
|
|
|
|
|
event->axes.point.x);
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_y(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2016-01-06 16:16:46 +10:00
|
|
|
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return evdev_convert_to_mm(device->abs.absinfo_y,
|
|
|
|
|
event->axes.point.y);
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
2016-01-06 14:47:18 +10:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_dx(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.delta.x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_dy(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.delta.y;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 09:51:11 +10:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_pressure(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2016-01-06 16:16:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.pressure;
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_distance(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2016-01-06 16:16:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.distance;
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_tilt_x(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2016-01-06 16:16:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.tilt.x;
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_tilt_y(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2016-01-06 16:16:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.tilt.y;
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_rotation(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2016-01-06 16:16:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.rotation;
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_tool_get_slider_position(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
2016-01-06 16:16:46 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
|
|
|
|
|
|
|
|
|
return event->axes.slider;
|
2015-12-14 09:51:11 +10:00
|
|
|
}
|
|
|
|
|
|
2015-02-20 12:03:52 +10:00
|
|
|
LIBINPUT_EXPORT double
|
2015-12-14 10:23:56 +10:00
|
|
|
libinput_event_tablet_tool_get_wheel_delta(struct libinput_event_tablet_tool *event)
|
2015-02-20 12:03:52 +10:00
|
|
|
{
|
2015-11-05 14:33:58 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-02-20 12:03:52 +10:00
|
|
|
|
2016-01-06 16:16:46 +10:00
|
|
|
return event->axes.wheel;
|
2015-02-20 12:03:52 +10:00
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:23:56 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_event_tablet_tool_get_wheel_delta_discrete(
|
|
|
|
|
struct libinput_event_tablet_tool *event)
|
2015-02-20 14:34:31 +10:00
|
|
|
{
|
2015-11-05 14:33:58 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-02-20 14:34:31 +10:00
|
|
|
|
2016-01-06 16:16:46 +10:00
|
|
|
return event->axes.wheel_discrete;
|
2015-02-20 14:34:31 +10:00
|
|
|
}
|
|
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
LIBINPUT_EXPORT double
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_x_transformed(struct libinput_event_tablet_tool *event,
|
2014-06-05 23:20:36 -04:00
|
|
|
uint32_t width)
|
|
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-06-05 23:20:36 -04:00
|
|
|
|
2015-11-05 14:33:58 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2014-06-24 15:10:34 +10:00
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
return evdev_device_transform_x(device,
|
2016-01-06 16:16:46 +10:00
|
|
|
event->axes.point.x,
|
2014-06-05 23:20:36 -04:00
|
|
|
width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_y_transformed(struct libinput_event_tablet_tool *event,
|
2014-06-05 23:20:36 -04:00
|
|
|
uint32_t height)
|
|
|
|
|
{
|
2017-01-30 19:48:33 +10:00
|
|
|
struct evdev_device *device = evdev_device(event->base.device);
|
2014-06-05 23:20:36 -04:00
|
|
|
|
2015-11-05 14:33:58 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2016-01-14 14:12:28 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2014-06-24 15:10:34 +10:00
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
return evdev_device_transform_y(device,
|
2016-01-06 16:16:46 +10:00
|
|
|
event->axes.point.y,
|
2014-06-05 23:20:36 -04:00
|
|
|
height);
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 15:34:19 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_tool *
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_tool(struct libinput_event_tablet_tool *event)
|
2014-06-10 16:48:19 -04:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
return event->tool;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 15:41:48 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_tablet_tool_proximity_state
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_proximity_state(struct libinput_event_tablet_tool *event)
|
2015-02-16 22:48:42 -05:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2015-02-16 22:48:42 -05:00
|
|
|
return event->proximity_state;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 15:43:41 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_tablet_tool_tip_state
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_tip_state(struct libinput_event_tablet_tool *event)
|
2015-11-11 13:39:43 +10:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2015-11-11 13:39:43 +10:00
|
|
|
return event->tip_state;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_time(struct libinput_event_tablet_tool *event)
|
2015-08-04 12:37:40 +10:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2015-08-04 12:37:40 +10:00
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_time_usec(struct libinput_event_tablet_tool *event)
|
2014-06-05 23:20:36 -04:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 23:14:41 -04:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_button(struct libinput_event_tablet_tool *event)
|
2014-06-10 23:14:41 -04:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2014-06-10 23:14:41 -04:00
|
|
|
return event->button;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_button_state
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_button_state(struct libinput_event_tablet_tool *event)
|
2014-06-10 23:14:41 -04:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2014-06-10 23:14:41 -04:00
|
|
|
return event->state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_seat_button_count(struct libinput_event_tablet_tool *event)
|
2014-06-10 23:14:41 -04:00
|
|
|
{
|
2015-11-12 07:29:51 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
|
2015-11-12 07:29:51 +10:00
|
|
|
|
2014-06-10 23:14:41 -04:00
|
|
|
return event->seat_button_count;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 15:39:07 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_tablet_tool_type
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_get_type(struct libinput_tablet_tool *tool)
|
2014-06-10 16:44:02 -04:00
|
|
|
{
|
|
|
|
|
return tool->type;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-09 15:38:55 +10:00
|
|
|
LIBINPUT_EXPORT uint64_t
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_get_tool_id(struct libinput_tablet_tool *tool)
|
2015-02-19 14:56:34 +10:00
|
|
|
{
|
|
|
|
|
return tool->tool_id;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-15 12:39:52 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_tool_is_unique(struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
return tool->serial != 0;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-05 13:16:58 +10:00
|
|
|
LIBINPUT_EXPORT uint64_t
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_get_serial(struct libinput_tablet_tool *tool)
|
2014-06-10 16:44:02 -04:00
|
|
|
{
|
|
|
|
|
return tool->serial;
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-07 22:02:22 -04:00
|
|
|
LIBINPUT_EXPORT int
|
2015-12-14 10:06:56 +10:00
|
|
|
libinput_tablet_tool_has_pressure(struct libinput_tablet_tool *tool)
|
2014-08-07 22:02:22 -04:00
|
|
|
{
|
2015-12-14 10:06:56 +10:00
|
|
|
return bit_is_set(tool->axis_caps,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_tool_has_distance(struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
return bit_is_set(tool->axis_caps,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_tool_has_tilt(struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
return bit_is_set(tool->axis_caps,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_tool_has_rotation(struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
return bit_is_set(tool->axis_caps,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_tool_has_slider(struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
return bit_is_set(tool->axis_caps,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_tool_has_wheel(struct libinput_tablet_tool *tool)
|
|
|
|
|
{
|
|
|
|
|
return bit_is_set(tool->axis_caps,
|
|
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
|
2014-08-07 22:02:22 -04:00
|
|
|
}
|
|
|
|
|
|
2015-02-18 13:53:31 +10:00
|
|
|
LIBINPUT_EXPORT int
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_has_button(struct libinput_tablet_tool *tool,
|
|
|
|
|
uint32_t code)
|
2015-02-18 13:53:31 +10:00
|
|
|
{
|
|
|
|
|
if (NCHARS(code) > sizeof(tool->buttons))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return bit_is_set(tool->buttons, code);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-05 17:49:39 -04:00
|
|
|
LIBINPUT_EXPORT void
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_set_user_data(struct libinput_tablet_tool *tool,
|
|
|
|
|
void *user_data)
|
2014-08-05 17:49:39 -04:00
|
|
|
{
|
|
|
|
|
tool->user_data = user_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void *
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_get_user_data(struct libinput_tablet_tool *tool)
|
2014-08-05 17:49:39 -04:00
|
|
|
{
|
|
|
|
|
return tool->user_data;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 15:34:19 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_tool *
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_ref(struct libinput_tablet_tool *tool)
|
2014-06-10 16:44:02 -04:00
|
|
|
{
|
|
|
|
|
tool->refcount++;
|
2014-06-27 11:05:30 +10:00
|
|
|
return tool;
|
2014-06-10 16:44:02 -04:00
|
|
|
}
|
|
|
|
|
|
2015-11-16 15:34:19 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_tool *
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_unref(struct libinput_tablet_tool *tool)
|
2014-06-10 16:44:02 -04:00
|
|
|
{
|
|
|
|
|
assert(tool->refcount > 0);
|
|
|
|
|
|
2014-06-27 11:05:30 +10:00
|
|
|
tool->refcount--;
|
|
|
|
|
if (tool->refcount > 0)
|
|
|
|
|
return tool;
|
|
|
|
|
|
|
|
|
|
list_remove(&tool->link);
|
|
|
|
|
free(tool);
|
|
|
|
|
return NULL;
|
2014-06-10 16:44:02 -04:00
|
|
|
}
|
|
|
|
|
|
2017-01-20 16:54:13 +11:00
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_switch_get_base_event(struct libinput_event_switch *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
|
|
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_switch
|
|
|
|
|
libinput_event_switch_get_switch(struct libinput_event_switch *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
|
|
|
|
|
return event->sw;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_switch_state
|
|
|
|
|
libinput_event_switch_get_switch_state(struct libinput_event_switch *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
|
|
|
|
|
return event->state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_event_switch_get_time(struct libinput_event_switch *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
|
|
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
|
|
|
|
libinput_event_switch_get_time_usec(struct libinput_event_switch *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE);
|
|
|
|
|
|
|
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
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 *user_data)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_source *source;
|
|
|
|
|
struct epoll_event ep;
|
|
|
|
|
|
2015-02-03 09:36:17 +10:00
|
|
|
source = zalloc(sizeof *source);
|
2013-11-17 11:19:50 +01:00
|
|
|
source->dispatch = dispatch;
|
|
|
|
|
source->user_data = user_data;
|
|
|
|
|
source->fd = fd;
|
|
|
|
|
|
|
|
|
|
memset(&ep, 0, sizeof ep);
|
|
|
|
|
ep.events = EPOLLIN;
|
|
|
|
|
ep.data.ptr = source;
|
|
|
|
|
|
|
|
|
|
if (epoll_ctl(libinput->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) {
|
|
|
|
|
free(source);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_remove_source(struct libinput *libinput,
|
|
|
|
|
struct libinput_source *source)
|
|
|
|
|
{
|
|
|
|
|
epoll_ctl(libinput->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
|
|
|
|
|
source->fd = -1;
|
|
|
|
|
list_insert(&libinput->source_destroy_list, &source->link);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2016-03-04 07:50:49 +10:00
|
|
|
assert(interface->open_restricted != NULL);
|
|
|
|
|
assert(interface->close_restricted != NULL);
|
|
|
|
|
|
2017-01-11 09:59:59 +10:00
|
|
|
libinput->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
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
|
|
|
if (libinput->epoll_fd < 0)
|
|
|
|
|
return -1;
|
2013-11-17 11:19:50 +01:00
|
|
|
|
2013-12-24 13:50:10 +10:00
|
|
|
libinput->events_len = 4;
|
|
|
|
|
libinput->events = zalloc(libinput->events_len * sizeof(*libinput->events));
|
2014-06-18 19:51:19 +10:00
|
|
|
libinput->log_handler = libinput_default_log_func;
|
|
|
|
|
libinput->log_priority = LIBINPUT_LOG_PRIORITY_ERROR;
|
2013-11-17 19:31:34 +01:00
|
|
|
libinput->interface = interface;
|
2013-12-13 11:37:31 +10:00
|
|
|
libinput->interface_backend = interface_backend;
|
2013-11-17 19:31:34 +01:00
|
|
|
libinput->user_data = user_data;
|
2014-06-25 00:06:58 +02:00
|
|
|
libinput->refcount = 1;
|
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
|
|
|
list_init(&libinput->source_destroy_list);
|
|
|
|
|
list_init(&libinput->seat_list);
|
2015-09-04 12:56:41 +10:00
|
|
|
list_init(&libinput->device_group_list);
|
2014-06-10 16:48:19 -04:00
|
|
|
list_init(&libinput->tool_list);
|
2013-11-17 19:31:34 +01:00
|
|
|
|
2014-06-06 17:01:05 +02:00
|
|
|
if (libinput_timer_subsys_init(libinput) != 0) {
|
|
|
|
|
free(libinput->events);
|
|
|
|
|
close(libinput->epoll_fd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
return 0;
|
2013-11-17 11:19:50 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-31 16:11:03 +01:00
|
|
|
static void
|
|
|
|
|
libinput_device_destroy(struct libinput_device *device);
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
libinput_seat_destroy(struct libinput_seat *seat);
|
|
|
|
|
|
2014-01-07 15:45:55 +10:00
|
|
|
static void
|
|
|
|
|
libinput_drop_destroyed_sources(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_source *source, *next;
|
|
|
|
|
|
|
|
|
|
list_for_each_safe(source, next, &libinput->source_destroy_list, link)
|
|
|
|
|
free(source);
|
|
|
|
|
list_init(&libinput->source_destroy_list);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-25 00:06:58 +02:00
|
|
|
LIBINPUT_EXPORT struct libinput *
|
|
|
|
|
libinput_ref(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
libinput->refcount++;
|
|
|
|
|
return libinput;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput *
|
|
|
|
|
libinput_unref(struct libinput *libinput)
|
2013-11-17 11:19:50 +01:00
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
2013-12-16 22:52:05 +01:00
|
|
|
struct libinput_device *device, *next_device;
|
|
|
|
|
struct libinput_seat *seat, *next_seat;
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool, *next_tool;
|
2015-09-04 12:56:41 +10:00
|
|
|
struct libinput_device_group *group, *next_group;
|
2013-11-17 11:19:50 +01:00
|
|
|
|
2013-12-24 11:00:37 +10:00
|
|
|
if (libinput == NULL)
|
2014-06-25 00:06:58 +02:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
assert(libinput->refcount > 0);
|
|
|
|
|
libinput->refcount--;
|
|
|
|
|
if (libinput->refcount > 0)
|
|
|
|
|
return libinput;
|
2013-12-24 11:00:37 +10:00
|
|
|
|
2014-01-07 14:54:55 +10:00
|
|
|
libinput_suspend(libinput);
|
|
|
|
|
|
2013-12-13 11:37:31 +10:00
|
|
|
libinput->interface_backend->destroy(libinput);
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
while ((event = libinput_get_event(libinput)))
|
2013-12-30 22:11:33 +01:00
|
|
|
libinput_event_destroy(event);
|
2014-01-07 15:45:55 +10:00
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
free(libinput->events);
|
|
|
|
|
|
2013-12-16 22:52:05 +01:00
|
|
|
list_for_each_safe(seat, next_seat, &libinput->seat_list, link) {
|
|
|
|
|
list_for_each_safe(device, next_device,
|
|
|
|
|
&seat->devices_list,
|
|
|
|
|
link)
|
2013-12-31 16:11:03 +01:00
|
|
|
libinput_device_destroy(device);
|
2013-12-16 22:52:05 +01:00
|
|
|
|
2013-12-31 16:11:03 +01:00
|
|
|
libinput_seat_destroy(seat);
|
2013-12-16 22:52:05 +01:00
|
|
|
}
|
|
|
|
|
|
2015-09-04 12:56:41 +10:00
|
|
|
list_for_each_safe(group,
|
|
|
|
|
next_group,
|
|
|
|
|
&libinput->device_group_list,
|
|
|
|
|
link) {
|
|
|
|
|
libinput_device_group_destroy(group);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 16:48:19 -04:00
|
|
|
list_for_each_safe(tool, next_tool, &libinput->tool_list, link) {
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_unref(tool);
|
2014-06-10 16:48:19 -04:00
|
|
|
}
|
|
|
|
|
|
2014-06-06 17:01:05 +02:00
|
|
|
libinput_timer_subsys_destroy(libinput);
|
|
|
|
|
libinput_drop_destroyed_sources(libinput);
|
2013-11-17 11:19:50 +01:00
|
|
|
close(libinput->epoll_fd);
|
|
|
|
|
free(libinput);
|
2014-06-25 00:06:58 +02:00
|
|
|
|
|
|
|
|
return NULL;
|
2013-11-17 11:19:50 +01:00
|
|
|
}
|
|
|
|
|
|
2016-05-24 14:37:54 +10:00
|
|
|
static void
|
|
|
|
|
libinput_event_tablet_tool_destroy(struct libinput_event_tablet_tool *event)
|
|
|
|
|
{
|
|
|
|
|
libinput_tablet_tool_unref(event->tool);
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-02 15:35:43 +10:00
|
|
|
static void
|
|
|
|
|
libinput_event_tablet_pad_destroy(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
libinput_tablet_pad_mode_group_unref(event->mode_group);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-21 13:56:12 +10:00
|
|
|
LIBINPUT_EXPORT void
|
|
|
|
|
libinput_event_destroy(struct libinput_event *event)
|
2013-12-07 16:41:43 +01:00
|
|
|
{
|
2014-01-21 13:56:12 +10:00
|
|
|
if (event == NULL)
|
|
|
|
|
return;
|
2013-12-13 17:49:38 +10:00
|
|
|
|
2016-05-24 14:37:54 +10:00
|
|
|
switch(event->type) {
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
|
|
|
|
|
libinput_event_tablet_tool_destroy(
|
|
|
|
|
libinput_event_get_tablet_tool_event(event));
|
|
|
|
|
break;
|
2016-06-02 15:35:43 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_PAD_RING:
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_PAD_STRIP:
|
|
|
|
|
case LIBINPUT_EVENT_TABLET_PAD_BUTTON:
|
|
|
|
|
libinput_event_tablet_pad_destroy(
|
|
|
|
|
libinput_event_get_tablet_pad_event(event));
|
|
|
|
|
break;
|
2016-05-24 14:37:54 +10:00
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-22 23:45:44 +01:00
|
|
|
if (event->device)
|
2013-12-19 11:42:55 +10:00
|
|
|
libinput_device_unref(event->device);
|
2013-12-07 16:41:43 +01:00
|
|
|
|
|
|
|
|
free(event);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
return libinput->interface->open_restricted(path,
|
|
|
|
|
flags,
|
|
|
|
|
libinput->user_data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
close_restricted(struct libinput *libinput, int fd)
|
|
|
|
|
{
|
|
|
|
|
return libinput->interface->close_restricted(fd, libinput->user_data);
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-27 16:08:04 +08:00
|
|
|
bool
|
|
|
|
|
ignore_litest_test_suite_device(struct udev_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!getenv("LIBINPUT_RUNNING_TEST_SUITE") &&
|
|
|
|
|
udev_device_get_property_value(device, "LIBINPUT_TEST_DEVICE"))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
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_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
|
|
|
{
|
|
|
|
|
seat->refcount = 1;
|
|
|
|
|
seat->libinput = libinput;
|
2017-07-07 09:47:06 +10:00
|
|
|
seat->physical_name = safe_strdup(physical_name);
|
|
|
|
|
seat->logical_name = safe_strdup(logical_name);
|
2013-12-13 11:37:31 +10:00
|
|
|
seat->destroy = 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
|
|
|
list_init(&seat->devices_list);
|
2014-02-10 11:40:55 +10:00
|
|
|
list_insert(&libinput->seat_list, &seat->link);
|
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-06-25 00:06:57 +02:00
|
|
|
LIBINPUT_EXPORT struct libinput_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
|
|
|
libinput_seat_ref(struct libinput_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
seat->refcount++;
|
2014-06-25 00:06:57 +02:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
2013-12-31 16:11:03 +01:00
|
|
|
static void
|
|
|
|
|
libinput_seat_destroy(struct libinput_seat *seat)
|
|
|
|
|
{
|
2013-12-13 11:37:31 +10:00
|
|
|
list_remove(&seat->link);
|
2014-01-15 17:04:00 +10:00
|
|
|
free(seat->logical_name);
|
|
|
|
|
free(seat->physical_name);
|
2013-12-13 11:37:31 +10:00
|
|
|
seat->destroy(seat);
|
2013-12-31 16:11:03 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 00:06:57 +02:00
|
|
|
LIBINPUT_EXPORT struct libinput_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
|
|
|
libinput_seat_unref(struct libinput_seat *seat)
|
|
|
|
|
{
|
2014-01-08 16:40:14 +10:00
|
|
|
assert(seat->refcount > 0);
|
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
|
|
|
seat->refcount--;
|
2014-06-25 00:06:57 +02:00
|
|
|
if (seat->refcount == 0) {
|
2013-12-31 16:11:03 +01:00
|
|
|
libinput_seat_destroy(seat);
|
2014-06-25 00:06:57 +02:00
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
return 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void
|
|
|
|
|
libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data)
|
|
|
|
|
{
|
|
|
|
|
seat->user_data = user_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void *
|
|
|
|
|
libinput_seat_get_user_data(struct libinput_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
return seat->user_data;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 16:00:13 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput *
|
|
|
|
|
libinput_seat_get_context(struct libinput_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
return seat->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
|
|
|
LIBINPUT_EXPORT const char *
|
2014-01-15 17:04:00 +10:00
|
|
|
libinput_seat_get_physical_name(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
|
|
|
{
|
2014-01-15 17:04:00 +10:00
|
|
|
return seat->physical_name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT const char *
|
|
|
|
|
libinput_seat_get_logical_name(struct libinput_seat *seat)
|
|
|
|
|
{
|
|
|
|
|
return seat->logical_name;
|
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)
|
|
|
|
|
{
|
|
|
|
|
device->seat = seat;
|
|
|
|
|
device->refcount = 1;
|
2014-09-28 13:21:02 +02:00
|
|
|
list_init(&device->event_listeners);
|
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-06-25 00:06:57 +02:00
|
|
|
LIBINPUT_EXPORT struct libinput_device *
|
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
|
|
|
libinput_device_ref(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
device->refcount++;
|
2014-06-25 00:06:57 +02:00
|
|
|
return device;
|
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
|
|
|
}
|
|
|
|
|
|
2013-12-31 16:11:03 +01:00
|
|
|
static void
|
|
|
|
|
libinput_device_destroy(struct libinput_device *device)
|
|
|
|
|
{
|
2014-09-28 13:21:02 +02:00
|
|
|
assert(list_empty(&device->event_listeners));
|
2017-01-30 19:48:33 +10:00
|
|
|
evdev_device_destroy(evdev_device(device));
|
2013-12-31 16:11:03 +01:00
|
|
|
}
|
|
|
|
|
|
2014-06-25 00:06:57 +02:00
|
|
|
LIBINPUT_EXPORT struct libinput_device *
|
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
|
|
|
libinput_device_unref(struct libinput_device *device)
|
|
|
|
|
{
|
2014-01-08 16:40:14 +10:00
|
|
|
assert(device->refcount > 0);
|
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
|
|
|
device->refcount--;
|
2014-06-25 00:06:57 +02:00
|
|
|
if (device->refcount == 0) {
|
2013-12-31 16:11:03 +01:00
|
|
|
libinput_device_destroy(device);
|
2014-06-25 00:06:57 +02:00
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
return device;
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_get_fd(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
return libinput->epoll_fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_dispatch(struct libinput *libinput)
|
|
|
|
|
{
|
2014-01-07 15:45:55 +10:00
|
|
|
struct libinput_source *source;
|
2013-11-17 11:19:50 +01:00
|
|
|
struct epoll_event ep[32];
|
|
|
|
|
int i, count;
|
|
|
|
|
|
|
|
|
|
count = epoll_wait(libinput->epoll_fd, ep, ARRAY_LENGTH(ep), 0);
|
|
|
|
|
if (count < 0)
|
2013-12-05 17:26:40 +10:00
|
|
|
return -errno;
|
2013-11-17 11:19:50 +01:00
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
|
source = ep[i].data.ptr;
|
|
|
|
|
if (source->fd == -1)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
source->dispatch(source->user_data);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-07 15:45:55 +10:00
|
|
|
libinput_drop_destroyed_sources(libinput);
|
2013-11-17 11:19:50 +01:00
|
|
|
|
2013-12-30 22:08:35 +01:00
|
|
|
return 0;
|
2013-11-17 11:19:50 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-25 15:19:50 +10:00
|
|
|
void
|
|
|
|
|
libinput_device_init_event_listener(struct libinput_event_listener *listener)
|
|
|
|
|
{
|
|
|
|
|
list_init(&listener->link);
|
|
|
|
|
}
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
listener->notify_func = notify_func;
|
|
|
|
|
listener->notify_func_data = notify_func_data;
|
|
|
|
|
list_insert(&device->event_listeners, &listener->link);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
libinput_device_remove_event_listener(struct libinput_event_listener *listener)
|
|
|
|
|
{
|
|
|
|
|
list_remove(&listener->link);
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
static uint32_t
|
|
|
|
|
update_seat_key_count(struct libinput_seat *seat,
|
|
|
|
|
int32_t key,
|
2014-06-17 07:55:35 +10:00
|
|
|
enum libinput_key_state state)
|
2014-04-01 21:57:45 +02:00
|
|
|
{
|
|
|
|
|
assert(key >= 0 && key <= KEY_MAX);
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
2014-06-17 07:55:35 +10:00
|
|
|
case LIBINPUT_KEY_STATE_PRESSED:
|
2014-04-01 21:57:45 +02:00
|
|
|
return ++seat->button_count[key];
|
2014-06-17 07:55:35 +10:00
|
|
|
case LIBINPUT_KEY_STATE_RELEASED:
|
2014-04-01 21:57:45 +02:00
|
|
|
/* 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,
|
2014-06-03 20:08:02 -04:00
|
|
|
enum libinput_button_state state)
|
2014-04-01 21:57:45 +02:00
|
|
|
{
|
|
|
|
|
assert(button >= 0 && button <= KEY_MAX);
|
|
|
|
|
|
|
|
|
|
switch (state) {
|
2014-06-03 20:08:02 -04:00
|
|
|
case LIBINPUT_BUTTON_STATE_PRESSED:
|
2014-04-01 21:57:45 +02:00
|
|
|
return ++seat->button_count[button];
|
2014-06-03 20:08:02 -04:00
|
|
|
case LIBINPUT_BUTTON_STATE_RELEASED:
|
2014-04-01 21:57:45 +02:00
|
|
|
/* We might not have received the first PRESSED event. */
|
|
|
|
|
if (seat->button_count[button] == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return --seat->button_count[button];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-16 19:32:46 +01:00
|
|
|
static void
|
2013-11-17 11:19:50 +01:00
|
|
|
init_event_base(struct libinput_event *event,
|
2014-01-17 17:59:30 +10:00
|
|
|
struct libinput_device *device,
|
2013-12-19 11:42:55 +10:00
|
|
|
enum libinput_event_type type)
|
2013-11-17 11:19:50 +01:00
|
|
|
{
|
|
|
|
|
event->type = type;
|
2014-01-17 17:59:30 +10:00
|
|
|
event->device = device;
|
2013-11-17 11:19:50 +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
|
|
|
static void
|
2014-01-17 17:59:30 +10:00
|
|
|
post_base_event(struct libinput_device *device,
|
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
|
|
|
enum libinput_event_type type,
|
|
|
|
|
struct libinput_event *event)
|
|
|
|
|
{
|
2014-01-17 17:59:30 +10:00
|
|
|
struct libinput *libinput = device->seat->libinput;
|
2013-12-19 11:42:55 +10:00
|
|
|
init_event_base(event, device, type);
|
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
|
|
|
libinput_post_event(libinput, event);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
static void
|
|
|
|
|
post_device_event(struct libinput_device *device,
|
2014-09-28 13:21:01 +02:00
|
|
|
uint64_t time,
|
2013-11-17 11:19:50 +01:00
|
|
|
enum libinput_event_type type,
|
|
|
|
|
struct libinput_event *event)
|
|
|
|
|
{
|
2014-09-28 13:21:02 +02:00
|
|
|
struct libinput_event_listener *listener, *tmp;
|
2017-04-28 13:44:59 +10:00
|
|
|
#if 0
|
|
|
|
|
struct libinput *libinput = device->seat->libinput;
|
|
|
|
|
|
|
|
|
|
if (libinput->last_event_time > time) {
|
|
|
|
|
log_bug_libinput(device->seat->libinput,
|
|
|
|
|
"out-of-order timestamps for %s time %" PRIu64 "\n",
|
|
|
|
|
event_type_to_str(type),
|
|
|
|
|
time);
|
|
|
|
|
}
|
|
|
|
|
libinput->last_event_time = time;
|
|
|
|
|
#endif
|
2014-09-28 13:21:02 +02:00
|
|
|
|
2013-12-19 11:42:55 +10:00
|
|
|
init_event_base(event, device, type);
|
2014-09-28 13:21:02 +02:00
|
|
|
|
|
|
|
|
list_for_each_safe(listener, tmp, &device->event_listeners, link)
|
|
|
|
|
listener->notify_func(time, event, listener->notify_func_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
|
|
|
libinput_post_event(device->seat->libinput, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
notify_added_device(struct libinput_device *device)
|
|
|
|
|
{
|
2014-01-15 17:10:30 +10:00
|
|
|
struct libinput_event_device_notify *added_device_event;
|
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-22 11:01:24 +10:00
|
|
|
added_device_event = zalloc(sizeof *added_device_event);
|
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-17 17:59:30 +10:00
|
|
|
post_base_event(device,
|
2013-12-19 12:04:24 +10:00
|
|
|
LIBINPUT_EVENT_DEVICE_ADDED,
|
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
|
|
|
&added_device_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
notify_removed_device(struct libinput_device *device)
|
|
|
|
|
{
|
2014-01-15 17:10:30 +10:00
|
|
|
struct libinput_event_device_notify *removed_device_event;
|
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-22 11:01:24 +10:00
|
|
|
removed_device_event = zalloc(sizeof *removed_device_event);
|
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-17 17:59:30 +10:00
|
|
|
post_base_event(device,
|
2013-12-19 12:04:24 +10:00
|
|
|
LIBINPUT_EVENT_DEVICE_REMOVED,
|
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
|
|
|
&removed_device_event->base);
|
2013-11-17 11:19:50 +01:00
|
|
|
}
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
static inline bool
|
|
|
|
|
device_has_cap(struct libinput_device *device,
|
|
|
|
|
enum libinput_device_capability cap)
|
|
|
|
|
{
|
|
|
|
|
const char *capability;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_has_capability(device, cap))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
switch (cap) {
|
|
|
|
|
case LIBINPUT_DEVICE_CAP_POINTER:
|
|
|
|
|
capability = "CAP_POINTER";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_DEVICE_CAP_KEYBOARD:
|
|
|
|
|
capability = "CAP_KEYBOARD";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_DEVICE_CAP_TOUCH:
|
|
|
|
|
capability = "CAP_TOUCH";
|
|
|
|
|
break;
|
2015-01-22 16:41:50 +01:00
|
|
|
case LIBINPUT_DEVICE_CAP_GESTURE:
|
|
|
|
|
capability = "CAP_GESTURE";
|
|
|
|
|
break;
|
2015-11-16 16:26:56 +10:00
|
|
|
case LIBINPUT_DEVICE_CAP_TABLET_TOOL:
|
2016-02-01 17:19:55 +10:00
|
|
|
capability = "CAP_TABLET_TOOL";
|
2015-05-26 10:39:57 +10:00
|
|
|
break;
|
2016-01-21 12:35:11 +10:00
|
|
|
case LIBINPUT_DEVICE_CAP_TABLET_PAD:
|
|
|
|
|
capability = "CAP_TABLET_PAD";
|
|
|
|
|
break;
|
2017-01-20 16:54:13 +11:00
|
|
|
case LIBINPUT_DEVICE_CAP_SWITCH:
|
|
|
|
|
capability = "CAP_SWITCH";
|
|
|
|
|
break;
|
2015-04-13 10:23:46 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
log_bug_libinput(device->seat->libinput,
|
|
|
|
|
"Event for missing capability %s on device \"%s\"\n",
|
|
|
|
|
capability,
|
|
|
|
|
libinput_device_get_name(device));
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2013-12-19 16:40:48 +10:00
|
|
|
struct libinput_event_keyboard *key_event;
|
2014-04-01 21:57:45 +02:00
|
|
|
uint32_t seat_key_count;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-22 11:01:24 +10:00
|
|
|
key_event = zalloc(sizeof *key_event);
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
seat_key_count = update_seat_key_count(device->seat, key, state);
|
|
|
|
|
|
2013-12-19 16:40:48 +10:00
|
|
|
*key_event = (struct libinput_event_keyboard) {
|
2013-11-16 19:32:46 +01:00
|
|
|
.time = time,
|
|
|
|
|
.key = key,
|
|
|
|
|
.state = state,
|
2014-04-01 21:57:45 +02:00
|
|
|
.seat_key_count = seat_key_count,
|
2013-11-16 19:32:46 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY,
|
|
|
|
|
&key_event->base);
|
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,
|
2015-03-11 10:43:18 +10:00
|
|
|
const struct normalized_coords *delta,
|
2015-06-26 09:07:24 +10:00
|
|
|
const struct device_float_coords *raw)
|
2013-11-10 17:55:40 +01:00
|
|
|
{
|
2013-12-19 13:15:28 +10:00
|
|
|
struct libinput_event_pointer *motion_event;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-22 11:01:24 +10:00
|
|
|
motion_event = zalloc(sizeof *motion_event);
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2013-12-19 13:15:28 +10:00
|
|
|
*motion_event = (struct libinput_event_pointer) {
|
2013-11-16 19:32:46 +01:00
|
|
|
.time = time,
|
2015-03-11 11:19:24 +10:00
|
|
|
.delta = *delta,
|
2015-06-26 09:07:24 +10:00
|
|
|
.delta_raw = *raw,
|
2013-11-16 19:32:46 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EVENT_POINTER_MOTION,
|
|
|
|
|
&motion_event->base);
|
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,
|
2015-03-11 10:43:18 +10:00
|
|
|
const struct device_coords *point)
|
2013-11-10 17:55:40 +01:00
|
|
|
{
|
2013-12-19 13:15:28 +10:00
|
|
|
struct libinput_event_pointer *motion_absolute_event;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-22 11:01:24 +10:00
|
|
|
motion_absolute_event = zalloc(sizeof *motion_absolute_event);
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2013-12-19 13:15:28 +10:00
|
|
|
*motion_absolute_event = (struct libinput_event_pointer) {
|
2013-11-16 19:32:46 +01:00
|
|
|
.time = time,
|
2015-03-11 11:19:24 +10:00
|
|
|
.absolute = *point,
|
2013-11-16 19:32:46 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
|
|
|
|
|
&motion_absolute_event->base);
|
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
|
|
|
{
|
2013-12-19 13:15:28 +10:00
|
|
|
struct libinput_event_pointer *button_event;
|
2014-04-01 21:57:45 +02:00
|
|
|
int32_t seat_button_count;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-22 11:01:24 +10:00
|
|
|
button_event = zalloc(sizeof *button_event);
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2014-04-01 21:57:45 +02:00
|
|
|
seat_button_count = update_seat_button_count(device->seat,
|
|
|
|
|
button,
|
|
|
|
|
state);
|
|
|
|
|
|
2013-12-19 13:15:28 +10:00
|
|
|
*button_event = (struct libinput_event_pointer) {
|
2013-11-16 19:32:46 +01:00
|
|
|
.time = time,
|
|
|
|
|
.button = button,
|
|
|
|
|
.state = state,
|
2014-04-01 21:57:45 +02:00
|
|
|
.seat_button_count = seat_button_count,
|
2013-11-16 19:32:46 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON,
|
|
|
|
|
&button_event->base);
|
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-03-11 10:36:44 +10:00
|
|
|
const struct normalized_coords *delta,
|
2015-03-11 11:30:02 +10:00
|
|
|
const struct discrete_coords *discrete)
|
2013-11-10 17:55:40 +01:00
|
|
|
{
|
2013-12-19 13:15:28 +10:00
|
|
|
struct libinput_event_pointer *axis_event;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-22 11:01:24 +10:00
|
|
|
axis_event = zalloc(sizeof *axis_event);
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2013-12-19 13:15:28 +10:00
|
|
|
*axis_event = (struct libinput_event_pointer) {
|
2013-11-16 19:32:46 +01:00
|
|
|
.time = time,
|
2015-03-11 11:19:24 +10:00
|
|
|
.delta = *delta,
|
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
|
|
|
.source = source,
|
2014-12-24 11:10:04 +10:00
|
|
|
.axes = axes,
|
2015-03-11 11:30:02 +10:00
|
|
|
.discrete = *discrete,
|
2013-11-16 19:32:46 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EVENT_POINTER_AXIS,
|
|
|
|
|
&axis_event->base);
|
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,
|
2015-03-11 10:48:54 +10:00
|
|
|
const struct device_coords *point)
|
2014-02-19 21:39:26 +01:00
|
|
|
{
|
|
|
|
|
struct libinput_event_touch *touch_event;
|
|
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-02-19 21:39:26 +01:00
|
|
|
touch_event = zalloc(sizeof *touch_event);
|
|
|
|
|
|
|
|
|
|
*touch_event = (struct libinput_event_touch) {
|
|
|
|
|
.time = time,
|
|
|
|
|
.slot = slot,
|
|
|
|
|
.seat_slot = seat_slot,
|
2015-03-11 10:48:54 +10:00
|
|
|
.point = *point,
|
2014-02-19 21:39:26 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2014-02-19 21:39:26 +01:00
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
&touch_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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,
|
2015-03-11 10:48:54 +10:00
|
|
|
const struct device_coords *point)
|
2013-11-10 17:55:40 +01:00
|
|
|
{
|
2013-12-19 17:16:19 +10:00
|
|
|
struct libinput_event_touch *touch_event;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-22 11:01:24 +10:00
|
|
|
touch_event = zalloc(sizeof *touch_event);
|
2013-11-16 19:32:46 +01:00
|
|
|
|
2013-12-19 17:16:19 +10:00
|
|
|
*touch_event = (struct libinput_event_touch) {
|
2013-11-16 19:32:46 +01:00
|
|
|
.time = time,
|
|
|
|
|
.slot = slot,
|
2014-01-30 22:44:49 +01:00
|
|
|
.seat_slot = seat_slot,
|
2015-03-11 10:48:54 +10:00
|
|
|
.point = *point,
|
2013-11-16 19:32:46 +01:00
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2014-02-19 21:39:26 +01:00
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
&touch_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_touch *touch_event;
|
|
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
|
|
|
|
|
return;
|
|
|
|
|
|
2014-02-19 21:39:26 +01:00
|
|
|
touch_event = zalloc(sizeof *touch_event);
|
|
|
|
|
|
|
|
|
|
*touch_event = (struct libinput_event_touch) {
|
|
|
|
|
.time = time,
|
|
|
|
|
.slot = slot,
|
|
|
|
|
.seat_slot = seat_slot,
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2014-02-19 21:39:26 +01:00
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
2013-11-17 11:19:50 +01:00
|
|
|
&touch_event->base);
|
2013-11-10 17:55:40 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-20 10:15:00 +10:00
|
|
|
void
|
|
|
|
|
touch_notify_frame(struct libinput_device *device,
|
2014-09-28 13:21:00 +02:00
|
|
|
uint64_t time)
|
2013-12-20 10:15:00 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_touch *touch_event;
|
|
|
|
|
|
2015-04-13 10:23:46 +10:00
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_TOUCH))
|
|
|
|
|
return;
|
|
|
|
|
|
2013-12-20 10:15:00 +10:00
|
|
|
touch_event = zalloc(sizeof *touch_event);
|
|
|
|
|
|
|
|
|
|
*touch_event = (struct libinput_event_touch) {
|
|
|
|
|
.time = time,
|
|
|
|
|
};
|
|
|
|
|
|
2014-09-28 13:21:01 +02:00
|
|
|
post_device_event(device, time,
|
2013-12-20 10:15:00 +10:00
|
|
|
LIBINPUT_EVENT_TOUCH_FRAME,
|
|
|
|
|
&touch_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-05 23:20:36 -04:00
|
|
|
void
|
|
|
|
|
tablet_notify_axis(struct libinput_device *device,
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state,
|
2014-06-05 23:20:36 -04:00
|
|
|
unsigned char *changed_axes,
|
2016-01-06 16:16:46 +10:00
|
|
|
const struct tablet_axes *axes)
|
2014-06-05 23:20:36 -04:00
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *axis_event;
|
2014-06-05 23:20:36 -04:00
|
|
|
|
|
|
|
|
axis_event = zalloc(sizeof *axis_event);
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
*axis_event = (struct libinput_event_tablet_tool) {
|
2014-06-05 23:20:36 -04:00
|
|
|
.time = time,
|
2016-05-24 14:37:54 +10:00
|
|
|
.tool = libinput_tablet_tool_ref(tool),
|
2016-01-05 14:08:01 +10:00
|
|
|
.proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
|
2015-11-12 08:01:43 +10:00
|
|
|
.tip_state = tip_state,
|
2016-01-06 16:16:46 +10:00
|
|
|
.axes = *axes,
|
2014-06-05 23:20:36 -04:00
|
|
|
};
|
|
|
|
|
|
2014-06-27 09:19:03 +10:00
|
|
|
memcpy(axis_event->changed_axes,
|
2014-06-05 23:20:36 -04:00
|
|
|
changed_axes,
|
|
|
|
|
sizeof(axis_event->changed_axes));
|
|
|
|
|
|
|
|
|
|
post_device_event(device,
|
2014-12-08 11:14:11 +10:00
|
|
|
time,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
2014-06-05 23:20:36 -04:00
|
|
|
&axis_event->base);
|
|
|
|
|
}
|
2013-12-20 10:15:00 +10: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,
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:41:48 +10:00
|
|
|
enum libinput_tablet_tool_proximity_state proximity_state,
|
2015-02-16 22:48:44 -05:00
|
|
|
unsigned char *changed_axes,
|
2016-01-06 16:16:46 +10:00
|
|
|
const struct tablet_axes *axes)
|
2014-06-06 16:35:33 -04:00
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *proximity_event;
|
2014-06-06 16:35:33 -04:00
|
|
|
|
2015-02-16 22:48:42 -05:00
|
|
|
proximity_event = zalloc(sizeof *proximity_event);
|
2014-06-06 16:35:33 -04:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
*proximity_event = (struct libinput_event_tablet_tool) {
|
2014-06-26 21:31:52 -04:00
|
|
|
.time = time,
|
2016-05-24 14:37:54 +10:00
|
|
|
.tool = libinput_tablet_tool_ref(tool),
|
2015-12-21 15:24:03 +10:00
|
|
|
.tip_state = LIBINPUT_TABLET_TOOL_TIP_UP,
|
2015-02-16 22:48:42 -05:00
|
|
|
.proximity_state = proximity_state,
|
2016-01-06 16:16:46 +10:00
|
|
|
.axes = *axes,
|
2014-06-06 16:35:33 -04:00
|
|
|
};
|
2015-02-16 22:48:44 -05:00
|
|
|
memcpy(proximity_event->changed_axes,
|
|
|
|
|
changed_axes,
|
|
|
|
|
sizeof(proximity_event->changed_axes));
|
2014-06-06 16:35:33 -04:00
|
|
|
|
|
|
|
|
post_device_event(device,
|
2014-12-08 11:14:11 +10:00
|
|
|
time,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
|
2015-02-16 22:48:42 -05:00
|
|
|
&proximity_event->base);
|
2014-06-06 16:35:33 -04:00
|
|
|
}
|
|
|
|
|
|
2015-11-11 13:39:43 +10:00
|
|
|
void
|
|
|
|
|
tablet_notify_tip(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state,
|
2015-12-15 08:39:56 +10:00
|
|
|
unsigned char *changed_axes,
|
2016-01-06 16:16:46 +10:00
|
|
|
const struct tablet_axes *axes)
|
2015-11-11 13:39:43 +10:00
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *tip_event;
|
2015-11-11 13:39:43 +10:00
|
|
|
|
|
|
|
|
tip_event = zalloc(sizeof *tip_event);
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
*tip_event = (struct libinput_event_tablet_tool) {
|
2015-11-11 13:39:43 +10:00
|
|
|
.time = time,
|
2016-05-24 14:37:54 +10:00
|
|
|
.tool = libinput_tablet_tool_ref(tool),
|
2015-11-11 13:39:43 +10:00
|
|
|
.tip_state = tip_state,
|
2016-01-05 14:08:01 +10:00
|
|
|
.proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
|
2016-01-06 16:16:46 +10:00
|
|
|
.axes = *axes,
|
2015-11-11 13:39:43 +10:00
|
|
|
};
|
2015-12-15 08:39:56 +10:00
|
|
|
memcpy(tip_event->changed_axes,
|
|
|
|
|
changed_axes,
|
|
|
|
|
sizeof(tip_event->changed_axes));
|
2015-11-11 13:39:43 +10:00
|
|
|
|
|
|
|
|
post_device_event(device,
|
|
|
|
|
time,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2015-11-11 13:39:43 +10:00
|
|
|
&tip_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-10 23:14:41 -04:00
|
|
|
void
|
|
|
|
|
tablet_notify_button(struct libinput_device *device,
|
2015-08-04 12:37:40 +10:00
|
|
|
uint64_t time,
|
2015-11-16 15:34:19 +10:00
|
|
|
struct libinput_tablet_tool *tool,
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state tip_state,
|
2016-01-06 16:16:46 +10:00
|
|
|
const struct tablet_axes *axes,
|
2014-06-10 23:14:41 -04:00
|
|
|
int32_t button,
|
|
|
|
|
enum libinput_button_state state)
|
|
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *button_event;
|
2014-06-10 23:14:41 -04:00
|
|
|
int32_t seat_button_count;
|
|
|
|
|
|
|
|
|
|
button_event = zalloc(sizeof *button_event);
|
|
|
|
|
|
|
|
|
|
seat_button_count = update_seat_button_count(device->seat,
|
|
|
|
|
button,
|
|
|
|
|
state);
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
*button_event = (struct libinput_event_tablet_tool) {
|
2014-06-10 23:14:41 -04:00
|
|
|
.time = time,
|
2016-05-24 14:37:54 +10:00
|
|
|
.tool = libinput_tablet_tool_ref(tool),
|
2014-06-10 23:14:41 -04:00
|
|
|
.button = button,
|
|
|
|
|
.state = state,
|
|
|
|
|
.seat_button_count = seat_button_count,
|
2016-01-05 14:08:01 +10:00
|
|
|
.proximity_state = LIBINPUT_TABLET_TOOL_PROXIMITY_STATE_IN,
|
2015-11-12 08:01:43 +10:00
|
|
|
.tip_state = tip_state,
|
2016-01-06 16:16:46 +10:00
|
|
|
.axes = *axes,
|
2014-06-10 23:14:41 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
post_device_event(device,
|
2014-12-08 11:14:11 +10:00
|
|
|
time,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON,
|
2014-06-10 23:14:41 -04:00
|
|
|
&button_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
void
|
|
|
|
|
tablet_pad_notify_button(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int32_t button,
|
2016-06-02 15:35:43 +10:00
|
|
|
enum libinput_button_state state,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
2016-01-21 12:35:11 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_tablet_pad *button_event;
|
2016-06-02 15:35:43 +10:00
|
|
|
unsigned int mode;
|
2016-01-21 12:35:11 +10:00
|
|
|
|
|
|
|
|
button_event = zalloc(sizeof *button_event);
|
|
|
|
|
|
2016-06-02 15:35:43 +10:00
|
|
|
mode = libinput_tablet_pad_mode_group_get_mode(group);
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
*button_event = (struct libinput_event_tablet_pad) {
|
|
|
|
|
.time = time,
|
2016-05-26 10:03:47 +10:00
|
|
|
.button.number = button,
|
|
|
|
|
.button.state = state,
|
2016-06-02 15:35:43 +10:00
|
|
|
.mode_group = libinput_tablet_pad_mode_group_ref(group),
|
|
|
|
|
.mode = mode,
|
2016-01-21 12:35:11 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
post_device_event(device,
|
|
|
|
|
time,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON,
|
|
|
|
|
&button_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tablet_pad_notify_ring(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
double value,
|
2016-06-02 15:35:43 +10:00
|
|
|
enum libinput_tablet_pad_ring_axis_source source,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
2016-01-21 12:35:11 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_tablet_pad *ring_event;
|
2016-06-02 15:35:43 +10:00
|
|
|
unsigned int mode;
|
2016-01-21 12:35:11 +10:00
|
|
|
|
|
|
|
|
ring_event = zalloc(sizeof *ring_event);
|
|
|
|
|
|
2016-06-02 15:35:43 +10:00
|
|
|
mode = libinput_tablet_pad_mode_group_get_mode(group);
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
*ring_event = (struct libinput_event_tablet_pad) {
|
|
|
|
|
.time = time,
|
|
|
|
|
.ring.number = number,
|
|
|
|
|
.ring.position = value,
|
|
|
|
|
.ring.source = source,
|
2016-06-02 15:35:43 +10:00
|
|
|
.mode_group = libinput_tablet_pad_mode_group_ref(group),
|
|
|
|
|
.mode = mode,
|
2016-01-21 12:35:11 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
post_device_event(device,
|
|
|
|
|
time,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
&ring_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
tablet_pad_notify_strip(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
unsigned int number,
|
|
|
|
|
double value,
|
2016-06-02 15:35:43 +10:00
|
|
|
enum libinput_tablet_pad_strip_axis_source source,
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
2016-01-21 12:35:11 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_tablet_pad *strip_event;
|
2016-06-02 15:35:43 +10:00
|
|
|
unsigned int mode;
|
2016-01-21 12:35:11 +10:00
|
|
|
|
|
|
|
|
strip_event = zalloc(sizeof *strip_event);
|
|
|
|
|
|
2016-06-02 15:35:43 +10:00
|
|
|
mode = libinput_tablet_pad_mode_group_get_mode(group);
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
*strip_event = (struct libinput_event_tablet_pad) {
|
|
|
|
|
.time = time,
|
|
|
|
|
.strip.number = number,
|
|
|
|
|
.strip.position = value,
|
|
|
|
|
.strip.source = source,
|
2016-06-02 15:35:43 +10:00
|
|
|
.mode_group = libinput_tablet_pad_mode_group_ref(group),
|
|
|
|
|
.mode = mode,
|
2016-01-21 12:35:11 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
post_device_event(device,
|
|
|
|
|
time,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
&strip_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
static void
|
|
|
|
|
gesture_notify(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int finger_count,
|
2015-04-29 13:19:51 +02:00
|
|
|
int cancelled,
|
2015-03-04 15:24:04 +01:00
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct normalized_coords *unaccel,
|
|
|
|
|
double scale,
|
|
|
|
|
double angle)
|
2015-01-22 16:41:50 +01:00
|
|
|
{
|
|
|
|
|
struct libinput_event_gesture *gesture_event;
|
|
|
|
|
|
|
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_GESTURE))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
gesture_event = zalloc(sizeof *gesture_event);
|
|
|
|
|
|
|
|
|
|
*gesture_event = (struct libinput_event_gesture) {
|
|
|
|
|
.time = time,
|
|
|
|
|
.finger_count = finger_count,
|
2015-04-29 13:19:51 +02:00
|
|
|
.cancelled = cancelled,
|
2015-01-22 16:41:50 +01:00
|
|
|
.delta = *delta,
|
|
|
|
|
.delta_unaccel = *unaccel,
|
2015-03-04 15:24:04 +01:00
|
|
|
.scale = scale,
|
|
|
|
|
.angle = angle,
|
2015-01-22 16:41:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
post_device_event(device, time, type,
|
|
|
|
|
&gesture_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
void
|
|
|
|
|
gesture_notify_swipe(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_event_type type,
|
|
|
|
|
int finger_count,
|
|
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct normalized_coords *unaccel)
|
|
|
|
|
{
|
2015-04-29 13:19:51 +02:00
|
|
|
gesture_notify(device, time, type, finger_count, 0, delta, unaccel,
|
2015-03-04 15:24:04 +01:00
|
|
|
0.0, 0.0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 13:19:51 +02:00
|
|
|
void
|
|
|
|
|
gesture_notify_swipe_end(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
int finger_count,
|
|
|
|
|
int cancelled)
|
|
|
|
|
{
|
|
|
|
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
|
|
|
|
|
|
|
|
|
gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_SWIPE_END,
|
|
|
|
|
finger_count, cancelled, &zero, &zero, 0.0, 0.0);
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
void
|
|
|
|
|
gesture_notify_pinch(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_event_type type,
|
2016-01-07 13:57:03 +10:00
|
|
|
int finger_count,
|
2015-03-04 15:24:04 +01:00
|
|
|
const struct normalized_coords *delta,
|
|
|
|
|
const struct normalized_coords *unaccel,
|
|
|
|
|
double scale,
|
|
|
|
|
double angle)
|
|
|
|
|
{
|
2016-01-07 13:57:03 +10:00
|
|
|
gesture_notify(device, time, type, finger_count, 0,
|
|
|
|
|
delta, unaccel, scale, angle);
|
2015-04-29 13:19:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
gesture_notify_pinch_end(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
2016-01-07 13:57:03 +10:00
|
|
|
int finger_count,
|
2015-05-22 10:58:56 +10:00
|
|
|
double scale,
|
2015-04-29 13:19:51 +02:00
|
|
|
int cancelled)
|
|
|
|
|
{
|
|
|
|
|
const struct normalized_coords zero = { 0.0, 0.0 };
|
|
|
|
|
|
|
|
|
|
gesture_notify(device, time, LIBINPUT_EVENT_GESTURE_PINCH_END,
|
2016-01-07 13:57:03 +10:00
|
|
|
finger_count, cancelled, &zero, &zero, scale, 0.0);
|
2015-03-04 15:24:04 +01:00
|
|
|
}
|
|
|
|
|
|
2017-01-20 16:54:13 +11:00
|
|
|
void
|
|
|
|
|
switch_notify_toggle(struct libinput_device *device,
|
|
|
|
|
uint64_t time,
|
|
|
|
|
enum libinput_switch sw,
|
|
|
|
|
enum libinput_switch_state state)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_switch *switch_event;
|
|
|
|
|
|
|
|
|
|
if (!device_has_cap(device, LIBINPUT_DEVICE_CAP_SWITCH))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
switch_event = zalloc(sizeof *switch_event);
|
|
|
|
|
|
|
|
|
|
*switch_event = (struct libinput_event_switch) {
|
|
|
|
|
.time = time,
|
|
|
|
|
.sw = sw,
|
|
|
|
|
.state = state,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
post_device_event(device, time,
|
|
|
|
|
LIBINPUT_EVENT_SWITCH_TOGGLE,
|
|
|
|
|
&switch_event->base);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
static void
|
2013-11-17 11:19:50 +01:00
|
|
|
libinput_post_event(struct libinput *libinput,
|
|
|
|
|
struct libinput_event *event)
|
2013-11-10 17:55:40 +01:00
|
|
|
{
|
2013-11-17 11:19:50 +01:00
|
|
|
struct libinput_event **events = libinput->events;
|
|
|
|
|
size_t events_len = libinput->events_len;
|
|
|
|
|
size_t events_count = libinput->events_count;
|
2013-11-16 19:32:46 +01:00
|
|
|
size_t move_len;
|
|
|
|
|
size_t new_out;
|
|
|
|
|
|
2015-12-14 07:39:26 +10:00
|
|
|
#if 0
|
|
|
|
|
log_debug(libinput, "Queuing %s\n", event_type_to_str(event->type));
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-11-16 19:32:46 +01:00
|
|
|
events_count++;
|
|
|
|
|
if (events_count > events_len) {
|
2013-12-24 13:50:10 +10:00
|
|
|
events_len *= 2;
|
2013-11-16 19:32:46 +01:00
|
|
|
events = realloc(events, events_len * sizeof *events);
|
|
|
|
|
if (!events) {
|
2015-08-19 08:51:58 +10:00
|
|
|
log_error(libinput,
|
|
|
|
|
"Failed to reallocate event ring buffer. "
|
|
|
|
|
"Events may be discarded\n");
|
2013-11-16 19:32:46 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
if (libinput->events_count > 0 && libinput->events_in == 0) {
|
|
|
|
|
libinput->events_in = libinput->events_len;
|
|
|
|
|
} else if (libinput->events_count > 0 &&
|
|
|
|
|
libinput->events_out >= libinput->events_in) {
|
|
|
|
|
move_len = libinput->events_len - libinput->events_out;
|
2013-11-16 19:32:46 +01:00
|
|
|
new_out = events_len - move_len;
|
|
|
|
|
memmove(events + new_out,
|
2013-12-24 13:46:20 +10:00
|
|
|
events + libinput->events_out,
|
2013-11-16 19:32:46 +01:00
|
|
|
move_len * sizeof *events);
|
2013-11-17 11:19:50 +01:00
|
|
|
libinput->events_out = new_out;
|
2013-11-16 19:32:46 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
libinput->events = events;
|
|
|
|
|
libinput->events_len = events_len;
|
2013-11-16 19:32:46 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-22 23:45:44 +01:00
|
|
|
if (event->device)
|
2013-12-19 11:42:55 +10:00
|
|
|
libinput_device_ref(event->device);
|
2013-12-07 16:41:43 +01:00
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
libinput->events_count = events_count;
|
|
|
|
|
events[libinput->events_in] = event;
|
|
|
|
|
libinput->events_in = (libinput->events_in + 1) % libinput->events_len;
|
2013-11-10 17:55:40 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-16 19:32:46 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
2013-11-17 11:19:50 +01:00
|
|
|
libinput_get_event(struct libinput *libinput)
|
2013-11-10 17:55:40 +01:00
|
|
|
{
|
2013-11-16 19:32:46 +01:00
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
if (libinput->events_count == 0)
|
2013-11-16 19:32:46 +01:00
|
|
|
return NULL;
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
event = libinput->events[libinput->events_out];
|
|
|
|
|
libinput->events_out =
|
|
|
|
|
(libinput->events_out + 1) % libinput->events_len;
|
|
|
|
|
libinput->events_count--;
|
2013-11-16 19:32:46 +01:00
|
|
|
|
|
|
|
|
return event;
|
2013-11-10 17:55:40 +01:00
|
|
|
}
|
|
|
|
|
|
2013-12-13 17:58:50 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_event_type
|
|
|
|
|
libinput_next_event_type(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event *event;
|
|
|
|
|
|
|
|
|
|
if (libinput->events_count == 0)
|
|
|
|
|
return LIBINPUT_EVENT_NONE;
|
|
|
|
|
|
|
|
|
|
event = libinput->events[libinput->events_out];
|
|
|
|
|
return event->type;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-23 13:37:28 +10:00
|
|
|
LIBINPUT_EXPORT void
|
|
|
|
|
libinput_set_user_data(struct libinput *libinput,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
libinput->user_data = 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
|
|
|
LIBINPUT_EXPORT void *
|
|
|
|
|
libinput_get_user_data(struct libinput *libinput)
|
|
|
|
|
{
|
|
|
|
|
return libinput->user_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_resume(struct libinput *libinput)
|
|
|
|
|
{
|
2013-12-13 11:37:31 +10:00
|
|
|
return libinput->interface_backend->resume(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
|
|
|
}
|
|
|
|
|
|
2013-11-17 16:59:09 +01:00
|
|
|
LIBINPUT_EXPORT 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
|
|
|
libinput_suspend(struct libinput *libinput)
|
2013-11-17 16:59:09 +01:00
|
|
|
{
|
2013-12-13 11:37:31 +10:00
|
|
|
libinput->interface_backend->suspend(libinput);
|
2013-11-17 16:59:09 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
LIBINPUT_EXPORT 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
|
|
|
libinput_device_set_user_data(struct libinput_device *device, void *user_data)
|
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
|
|
|
device->user_data = user_data;
|
2013-11-10 17:55:40 +01:00
|
|
|
}
|
|
|
|
|
|
2013-11-17 11:19:50 +01:00
|
|
|
LIBINPUT_EXPORT void *
|
|
|
|
|
libinput_device_get_user_data(struct libinput_device *device)
|
|
|
|
|
{
|
2013-11-17 19:31:34 +01:00
|
|
|
return device->user_data;
|
2013-11-17 11:19:50 +01:00
|
|
|
}
|
|
|
|
|
|
2014-12-01 16:00:13 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput *
|
|
|
|
|
libinput_device_get_context(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return libinput_seat_get_context(device->seat);
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_device_group *
|
|
|
|
|
libinput_device_get_device_group(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return device->group;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 17:50:04 +01:00
|
|
|
LIBINPUT_EXPORT const char *
|
|
|
|
|
libinput_device_get_sysname(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return evdev_device_get_sysname((struct evdev_device *) device);
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-27 12:55:29 +10:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
LIBINPUT_EXPORT const char *
|
|
|
|
|
libinput_device_get_output_name(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return evdev_device_get_output((struct evdev_device *) device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_seat *
|
|
|
|
|
libinput_device_get_seat(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return device->seat;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 13:43:59 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_set_seat_logical_name(struct libinput_device *device,
|
|
|
|
|
const char *name)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *libinput = device->seat->libinput;
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
return libinput->interface_backend->device_change_seat(device,
|
|
|
|
|
name);
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-31 10:53:53 +10:00
|
|
|
LIBINPUT_EXPORT struct udev_device *
|
|
|
|
|
libinput_device_get_udev_device(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return evdev_device_get_udev_device((struct evdev_device *)device);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-10 17:55:40 +01:00
|
|
|
LIBINPUT_EXPORT void
|
|
|
|
|
libinput_device_led_update(struct libinput_device *device,
|
|
|
|
|
enum libinput_led leds)
|
|
|
|
|
{
|
|
|
|
|
evdev_device_led_update((struct evdev_device *) device, leds);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-15 17:45:02 +01:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_has_capability(struct libinput_device *device,
|
|
|
|
|
enum libinput_device_capability capability)
|
|
|
|
|
{
|
|
|
|
|
return evdev_device_has_capability((struct evdev_device *) device,
|
|
|
|
|
capability);
|
|
|
|
|
}
|
2014-03-25 13:55:47 +10:00
|
|
|
|
2014-06-17 15:45:07 +10:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-06 12:27:35 +01:00
|
|
|
LIBINPUT_EXPORT int
|
2015-02-13 14:36:56 +10:00
|
|
|
libinput_device_pointer_has_button(struct libinput_device *device, uint32_t code)
|
2014-11-06 12:27:35 +01:00
|
|
|
{
|
|
|
|
|
return evdev_device_has_button((struct evdev_device *)device, code);
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-22 14:36:25 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code)
|
|
|
|
|
{
|
|
|
|
|
return evdev_device_has_key((struct evdev_device *)device, code);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_tablet_pad_get_num_buttons(struct libinput_device *device)
|
|
|
|
|
{
|
2016-02-05 15:16:38 +10:00
|
|
|
return evdev_device_tablet_pad_get_num_buttons((struct evdev_device *)device);
|
2016-01-21 12:35:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_tablet_pad_get_num_rings(struct libinput_device *device)
|
|
|
|
|
{
|
2016-02-05 15:16:38 +10:00
|
|
|
return evdev_device_tablet_pad_get_num_rings((struct evdev_device *)device);
|
2016-01-21 12:35:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_tablet_pad_get_num_strips(struct libinput_device *device)
|
|
|
|
|
{
|
2016-02-05 15:16:38 +10:00
|
|
|
return evdev_device_tablet_pad_get_num_strips((struct evdev_device *)device);
|
2016-01-21 12:35:11 +10:00
|
|
|
}
|
|
|
|
|
|
2016-05-26 10:05:10 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_tablet_pad_get_num_mode_groups(struct libinput_device *device)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
return evdev_device_tablet_pad_get_num_mode_groups((struct evdev_device *)device);
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_pad_mode_group*
|
|
|
|
|
libinput_device_tablet_pad_get_mode_group(struct libinput_device *device,
|
|
|
|
|
unsigned int index)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
return evdev_device_tablet_pad_get_mode_group((struct evdev_device *)device,
|
|
|
|
|
index);
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_tablet_pad_mode_group_get_num_modes(
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
return group->num_modes;
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_tablet_pad_mode_group_get_mode(struct libinput_tablet_pad_mode_group *group)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
return group->current_mode;
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_tablet_pad_mode_group_get_index(struct libinput_tablet_pad_mode_group *group)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
return group->index;
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_pad_mode_group_has_button(struct libinput_tablet_pad_mode_group *group,
|
|
|
|
|
unsigned int button)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
if ((int)button >=
|
|
|
|
|
libinput_device_tablet_pad_get_num_buttons(group->device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return !!(group->button_mask & (1 << button));
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_pad_mode_group_has_ring(struct libinput_tablet_pad_mode_group *group,
|
|
|
|
|
unsigned int ring)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
if ((int)ring >=
|
|
|
|
|
libinput_device_tablet_pad_get_num_rings(group->device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return !!(group->ring_mask & (1 << ring));
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_pad_mode_group_has_strip(struct libinput_tablet_pad_mode_group *group,
|
|
|
|
|
unsigned int strip)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
if ((int)strip >=
|
|
|
|
|
libinput_device_tablet_pad_get_num_strips(group->device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return !!(group->strip_mask & (1 << strip));
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_tablet_pad_mode_group_button_is_toggle(struct libinput_tablet_pad_mode_group *group,
|
|
|
|
|
unsigned int button)
|
|
|
|
|
{
|
2016-06-02 15:35:43 +10:00
|
|
|
if ((int)button >=
|
|
|
|
|
libinput_device_tablet_pad_get_num_buttons(group->device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return !!(group->toggle_button_mask & (1 << button));
|
2016-05-26 10:05:10 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_pad_mode_group *
|
|
|
|
|
libinput_tablet_pad_mode_group_ref(
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
|
|
|
|
{
|
|
|
|
|
group->refcount++;
|
|
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_pad_mode_group *
|
|
|
|
|
libinput_tablet_pad_mode_group_unref(
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
|
|
|
|
{
|
|
|
|
|
assert(group->refcount > 0);
|
|
|
|
|
|
|
|
|
|
group->refcount--;
|
|
|
|
|
if (group->refcount > 0)
|
|
|
|
|
return group;
|
|
|
|
|
|
|
|
|
|
list_remove(&group->link);
|
2016-06-02 15:35:43 +10:00
|
|
|
group->destroy(group);
|
2016-05-26 10:05:10 +10:00
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void
|
|
|
|
|
libinput_tablet_pad_mode_group_set_user_data(
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
group->user_data = user_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void *
|
|
|
|
|
libinput_tablet_pad_mode_group_get_user_data(
|
|
|
|
|
struct libinput_tablet_pad_mode_group *group)
|
|
|
|
|
{
|
|
|
|
|
return group->user_data;
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-25 13:55:47 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_DEVICE_ADDED,
|
|
|
|
|
LIBINPUT_EVENT_DEVICE_REMOVED);
|
|
|
|
|
|
2014-03-25 13:55:47 +10:00
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_KEYBOARD_KEY);
|
|
|
|
|
|
2014-03-25 13:55:47 +10:00
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_pointer_get_base_event(struct libinput_event_pointer *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_BUTTON,
|
|
|
|
|
LIBINPUT_EVENT_POINTER_AXIS);
|
|
|
|
|
|
2014-03-25 13:55:47 +10:00
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_touch_get_base_event(struct libinput_event_touch *event)
|
|
|
|
|
{
|
2015-03-13 10:07:53 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_DOWN,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_UP,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_MOTION,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_CANCEL,
|
|
|
|
|
LIBINPUT_EVENT_TOUCH_FRAME);
|
|
|
|
|
|
2014-03-25 13:55:47 +10:00
|
|
|
return &event->base;
|
|
|
|
|
}
|
2014-05-16 09:06:41 +10:00
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_gesture_get_base_event(struct libinput_event_gesture *event)
|
|
|
|
|
{
|
2016-01-04 10:49:23 +10:00
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_SWIPE_END,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_BEGIN,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE,
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_END);
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
2015-05-27 11:36:34 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_base_event(struct libinput_event_tablet_tool *event)
|
2015-05-27 11:36:34 +10:00
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_AXIS,
|
2015-12-14 07:36:14 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_TIP,
|
2015-11-16 16:27:46 +10:00
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_TOOL_BUTTON);
|
2015-05-27 11:36:34 +10:00
|
|
|
|
|
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_pad_get_ring_position(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING);
|
|
|
|
|
|
|
|
|
|
return event->ring.position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_event_tablet_pad_get_ring_number(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING);
|
|
|
|
|
|
|
|
|
|
return event->ring.number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_tablet_pad_ring_axis_source
|
|
|
|
|
libinput_event_tablet_pad_get_ring_source(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING);
|
|
|
|
|
|
|
|
|
|
return event->ring.source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_event_tablet_pad_get_strip_position(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0.0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP);
|
|
|
|
|
|
|
|
|
|
return event->strip.position;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_event_tablet_pad_get_strip_number(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP);
|
|
|
|
|
|
|
|
|
|
return event->strip.number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_tablet_pad_strip_axis_source
|
|
|
|
|
libinput_event_tablet_pad_get_strip_source(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP);
|
|
|
|
|
|
|
|
|
|
return event->strip.source;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_event_tablet_pad_get_button_number(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
2016-05-26 10:03:47 +10:00
|
|
|
return event->button.number;
|
2016-01-21 12:35:11 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_button_state
|
|
|
|
|
libinput_event_tablet_pad_get_button_state(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
LIBINPUT_BUTTON_STATE_RELEASED,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
2016-05-26 10:03:47 +10:00
|
|
|
return event->button.state;
|
2016-01-21 12:35:11 +10:00
|
|
|
}
|
|
|
|
|
|
2016-05-26 10:05:10 +10:00
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_event_tablet_pad_get_mode(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
|
|
|
|
return event->mode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_tablet_pad_mode_group *
|
|
|
|
|
libinput_event_tablet_pad_get_mode_group(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
|
|
|
|
return event->mode_group;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-21 12:35:11 +10:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_event_tablet_pad_get_time(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
|
|
|
|
return us2ms(event->time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint64_t
|
|
|
|
|
libinput_event_tablet_pad_get_time_usec(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
0,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
|
|
|
|
return event->time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_event *
|
|
|
|
|
libinput_event_tablet_pad_get_base_event(struct libinput_event_tablet_pad *event)
|
|
|
|
|
{
|
|
|
|
|
require_event_type(libinput_event_get_context(&event->base),
|
|
|
|
|
event->base.type,
|
|
|
|
|
NULL,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_RING,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_STRIP,
|
|
|
|
|
LIBINPUT_EVENT_TABLET_PAD_BUTTON);
|
|
|
|
|
|
|
|
|
|
return &event->base;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
LIBINPUT_EXPORT struct libinput_device_group *
|
|
|
|
|
libinput_device_group_ref(struct libinput_device_group *group)
|
|
|
|
|
{
|
|
|
|
|
group->refcount++;
|
|
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct libinput_device_group *
|
2015-09-04 12:56:41 +10:00
|
|
|
libinput_device_group_create(struct libinput *libinput,
|
|
|
|
|
const char *identifier)
|
2015-02-05 13:39:04 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_device_group *group;
|
|
|
|
|
|
|
|
|
|
group = zalloc(sizeof *group);
|
2015-02-09 18:45:45 -05:00
|
|
|
group->refcount = 1;
|
2017-07-07 09:47:06 +10:00
|
|
|
group->identifier = safe_strdup(identifier);
|
2015-02-09 18:45:45 -05:00
|
|
|
|
2015-09-04 12:56:41 +10:00
|
|
|
list_init(&group->link);
|
|
|
|
|
list_insert(&libinput->device_group_list, &group->link);
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-04 12:56:41 +10:00
|
|
|
struct libinput_device_group *
|
|
|
|
|
libinput_device_group_find_group(struct libinput *libinput,
|
|
|
|
|
const char *identifier)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device_group *g = NULL;
|
|
|
|
|
|
|
|
|
|
list_for_each(g, &libinput->device_group_list, link) {
|
|
|
|
|
if (identifier && g->identifier &&
|
|
|
|
|
streq(g->identifier, identifier)) {
|
|
|
|
|
return g;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-02 08:46:25 +10:00
|
|
|
return NULL;
|
2015-09-04 12:56:41 +10:00
|
|
|
}
|
|
|
|
|
|
2015-02-05 13:39:04 +10:00
|
|
|
void
|
|
|
|
|
libinput_device_set_device_group(struct libinput_device *device,
|
|
|
|
|
struct libinput_device_group *group)
|
|
|
|
|
{
|
|
|
|
|
device->group = group;
|
|
|
|
|
libinput_device_group_ref(group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
libinput_device_group_destroy(struct libinput_device_group *group)
|
|
|
|
|
{
|
2015-09-04 12:56:41 +10:00
|
|
|
list_remove(&group->link);
|
2015-02-09 18:45:45 -05:00
|
|
|
free(group->identifier);
|
2015-02-05 13:39:04 +10:00
|
|
|
free(group);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT struct libinput_device_group *
|
|
|
|
|
libinput_device_group_unref(struct libinput_device_group *group)
|
|
|
|
|
{
|
|
|
|
|
assert(group->refcount > 0);
|
|
|
|
|
group->refcount--;
|
|
|
|
|
if (group->refcount == 0) {
|
|
|
|
|
libinput_device_group_destroy(group);
|
|
|
|
|
return NULL;
|
|
|
|
|
} else {
|
|
|
|
|
return group;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void
|
|
|
|
|
libinput_device_group_set_user_data(struct libinput_device_group *group,
|
|
|
|
|
void *user_data)
|
|
|
|
|
{
|
|
|
|
|
group->user_data = user_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT void *
|
|
|
|
|
libinput_device_group_get_user_data(struct libinput_device_group *group)
|
|
|
|
|
{
|
|
|
|
|
return group->user_data;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-16 09:06:41 +10:00
|
|
|
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;
|
|
|
|
|
}
|
2014-01-07 11:42:32 +10:00
|
|
|
|
|
|
|
|
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,
|
2014-07-21 11:07:25 +10:00
|
|
|
enum libinput_config_tap_state enable)
|
2014-01-07 11:42:32 +10:00
|
|
|
{
|
2014-07-21 11:07:25 +10:00
|
|
|
if (enable != LIBINPUT_CONFIG_TAP_ENABLED &&
|
|
|
|
|
enable != LIBINPUT_CONFIG_TAP_DISABLED)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
2015-05-19 16:01:55 +10:00
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS;
|
2014-01-07 11:42:32 +10:00
|
|
|
|
|
|
|
|
return device->config.tap->set_enabled(device, enable);
|
2015-05-19 16:01:55 +10:00
|
|
|
|
2014-01-07 11:42:32 +10:00
|
|
|
}
|
|
|
|
|
|
2014-07-21 11:07:25 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_tap_state
|
2014-01-07 11:42:32 +10:00
|
|
|
libinput_device_config_tap_get_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
2014-07-21 11:07:25 +10:00
|
|
|
return LIBINPUT_CONFIG_TAP_DISABLED;
|
2014-01-07 11:42:32 +10:00
|
|
|
|
|
|
|
|
return device->config.tap->get_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-21 11:07:25 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_tap_state
|
2014-01-07 11:42:32 +10:00
|
|
|
libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
2014-07-21 11:07:25 +10:00
|
|
|
return LIBINPUT_CONFIG_TAP_DISABLED;
|
2014-01-07 11:42:32 +10:00
|
|
|
|
|
|
|
|
return device->config.tap->get_default(device);
|
|
|
|
|
}
|
2014-08-26 11:41:19 +10:00
|
|
|
|
2016-07-21 11:46:05 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_tap_set_button_map(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_tap_button_map map)
|
|
|
|
|
{
|
|
|
|
|
switch (map) {
|
|
|
|
|
case LIBINPUT_CONFIG_TAP_MAP_LRM:
|
|
|
|
|
case LIBINPUT_CONFIG_TAP_MAP_LMR:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->set_map(device, map);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_tap_button_map
|
|
|
|
|
libinput_device_config_tap_get_button_map(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->get_map(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_tap_button_map
|
|
|
|
|
libinput_device_config_tap_get_default_button_map(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_TAP_MAP_LRM;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->get_default_map(device);
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-22 17:59:19 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_tap_set_drag_enabled(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_drag_state enable)
|
|
|
|
|
{
|
|
|
|
|
if (enable != LIBINPUT_CONFIG_DRAG_ENABLED &&
|
|
|
|
|
enable != LIBINPUT_CONFIG_DRAG_DISABLED)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->set_drag_enabled(device, enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_drag_state
|
|
|
|
|
libinput_device_config_tap_get_drag_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_DRAG_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->get_drag_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_drag_state
|
|
|
|
|
libinput_device_config_tap_get_default_drag_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_DRAG_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->get_default_drag_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-16 17:02:02 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_tap_set_drag_lock_enabled(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_drag_lock_state enable)
|
|
|
|
|
{
|
|
|
|
|
if (enable != LIBINPUT_CONFIG_DRAG_LOCK_ENABLED &&
|
|
|
|
|
enable != LIBINPUT_CONFIG_DRAG_LOCK_DISABLED)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->set_draglock_enabled(device, enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_drag_lock_state
|
|
|
|
|
libinput_device_config_tap_get_drag_lock_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->get_draglock_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_drag_lock_state
|
|
|
|
|
libinput_device_config_tap_get_default_drag_lock_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (libinput_device_config_tap_get_finger_count(device) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_DRAG_LOCK_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.tap->get_default_draglock_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
2014-08-26 11:41:19 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_calibration_has_matrix(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return device->config.calibration ?
|
|
|
|
|
device->config.calibration->has_matrix(device) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_calibration_set_matrix(struct libinput_device *device,
|
|
|
|
|
const float matrix[6])
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_calibration_has_matrix(device))
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
return device->config.calibration->set_matrix(device, matrix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_calibration_get_matrix(struct libinput_device *device,
|
|
|
|
|
float matrix[6])
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_calibration_has_matrix(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.calibration->get_matrix(device, matrix);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_calibration_get_default_matrix(struct libinput_device *device,
|
|
|
|
|
float matrix[6])
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_calibration_has_matrix(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.calibration->get_default_matrix(device, matrix);
|
|
|
|
|
}
|
2014-01-30 16:18:55 +10:00
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_device_config_send_events_get_modes(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
uint32_t modes = LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
|
|
|
|
|
|
|
|
|
if (device->config.sendevents)
|
|
|
|
|
modes |= device->config.sendevents->get_modes(device);
|
|
|
|
|
|
|
|
|
|
return modes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_send_events_set_mode(struct libinput_device *device,
|
2014-10-30 15:36:52 +10:00
|
|
|
uint32_t mode)
|
2014-01-30 16:18:55 +10:00
|
|
|
{
|
2014-10-30 15:36:52 +10:00
|
|
|
if ((libinput_device_config_send_events_get_modes(device) & mode) != mode)
|
2014-01-30 16:18:55 +10:00
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
if (device->config.sendevents)
|
|
|
|
|
return device->config.sendevents->set_mode(device, mode);
|
|
|
|
|
else /* mode must be _ENABLED to get here */
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-30 15:36:52 +10:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-01-30 16:18:55 +10:00
|
|
|
libinput_device_config_send_events_get_mode(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (device->config.sendevents)
|
|
|
|
|
return device->config.sendevents->get_mode(device);
|
|
|
|
|
else
|
|
|
|
|
return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
|
|
|
|
}
|
|
|
|
|
|
2014-10-30 15:36:52 +10:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-01-30 16:18:55 +10:00
|
|
|
libinput_device_config_send_events_get_default_mode(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return LIBINPUT_CONFIG_SEND_EVENTS_ENABLED;
|
|
|
|
|
}
|
2014-05-15 15:46:19 +10:00
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_accel_is_available(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
return device->config.accel ?
|
|
|
|
|
device->config.accel->available(device) : 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_accel_set_speed(struct libinput_device *device,
|
|
|
|
|
double speed)
|
|
|
|
|
{
|
Fix an abort if the device speed is NaN
When using libinput with xf86-input-libinput, the device speed is
represented as a float passed via X properties.
If a buggy client gives a broken value, the conversions that occur
can cause the value of speed to be NaN (not a number), aka infinity.
In C, any comparison with NaN always gives false, whatever the value.
So that test in libinput_device_config_accel_set_speed():
(speed < 1.0 || speed > 1.0)
will necessarily return FALSE, defeating the test of range.
However, since since any comparison with NaN is false, the
opposite assert() in accelerator_set_speed():
(speed >= 1.0 && speed <= 1.0)
will be false as well, thus triggering the abort() and the crash of
the entire X server along with it.
The solution is to use the same construct in both routines, so that
it fails gracefully in libinput_device_config_accel_set_speed().
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2015-02-05 14:33:31 +01:00
|
|
|
/* Need the negation in case speed is NaN */
|
|
|
|
|
if (!(speed >= -1.0 && speed <= 1.0))
|
2014-05-15 15:46:19 +10:00
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
2014-12-04 16:50:32 +10:00
|
|
|
if (!libinput_device_config_accel_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
2014-05-15 15:46:19 +10:00
|
|
|
return device->config.accel->set_speed(device, speed);
|
|
|
|
|
}
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_device_config_accel_get_speed(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.accel->get_speed(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT double
|
|
|
|
|
libinput_device_config_accel_get_default_speed(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.accel->get_default_speed(device);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-27 13:13:47 +10:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_device_config_accel_get_profiles(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.accel->get_profiles(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_accel_profile
|
|
|
|
|
libinput_device_config_accel_get_profile(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
|
|
|
|
|
|
|
|
|
|
return device->config.accel->get_profile(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_accel_profile
|
|
|
|
|
libinput_device_config_accel_get_default_profile(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_ACCEL_PROFILE_NONE;
|
|
|
|
|
|
2016-04-08 15:51:27 +08:00
|
|
|
return device->config.accel->get_default_profile(device);
|
2015-08-27 13:13:47 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_accel_set_profile(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_accel_profile profile)
|
|
|
|
|
{
|
|
|
|
|
switch (profile) {
|
|
|
|
|
case LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT:
|
|
|
|
|
case LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_accel_is_available(device) ||
|
|
|
|
|
(libinput_device_config_accel_get_profiles(device) & profile) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
return device->config.accel->set_profile(device, profile);
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-18 15:10:19 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_scroll_has_natural_scroll(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!device->config.natural_scroll)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.natural_scroll->has(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_scroll_set_natural_scroll_enabled(struct libinput_device *device,
|
|
|
|
|
int enabled)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_scroll_has_natural_scroll(device))
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
return device->config.natural_scroll->set_enabled(device, enabled);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_scroll_get_natural_scroll_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!device->config.natural_scroll)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.natural_scroll->get_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_scroll_get_default_natural_scroll_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!device->config.natural_scroll)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.natural_scroll->get_default_enabled(device);
|
|
|
|
|
}
|
2014-09-22 16:48:41 +10:00
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
2015-01-06 21:20:22 -05:00
|
|
|
libinput_device_config_left_handed_is_available(struct libinput_device *device)
|
2014-09-22 16:48:41 +10:00
|
|
|
{
|
|
|
|
|
if (!device->config.left_handed)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.left_handed->has(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
2015-01-06 21:20:22 -05:00
|
|
|
libinput_device_config_left_handed_set(struct libinput_device *device,
|
|
|
|
|
int left_handed)
|
2014-09-22 16:48:41 +10:00
|
|
|
{
|
2015-01-06 21:20:22 -05:00
|
|
|
if (!libinput_device_config_left_handed_is_available(device))
|
2014-09-22 16:48:41 +10:00
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
|
|
|
|
return device->config.left_handed->set(device, left_handed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
2015-01-06 21:20:22 -05:00
|
|
|
libinput_device_config_left_handed_get(struct libinput_device *device)
|
2014-09-22 16:48:41 +10:00
|
|
|
{
|
2015-01-06 21:20:22 -05:00
|
|
|
if (!libinput_device_config_left_handed_is_available(device))
|
2014-09-22 16:48:41 +10:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.left_handed->get(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
2015-01-06 21:20:22 -05:00
|
|
|
libinput_device_config_left_handed_get_default(struct libinput_device *device)
|
2014-09-22 16:48:41 +10:00
|
|
|
{
|
2015-01-06 21:20:22 -05:00
|
|
|
if (!libinput_device_config_left_handed_is_available(device))
|
2014-09-22 16:48:41 +10:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.left_handed->get_default(device);
|
|
|
|
|
}
|
2014-11-03 14:52:59 +01:00
|
|
|
|
2014-12-03 14:45:26 +10:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_device_config_click_get_methods(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (device->config.click_method)
|
|
|
|
|
return device->config.click_method->get_methods(device);
|
|
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_click_set_method(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_click_method method)
|
|
|
|
|
{
|
|
|
|
|
/* Check method is a single valid method */
|
|
|
|
|
switch (method) {
|
|
|
|
|
case LIBINPUT_CONFIG_CLICK_METHOD_NONE:
|
|
|
|
|
case LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS:
|
|
|
|
|
case LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-15 10:21:47 +10:00
|
|
|
if ((libinput_device_config_click_get_methods(device) & method) != method)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
2014-12-03 14:45:26 +10:00
|
|
|
if (device->config.click_method)
|
|
|
|
|
return device->config.click_method->set_method(device, method);
|
|
|
|
|
else /* method must be _NONE to get here */
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_click_method
|
|
|
|
|
libinput_device_config_click_get_method(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (device->config.click_method)
|
|
|
|
|
return device->config.click_method->get_method(device);
|
|
|
|
|
else
|
|
|
|
|
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_click_method
|
|
|
|
|
libinput_device_config_click_get_default_method(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (device->config.click_method)
|
|
|
|
|
return device->config.click_method->get_default_method(device);
|
|
|
|
|
else
|
|
|
|
|
return LIBINPUT_CONFIG_CLICK_METHOD_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-14 12:08:33 +10:00
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_middle_emulation_is_available(
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (device->config.middle_emulation)
|
|
|
|
|
return device->config.middle_emulation->available(device);
|
|
|
|
|
else
|
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_middle_emulation_set_enabled(
|
|
|
|
|
struct libinput_device *device,
|
|
|
|
|
enum libinput_config_middle_emulation_state enable)
|
|
|
|
|
{
|
2015-05-19 16:22:14 +10:00
|
|
|
int available =
|
|
|
|
|
libinput_device_config_middle_emulation_is_available(device);
|
|
|
|
|
|
2015-04-14 12:08:33 +10:00
|
|
|
switch (enable) {
|
|
|
|
|
case LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED:
|
2015-05-19 16:22:14 +10:00
|
|
|
if (!available)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
break;
|
2015-04-14 12:08:33 +10:00
|
|
|
case LIBINPUT_CONFIG_MIDDLE_EMULATION_ENABLED:
|
2015-05-19 16:22:14 +10:00
|
|
|
if (!available)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
2015-04-14 12:08:33 +10:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return device->config.middle_emulation->set(device, enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_middle_emulation_state
|
|
|
|
|
libinput_device_config_middle_emulation_get_enabled(
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.middle_emulation->get(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_middle_emulation_state
|
|
|
|
|
libinput_device_config_middle_emulation_get_default_enabled(
|
|
|
|
|
struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_middle_emulation_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_MIDDLE_EMULATION_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.middle_emulation->get_default(device);
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-03 14:52:59 +01:00
|
|
|
LIBINPUT_EXPORT uint32_t
|
2014-11-19 12:16:28 +10:00
|
|
|
libinput_device_config_scroll_get_methods(struct libinput_device *device)
|
2014-11-03 14:52:59 +01:00
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
if (device->config.scroll_method)
|
|
|
|
|
return device->config.scroll_method->get_methods(device);
|
2014-11-03 14:52:59 +01:00
|
|
|
else
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
2014-11-19 12:16:28 +10:00
|
|
|
libinput_device_config_scroll_set_method(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_scroll_method method)
|
2014-11-03 14:52:59 +01:00
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
/* Check method is a single valid method */
|
|
|
|
|
switch (method) {
|
2014-11-03 14:52:59 +01:00
|
|
|
case LIBINPUT_CONFIG_SCROLL_NO_SCROLL:
|
|
|
|
|
case LIBINPUT_CONFIG_SCROLL_2FG:
|
|
|
|
|
case LIBINPUT_CONFIG_SCROLL_EDGE:
|
|
|
|
|
case LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-04 16:50:32 +10:00
|
|
|
if ((libinput_device_config_scroll_get_methods(device) & method) != method)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
if (device->config.scroll_method)
|
|
|
|
|
return device->config.scroll_method->set_method(device, method);
|
|
|
|
|
else /* method must be _NO_SCROLL to get here */
|
2014-11-03 14:52:59 +01:00
|
|
|
return LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_scroll_method
|
|
|
|
|
libinput_device_config_scroll_get_method(struct libinput_device *device)
|
2014-11-03 14:52:59 +01:00
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
if (device->config.scroll_method)
|
|
|
|
|
return device->config.scroll_method->get_method(device);
|
2014-11-03 14:52:59 +01:00
|
|
|
else
|
|
|
|
|
return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
LIBINPUT_EXPORT enum libinput_config_scroll_method
|
|
|
|
|
libinput_device_config_scroll_get_default_method(struct libinput_device *device)
|
2014-11-03 14:52:59 +01:00
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
if (device->config.scroll_method)
|
|
|
|
|
return device->config.scroll_method->get_default_method(device);
|
2014-11-03 14:52:59 +01:00
|
|
|
else
|
|
|
|
|
return LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_scroll_set_button(struct libinput_device *device,
|
|
|
|
|
uint32_t button)
|
|
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
if ((libinput_device_config_scroll_get_methods(device) &
|
2014-11-03 14:52:59 +01:00
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_UNSUPPORTED;
|
|
|
|
|
|
2017-02-06 11:23:18 +10:00
|
|
|
if (button && !libinput_device_pointer_has_button(device, button))
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
return device->config.scroll_method->set_button(device, button);
|
2014-11-03 14:52:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_device_config_scroll_get_button(struct libinput_device *device)
|
|
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
if ((libinput_device_config_scroll_get_methods(device) &
|
2014-11-03 14:52:59 +01:00
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
return device->config.scroll_method->get_button(device);
|
2014-11-03 14:52:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT uint32_t
|
|
|
|
|
libinput_device_config_scroll_get_default_button(struct libinput_device *device)
|
|
|
|
|
{
|
2014-11-19 12:16:28 +10:00
|
|
|
if ((libinput_device_config_scroll_get_methods(device) &
|
2014-11-03 14:52:59 +01:00
|
|
|
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN) == 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
return device->config.scroll_method->get_default_button(device);
|
2014-11-03 14:52:59 +01:00
|
|
|
}
|
2015-07-08 15:03:06 +10:00
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_dwt_is_available(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!device->config.dwt)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.dwt->is_available(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_dwt_set_enabled(struct libinput_device *device,
|
|
|
|
|
enum libinput_config_dwt_state enable)
|
|
|
|
|
{
|
|
|
|
|
if (enable != LIBINPUT_CONFIG_DWT_ENABLED &&
|
|
|
|
|
enable != LIBINPUT_CONFIG_DWT_DISABLED)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
|
|
|
|
if (!libinput_device_config_dwt_is_available(device))
|
|
|
|
|
return enable ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
|
|
|
|
|
return device->config.dwt->set_enabled(device, enable);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_dwt_state
|
|
|
|
|
libinput_device_config_dwt_get_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_dwt_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_DWT_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.dwt->get_enabled(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_dwt_state
|
|
|
|
|
libinput_device_config_dwt_get_default_enabled(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_dwt_is_available(device))
|
|
|
|
|
return LIBINPUT_CONFIG_DWT_DISABLED;
|
|
|
|
|
|
|
|
|
|
return device->config.dwt->get_default_enabled(device);
|
|
|
|
|
}
|
2016-05-03 13:52:53 +10:00
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT int
|
|
|
|
|
libinput_device_config_rotation_is_available(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!device->config.rotation)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.rotation->is_available(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT enum libinput_config_status
|
|
|
|
|
libinput_device_config_rotation_set_angle(struct libinput_device *device,
|
|
|
|
|
unsigned int degrees_cw)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_rotation_is_available(device))
|
|
|
|
|
return degrees_cw ? LIBINPUT_CONFIG_STATUS_UNSUPPORTED :
|
|
|
|
|
LIBINPUT_CONFIG_STATUS_SUCCESS;
|
|
|
|
|
|
|
|
|
|
if (degrees_cw >= 360 || degrees_cw % 90)
|
|
|
|
|
return LIBINPUT_CONFIG_STATUS_INVALID;
|
|
|
|
|
|
|
|
|
|
return device->config.rotation->set_angle(device, degrees_cw);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_device_config_rotation_get_angle(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_rotation_is_available(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.rotation->get_angle(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LIBINPUT_EXPORT unsigned int
|
|
|
|
|
libinput_device_config_rotation_get_default_angle(struct libinput_device *device)
|
|
|
|
|
{
|
|
|
|
|
if (!libinput_device_config_rotation_is_available(device))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
return device->config.rotation->get_default_angle(device);
|
|
|
|
|
}
|