2014-01-28 11:25:40 +10:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2014 Red Hat, Inc.
|
|
|
|
|
*
|
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:
|
2014-01-28 11:25:40 +10: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.
|
2014-01-28 11:25:40 +10:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define _GNU_SOURCE
|
|
|
|
|
#include <errno.h>
|
2015-11-05 13:16:58 +10:00
|
|
|
#include <inttypes.h>
|
2014-01-28 11:25:40 +10:00
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <poll.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h>
|
|
|
|
|
#include <unistd.h>
|
2014-05-30 14:41:23 +10:00
|
|
|
#include <libudev.h>
|
2014-06-03 07:51:37 +10:00
|
|
|
#include "linux/input.h"
|
2014-01-28 11:25:40 +10:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
|
|
#include <libinput.h>
|
2015-05-29 12:13:02 +10:00
|
|
|
#include <libevdev/libevdev.h>
|
2014-01-28 11:25:40 +10:00
|
|
|
|
2014-12-18 14:42:42 +10:00
|
|
|
#include "shared.h"
|
|
|
|
|
|
2014-01-28 11:25:40 +10:00
|
|
|
uint32_t start_time;
|
2014-01-25 11:53:53 +01:00
|
|
|
static const uint32_t screen_width = 100;
|
|
|
|
|
static const uint32_t screen_height = 100;
|
2015-06-24 15:07:53 +10:00
|
|
|
struct tools_context context;
|
2015-01-07 14:32:16 +10:00
|
|
|
static unsigned int stop = 0;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_event_header(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *dev = libinput_event_get_device(ev);
|
2014-07-15 21:53:26 +02:00
|
|
|
const char *type = NULL;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
switch(libinput_event_get_type(ev)) {
|
|
|
|
|
case LIBINPUT_EVENT_NONE:
|
|
|
|
|
abort();
|
|
|
|
|
case LIBINPUT_EVENT_DEVICE_ADDED:
|
|
|
|
|
type = "DEVICE_ADDED";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_DEVICE_REMOVED:
|
|
|
|
|
type = "DEVICE_REMOVED";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_KEYBOARD_KEY:
|
|
|
|
|
type = "KEYBOARD_KEY";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION:
|
|
|
|
|
type = "POINTER_MOTION";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
|
|
|
|
|
type = "POINTER_MOTION_ABSOLUTE";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_BUTTON:
|
|
|
|
|
type = "POINTER_BUTTON";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_AXIS:
|
|
|
|
|
type = "POINTER_AXIS";
|
|
|
|
|
break;
|
2014-02-19 21:39:26 +01:00
|
|
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
|
|
|
|
type = "TOUCH_DOWN";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_MOTION:
|
|
|
|
|
type = "TOUCH_MOTION";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_UP:
|
|
|
|
|
type = "TOUCH_UP";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_CANCEL:
|
|
|
|
|
type = "TOUCH_CANCEL";
|
2014-01-28 11:25:40 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_FRAME:
|
|
|
|
|
type = "TOUCH_FRAME";
|
|
|
|
|
break;
|
2015-01-22 16:41:50 +01:00
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
|
|
|
|
|
type = "GESTURE_SWIPE_BEGIN";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
|
|
|
|
|
type = "GESTURE_SWIPE_UPDATE";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
|
|
|
|
type = "GESTURE_SWIPE_END";
|
|
|
|
|
break;
|
2015-03-04 15:24:04 +01:00
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
|
|
|
|
type = "GESTURE_PINCH_BEGIN";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
|
|
|
|
type = "GESTURE_PINCH_UPDATE";
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_END:
|
|
|
|
|
type = "GESTURE_PINCH_END";
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
2014-06-05 23:35:24 -04:00
|
|
|
type = "TABLET_AXIS";
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
2015-02-16 22:48:42 -05:00
|
|
|
type = "TABLET_PROXIMITY";
|
2014-06-10 23:03:46 -04:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
2015-11-11 13:39:43 +10:00
|
|
|
type = "TABLET_TIP";
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
|
2014-06-06 18:32:12 -04:00
|
|
|
type = "TABLET_BUTTON";
|
|
|
|
|
break;
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
2015-02-16 22:48:43 -05:00
|
|
|
printf("%-7s %-16s ", libinput_device_get_sysname(dev), type);
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_event_time(uint32_t time)
|
|
|
|
|
{
|
|
|
|
|
printf("%+6.2fs ", (time - start_time) / 1000.0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_device_notify(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_device *dev = libinput_event_get_device(ev);
|
|
|
|
|
struct libinput_seat *seat = libinput_device_get_seat(dev);
|
2015-02-10 14:59:05 +10:00
|
|
|
struct libinput_device_group *group;
|
2014-06-17 15:45:07 +10:00
|
|
|
double w, h;
|
2015-03-18 10:01:03 +10:00
|
|
|
uint32_t scroll_methods, click_methods;
|
2015-02-10 14:59:05 +10:00
|
|
|
static int next_group_id = 0;
|
|
|
|
|
intptr_t group_id;
|
|
|
|
|
|
|
|
|
|
group = libinput_device_get_device_group(dev);
|
|
|
|
|
group_id = (intptr_t)libinput_device_group_get_user_data(group);
|
|
|
|
|
if (!group_id) {
|
|
|
|
|
group_id = ++next_group_id;
|
|
|
|
|
libinput_device_group_set_user_data(group, (void*)group_id);
|
|
|
|
|
}
|
2014-01-28 11:25:40 +10:00
|
|
|
|
2015-02-10 14:59:05 +10:00
|
|
|
printf("%-33s %5s %7s group%d",
|
2014-11-18 11:33:51 +10:00
|
|
|
libinput_device_get_name(dev),
|
2014-01-28 11:25:40 +10:00
|
|
|
libinput_seat_get_physical_name(seat),
|
2015-02-10 14:59:05 +10:00
|
|
|
libinput_seat_get_logical_name(seat),
|
|
|
|
|
(int)group_id);
|
2014-06-17 15:45:07 +10:00
|
|
|
|
2015-01-05 08:36:00 +10:00
|
|
|
printf(" cap:");
|
|
|
|
|
if (libinput_device_has_capability(dev,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_KEYBOARD))
|
|
|
|
|
printf("k");
|
|
|
|
|
if (libinput_device_has_capability(dev,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_POINTER))
|
|
|
|
|
printf("p");
|
|
|
|
|
if (libinput_device_has_capability(dev,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_TOUCH))
|
|
|
|
|
printf("t");
|
2015-01-22 16:41:50 +01:00
|
|
|
if (libinput_device_has_capability(dev,
|
|
|
|
|
LIBINPUT_DEVICE_CAP_GESTURE))
|
|
|
|
|
printf("g");
|
2015-02-10 15:25:57 +10:00
|
|
|
if (libinput_device_has_capability(dev,
|
2015-11-16 16:26:56 +10:00
|
|
|
LIBINPUT_DEVICE_CAP_TABLET_TOOL))
|
2015-02-10 15:25:57 +10:00
|
|
|
printf("T");
|
2015-01-05 08:36:00 +10:00
|
|
|
|
2014-06-17 15:45:07 +10:00
|
|
|
if (libinput_device_get_size(dev, &w, &h) == 0)
|
|
|
|
|
printf("\tsize %.2f/%.2fmm", w, h);
|
|
|
|
|
|
2015-06-22 11:07:31 +10:00
|
|
|
if (libinput_device_config_tap_get_finger_count(dev)) {
|
2014-11-18 11:16:24 +10:00
|
|
|
printf(" tap");
|
2015-06-22 11:07:31 +10:00
|
|
|
if (libinput_device_config_tap_get_drag_lock_enabled(dev))
|
|
|
|
|
printf("(dl on)");
|
|
|
|
|
else
|
|
|
|
|
printf("(dl off)");
|
|
|
|
|
}
|
2015-06-22 10:16:28 +10:00
|
|
|
if (libinput_device_config_left_handed_is_available(dev))
|
2014-11-18 11:16:24 +10:00
|
|
|
printf(" left");
|
2015-06-22 10:16:28 +10:00
|
|
|
if (libinput_device_config_scroll_has_natural_scroll(dev))
|
2014-11-18 11:16:24 +10:00
|
|
|
printf(" scroll-nat");
|
2015-06-22 10:16:28 +10:00
|
|
|
if (libinput_device_config_calibration_has_matrix(dev))
|
2014-11-18 11:16:24 +10:00
|
|
|
printf(" calib");
|
|
|
|
|
|
2014-11-19 12:16:28 +10:00
|
|
|
scroll_methods = libinput_device_config_scroll_get_methods(dev);
|
|
|
|
|
if (scroll_methods != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) {
|
2014-11-18 11:16:24 +10:00
|
|
|
printf(" scroll");
|
2014-11-19 12:16:28 +10:00
|
|
|
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_2FG)
|
2014-11-18 11:16:24 +10:00
|
|
|
printf("-2fg");
|
2014-11-19 12:16:28 +10:00
|
|
|
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_EDGE)
|
2014-11-18 11:16:24 +10:00
|
|
|
printf("-edge");
|
2014-11-19 12:16:28 +10:00
|
|
|
if (scroll_methods & LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN)
|
2014-11-18 11:16:24 +10:00
|
|
|
printf("-button");
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-18 10:01:03 +10:00
|
|
|
click_methods = libinput_device_config_click_get_methods(dev);
|
|
|
|
|
if (click_methods != LIBINPUT_CONFIG_CLICK_METHOD_NONE) {
|
|
|
|
|
printf(" click");
|
|
|
|
|
if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS)
|
|
|
|
|
printf("-buttonareas");
|
|
|
|
|
if (click_methods & LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER)
|
|
|
|
|
printf("-clickfinger");
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-08 15:03:06 +10:00
|
|
|
if (libinput_device_config_dwt_is_available(dev)) {
|
|
|
|
|
if (libinput_device_config_dwt_get_enabled(dev) ==
|
|
|
|
|
LIBINPUT_CONFIG_DWT_ENABLED)
|
|
|
|
|
printf(" dwt-on");
|
|
|
|
|
else
|
|
|
|
|
printf(" dwt-off)");
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-17 15:45:07 +10:00
|
|
|
printf("\n");
|
2014-11-18 11:16:24 +10:00
|
|
|
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_key_event(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(ev);
|
2014-06-17 07:55:35 +10:00
|
|
|
enum libinput_key_state state;
|
2015-05-29 12:13:02 +10:00
|
|
|
uint32_t key;
|
|
|
|
|
const char *keyname;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
print_event_time(libinput_event_keyboard_get_time(k));
|
|
|
|
|
state = libinput_event_keyboard_get_key_state(k);
|
2015-05-29 12:13:02 +10:00
|
|
|
|
|
|
|
|
key = libinput_event_keyboard_get_key(k);
|
|
|
|
|
keyname = libevdev_event_code_get_name(EV_KEY, key);
|
|
|
|
|
printf("%s (%d) %s\n",
|
|
|
|
|
keyname ? keyname : "???",
|
|
|
|
|
key,
|
2014-06-17 07:55:35 +10:00
|
|
|
state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_motion_event(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
|
2014-06-02 23:09:27 +02:00
|
|
|
double x = libinput_event_pointer_get_dx(p);
|
|
|
|
|
double y = libinput_event_pointer_get_dy(p);
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
print_event_time(libinput_event_pointer_get_time(p));
|
|
|
|
|
|
2014-06-02 23:09:27 +02:00
|
|
|
printf("%6.2f/%6.2f\n", x, y);
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_absmotion_event(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
|
2014-06-02 23:09:27 +02:00
|
|
|
double x = libinput_event_pointer_get_absolute_x_transformed(
|
2014-01-25 11:53:53 +01:00
|
|
|
p, screen_width);
|
2014-06-02 23:09:27 +02:00
|
|
|
double y = libinput_event_pointer_get_absolute_y_transformed(
|
2014-01-25 11:53:53 +01:00
|
|
|
p, screen_height);
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
print_event_time(libinput_event_pointer_get_time(p));
|
2014-06-02 23:09:27 +02:00
|
|
|
printf("%6.2f/%6.2f\n", x, y);
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2014-06-06 18:32:12 -04:00
|
|
|
print_pointer_button_event(struct libinput_event *ev)
|
2014-01-28 11:25:40 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
|
2014-06-03 20:08:02 -04:00
|
|
|
enum libinput_button_state state;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
print_event_time(libinput_event_pointer_get_time(p));
|
|
|
|
|
|
|
|
|
|
state = libinput_event_pointer_get_button_state(p);
|
2014-04-01 21:57:45 +02:00
|
|
|
printf("%3d %s, seat count: %u\n",
|
2014-01-28 11:25:40 +10:00
|
|
|
libinput_event_pointer_get_button(p),
|
2014-06-03 20:08:02 -04:00
|
|
|
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
|
2014-04-01 21:57:45 +02:00
|
|
|
libinput_event_pointer_get_seat_button_count(p));
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
2015-11-11 13:39:43 +10:00
|
|
|
static void
|
|
|
|
|
print_tablet_tip_event(struct libinput_event *ev)
|
|
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *p = libinput_event_get_tablet_tool_event(ev);
|
2015-11-16 15:43:41 +10:00
|
|
|
enum libinput_tablet_tool_tip_state state;
|
2015-11-11 13:39:43 +10:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
print_event_time(libinput_event_tablet_tool_get_time(p));
|
2015-11-11 13:39:43 +10:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
state = libinput_event_tablet_tool_get_tip_state(p);
|
2015-11-16 15:47:15 +10:00
|
|
|
printf("%s\n", state == LIBINPUT_TABLET_TOOL_TIP_DOWN ? "down" : "up");
|
2015-11-11 13:39:43 +10:00
|
|
|
}
|
|
|
|
|
|
2014-06-06 18:32:12 -04:00
|
|
|
static void
|
|
|
|
|
print_tablet_button_event(struct libinput_event *ev)
|
|
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *p = libinput_event_get_tablet_tool_event(ev);
|
2014-06-06 18:32:12 -04:00
|
|
|
enum libinput_button_state state;
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
print_event_time(libinput_event_tablet_tool_get_time(p));
|
2014-06-06 18:32:12 -04:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
state = libinput_event_tablet_tool_get_button_state(p);
|
2014-06-06 18:32:12 -04:00
|
|
|
printf("%3d %s, seat count: %u\n",
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_button(p),
|
2014-06-06 18:32:12 -04:00
|
|
|
state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
|
2015-11-16 16:28:55 +10:00
|
|
|
libinput_event_tablet_tool_get_seat_button_count(p));
|
2014-06-06 18:32:12 -04:00
|
|
|
}
|
|
|
|
|
|
2014-01-28 11:25:40 +10:00
|
|
|
static void
|
2014-06-05 23:35:24 -04:00
|
|
|
print_pointer_axis_event(struct libinput_event *ev)
|
2014-01-28 11:25:40 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
|
2014-12-24 11:10:04 +10:00
|
|
|
double v = 0, h = 0;
|
2015-12-04 15:58:16 +10:00
|
|
|
const char *have_vert = "",
|
|
|
|
|
*have_horiz = "";
|
2014-12-24 11:10:04 +10:00
|
|
|
|
|
|
|
|
if (libinput_event_pointer_has_axis(p,
|
2015-12-04 15:58:16 +10:00
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL)) {
|
2014-12-24 11:10:04 +10:00
|
|
|
v = libinput_event_pointer_get_axis_value(p,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL);
|
2015-12-04 15:58:16 +10:00
|
|
|
have_vert = "*";
|
|
|
|
|
}
|
2014-12-24 11:10:04 +10:00
|
|
|
if (libinput_event_pointer_has_axis(p,
|
2015-12-04 15:58:16 +10:00
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL)) {
|
2014-12-24 11:10:04 +10:00
|
|
|
h = libinput_event_pointer_get_axis_value(p,
|
|
|
|
|
LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL);
|
2015-12-04 15:58:16 +10:00
|
|
|
have_horiz = "*";
|
|
|
|
|
}
|
2014-01-28 11:25:40 +10:00
|
|
|
print_event_time(libinput_event_pointer_get_time(p));
|
2015-12-04 15:58:16 +10:00
|
|
|
printf("vert %.2f%s horiz %.2f%s\n", v, have_vert, h, have_horiz);
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
2014-06-05 23:35:24 -04:00
|
|
|
static void
|
2015-11-16 16:28:55 +10:00
|
|
|
print_tablet_axes(struct libinput_event_tablet_tool *t)
|
2014-06-05 23:35:24 -04:00
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
|
2015-02-20 12:03:52 +10:00
|
|
|
double x, y, dx, dy;
|
2014-06-17 13:58:35 +10:00
|
|
|
double dist, pressure;
|
2015-02-20 11:41:06 +10:00
|
|
|
double rotation, slider, wheel;
|
2015-02-20 12:03:52 +10:00
|
|
|
double delta;
|
2014-06-05 23:35:24 -04:00
|
|
|
|
2015-12-14 09:05:37 +10:00
|
|
|
#define changed_sym(ev, ax) \
|
|
|
|
|
(libinput_event_tablet_tool_##ax##_has_changed(ev) ? "*" : "")
|
|
|
|
|
|
2015-12-14 09:51:11 +10:00
|
|
|
x = libinput_event_tablet_tool_get_x(t);
|
|
|
|
|
y = libinput_event_tablet_tool_get_x(t);
|
2015-11-16 16:28:55 +10:00
|
|
|
dx = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_X);
|
|
|
|
|
dy = libinput_event_tablet_tool_get_axis_delta(t, LIBINPUT_TABLET_TOOL_AXIS_Y);
|
2015-02-20 12:03:52 +10:00
|
|
|
printf("\t%.2f%s/%.2f%s (%.2f/%.2f)",
|
2015-12-14 09:05:37 +10:00
|
|
|
x, changed_sym(t, x),
|
|
|
|
|
y, changed_sym(t, y),
|
2015-02-20 12:03:52 +10:00
|
|
|
dx, dy);
|
2014-06-17 13:58:35 +10:00
|
|
|
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_tilt(tool)) {
|
2015-12-14 09:51:11 +10:00
|
|
|
x = libinput_event_tablet_tool_get_tilt_x(t);
|
|
|
|
|
y = libinput_event_tablet_tool_get_tilt_y(t);
|
2015-11-16 16:28:55 +10:00
|
|
|
dx = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_X);
|
2015-11-16 16:28:55 +10:00
|
|
|
dy = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_TILT_Y);
|
2015-02-20 12:03:52 +10:00
|
|
|
printf("\ttilt: %.2f%s/%.2f%s (%.2f/%.2f)",
|
2015-12-14 09:05:37 +10:00
|
|
|
x, changed_sym(t, tilt_x),
|
|
|
|
|
y, changed_sym(t, tilt_y),
|
2015-02-20 12:03:52 +10:00
|
|
|
dx, dy);
|
2015-02-17 15:23:41 +10:00
|
|
|
}
|
2015-02-16 15:19:44 +10:00
|
|
|
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_distance(tool) ||
|
|
|
|
|
libinput_tablet_tool_has_pressure(tool)) {
|
2015-12-14 09:51:11 +10:00
|
|
|
dist = libinput_event_tablet_tool_get_distance(t);
|
|
|
|
|
pressure = libinput_event_tablet_tool_get_pressure(t);
|
2015-02-17 15:23:41 +10:00
|
|
|
if (dist) {
|
2015-11-16 16:28:55 +10:00
|
|
|
delta = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_DISTANCE);
|
2015-02-20 12:03:52 +10:00
|
|
|
printf("\tdistance: %.2f%s (%.2f)",
|
2015-12-14 09:05:37 +10:00
|
|
|
dist, changed_sym(t, distance),
|
2015-02-20 12:03:52 +10:00
|
|
|
delta);
|
2015-02-17 15:23:41 +10:00
|
|
|
} else {
|
2015-11-16 16:28:55 +10:00
|
|
|
delta = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_PRESSURE);
|
2015-02-20 12:03:52 +10:00
|
|
|
printf("\tpressure: %.2f%s (%.2f)",
|
2015-12-14 09:05:37 +10:00
|
|
|
pressure, changed_sym(t, pressure),
|
2015-02-20 12:03:52 +10:00
|
|
|
delta);
|
2015-02-17 15:23:41 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_rotation(tool)) {
|
2015-12-14 09:51:11 +10:00
|
|
|
rotation = libinput_event_tablet_tool_get_rotation(t);
|
2015-11-16 16:28:55 +10:00
|
|
|
delta = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_ROTATION_Z);
|
2015-02-20 12:03:52 +10:00
|
|
|
printf("\trotation: %.2f%s (%.2f)",
|
2015-12-14 09:05:37 +10:00
|
|
|
rotation, changed_sym(t, rotation),
|
2015-02-20 12:03:52 +10:00
|
|
|
delta);
|
2015-02-17 15:23:41 +10:00
|
|
|
}
|
2015-02-16 15:19:44 +10:00
|
|
|
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_slider(tool)) {
|
2015-12-14 09:51:11 +10:00
|
|
|
slider = libinput_event_tablet_tool_get_slider_position(t);
|
2015-11-16 16:28:55 +10:00
|
|
|
delta = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_SLIDER);
|
2015-02-20 12:03:52 +10:00
|
|
|
printf("\tslider: %.2f%s (%.2f)",
|
2015-12-14 09:05:37 +10:00
|
|
|
slider, changed_sym(t, slider),
|
2015-02-20 12:03:52 +10:00
|
|
|
delta);
|
2015-02-17 15:23:41 +10:00
|
|
|
}
|
2015-02-20 11:41:06 +10:00
|
|
|
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_wheel(tool)) {
|
2015-12-14 09:37:14 +10:00
|
|
|
wheel = libinput_event_tablet_tool_get_axis_delta(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
|
2015-11-16 16:28:55 +10:00
|
|
|
delta = libinput_event_tablet_tool_get_axis_delta_discrete(t,
|
2015-11-16 15:36:30 +10:00
|
|
|
LIBINPUT_TABLET_TOOL_AXIS_REL_WHEEL);
|
2015-02-20 14:34:31 +10:00
|
|
|
printf("\twheel: %.2f%s (%d)",
|
2015-12-14 09:05:37 +10:00
|
|
|
wheel, changed_sym(t, wheel),
|
2015-02-20 14:34:31 +10:00
|
|
|
(int)delta);
|
2015-02-20 11:41:06 +10:00
|
|
|
}
|
2015-02-17 15:23:41 +10:00
|
|
|
}
|
2015-02-17 13:04:06 +10:00
|
|
|
|
2015-02-17 15:23:41 +10:00
|
|
|
static void
|
|
|
|
|
print_tablet_axis_event(struct libinput_event *ev)
|
|
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
|
2015-02-17 15:23:41 +10:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
print_event_time(libinput_event_tablet_tool_get_time(t));
|
2015-02-17 15:23:41 +10:00
|
|
|
print_tablet_axes(t);
|
2014-06-17 13:58:35 +10:00
|
|
|
printf("\n");
|
2014-06-05 23:35:24 -04:00
|
|
|
}
|
|
|
|
|
|
2014-01-28 11:25:40 +10:00
|
|
|
static void
|
2014-02-19 21:39:26 +01:00
|
|
|
print_touch_event_without_coords(struct libinput_event *ev)
|
2014-01-28 11:25:40 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
|
|
|
|
|
|
|
|
|
|
print_event_time(libinput_event_touch_get_time(t));
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-08 19:27:45 -04:00
|
|
|
static void
|
2015-02-16 22:48:42 -05:00
|
|
|
print_proximity_event(struct libinput_event *ev)
|
2014-06-08 19:27:45 -04:00
|
|
|
{
|
2015-11-16 16:28:55 +10:00
|
|
|
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
|
|
|
|
|
struct libinput_tablet_tool *tool = libinput_event_tablet_tool_get_tool(t);
|
2015-11-16 15:41:48 +10:00
|
|
|
enum libinput_tablet_tool_proximity_state state;
|
2015-02-16 22:48:42 -05:00
|
|
|
const char *tool_str,
|
|
|
|
|
*state_str;
|
2014-06-08 19:27:45 -04:00
|
|
|
|
2015-11-16 16:35:03 +10:00
|
|
|
switch (libinput_tablet_tool_get_type(tool)) {
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_PEN:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "pen";
|
|
|
|
|
break;
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_ERASER:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "eraser";
|
|
|
|
|
break;
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_BRUSH:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "brush";
|
|
|
|
|
break;
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_PENCIL:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "pencil";
|
|
|
|
|
break;
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_AIRBRUSH:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "airbrush";
|
|
|
|
|
break;
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_MOUSE:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "mouse";
|
|
|
|
|
break;
|
2015-11-16 15:40:43 +10:00
|
|
|
case LIBINPUT_TABLET_TOOL_TYPE_LENS:
|
2014-06-08 19:27:45 -04:00
|
|
|
tool_str = "lens";
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
state = libinput_event_tablet_tool_get_proximity_state(t);
|
2014-06-08 19:27:45 -04:00
|
|
|
|
2015-11-16 16:28:55 +10:00
|
|
|
print_event_time(libinput_event_tablet_tool_get_time(t));
|
2015-02-16 22:48:44 -05:00
|
|
|
|
2015-11-16 15:42:31 +10:00
|
|
|
if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_IN) {
|
2015-02-17 15:23:41 +10:00
|
|
|
print_tablet_axes(t);
|
2015-02-16 22:48:42 -05:00
|
|
|
state_str = "proximity-in";
|
2015-11-16 15:42:31 +10:00
|
|
|
} else if (state == LIBINPUT_TABLET_TOOL_PROXIMITY_OUT) {
|
2015-02-16 22:48:42 -05:00
|
|
|
state_str = "proximity-out";
|
2015-02-16 22:48:44 -05:00
|
|
|
printf("\t");
|
|
|
|
|
} else {
|
2015-02-16 22:48:42 -05:00
|
|
|
abort();
|
2015-02-16 22:48:44 -05:00
|
|
|
}
|
2014-06-10 23:03:46 -04:00
|
|
|
|
2015-11-09 15:39:20 +10:00
|
|
|
printf("\t%s (%#" PRIx64 ", id %#" PRIx64 ") %s",
|
|
|
|
|
tool_str,
|
2015-11-16 16:35:03 +10:00
|
|
|
libinput_tablet_tool_get_serial(tool),
|
|
|
|
|
libinput_tablet_tool_get_tool_id(tool),
|
2015-11-09 15:39:20 +10:00
|
|
|
state_str);
|
2015-02-18 13:17:13 +10:00
|
|
|
|
|
|
|
|
printf("\taxes:");
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_distance(tool))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("d");
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_pressure(tool))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("p");
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_tilt(tool))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("t");
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_rotation(tool))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("r");
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_slider(tool))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("s");
|
2015-12-14 10:06:56 +10:00
|
|
|
if (libinput_tablet_tool_has_wheel(tool))
|
2015-04-01 14:01:01 -07:00
|
|
|
printf("w");
|
2015-02-18 13:17:13 +10:00
|
|
|
|
|
|
|
|
printf("\tbtn:");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_TOUCH))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("T");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_STYLUS))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("S");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_STYLUS2))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("S2");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_LEFT))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("L");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_MIDDLE))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("M");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_RIGHT))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("R");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_SIDE))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("Sd");
|
2015-11-16 16:35:03 +10:00
|
|
|
if (libinput_tablet_tool_has_button(tool, BTN_EXTRA))
|
2015-02-18 13:17:13 +10:00
|
|
|
printf("Ex");
|
|
|
|
|
|
2014-06-10 23:03:46 -04:00
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-28 11:25:40 +10:00
|
|
|
static void
|
2014-02-19 21:39:26 +01:00
|
|
|
print_touch_event_with_coords(struct libinput_event *ev)
|
2014-01-28 11:25:40 +10:00
|
|
|
{
|
|
|
|
|
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
|
2014-06-02 23:09:27 +02:00
|
|
|
double x = libinput_event_touch_get_x_transformed(t, screen_width);
|
|
|
|
|
double y = libinput_event_touch_get_y_transformed(t, screen_height);
|
2014-06-19 11:30:21 +10:00
|
|
|
double xmm = libinput_event_touch_get_x(t);
|
|
|
|
|
double ymm = libinput_event_touch_get_y(t);
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
print_event_time(libinput_event_touch_get_time(t));
|
|
|
|
|
|
2014-06-19 11:30:21 +10:00
|
|
|
printf("%d (%d) %5.2f/%5.2f (%5.2f/%5.2fmm)\n",
|
2014-01-28 11:25:40 +10:00
|
|
|
libinput_event_touch_get_slot(t),
|
2014-01-30 22:44:49 +01:00
|
|
|
libinput_event_touch_get_seat_slot(t),
|
2014-06-19 11:30:21 +10:00
|
|
|
x, y,
|
|
|
|
|
xmm, ymm);
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
2015-01-22 16:41:50 +01:00
|
|
|
static void
|
|
|
|
|
print_gesture_event_without_coords(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev);
|
2015-04-29 13:19:51 +02:00
|
|
|
int finger_count = libinput_event_gesture_get_finger_count(t);
|
2015-07-06 15:05:32 +10:00
|
|
|
int cancelled = 0;
|
|
|
|
|
enum libinput_event_type type;
|
|
|
|
|
|
|
|
|
|
type = libinput_event_get_type(ev);
|
|
|
|
|
|
|
|
|
|
if (type == LIBINPUT_EVENT_GESTURE_SWIPE_END ||
|
|
|
|
|
type == LIBINPUT_EVENT_GESTURE_PINCH_END)
|
|
|
|
|
cancelled = libinput_event_gesture_get_cancelled(t);
|
2015-01-22 16:41:50 +01:00
|
|
|
|
|
|
|
|
print_event_time(libinput_event_gesture_get_time(t));
|
2015-04-29 13:19:51 +02:00
|
|
|
printf("%d%s\n", finger_count, cancelled ? " cancelled" : "");
|
2015-01-22 16:41:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
print_gesture_event_with_coords(struct libinput_event *ev)
|
|
|
|
|
{
|
|
|
|
|
struct libinput_event_gesture *t = libinput_event_get_gesture_event(ev);
|
|
|
|
|
double dx = libinput_event_gesture_get_dx(t);
|
|
|
|
|
double dy = libinput_event_gesture_get_dy(t);
|
|
|
|
|
double dx_unaccel = libinput_event_gesture_get_dx_unaccelerated(t);
|
|
|
|
|
double dy_unaccel = libinput_event_gesture_get_dy_unaccelerated(t);
|
|
|
|
|
|
|
|
|
|
print_event_time(libinput_event_gesture_get_time(t));
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
printf("%d %5.2f/%5.2f (%5.2f/%5.2f unaccelerated)",
|
2015-01-22 16:41:50 +01:00
|
|
|
libinput_event_gesture_get_finger_count(t),
|
|
|
|
|
dx, dy, dx_unaccel, dy_unaccel);
|
2015-03-04 15:24:04 +01:00
|
|
|
|
2015-07-20 10:59:45 +10:00
|
|
|
if (libinput_event_get_type(ev) ==
|
|
|
|
|
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE) {
|
|
|
|
|
double scale = libinput_event_gesture_get_scale(t);
|
|
|
|
|
double angle = libinput_event_gesture_get_angle_delta(t);
|
|
|
|
|
|
2015-03-04 15:24:04 +01:00
|
|
|
printf(" %5.2f @ %5.2f\n", scale, angle);
|
2015-07-20 10:59:45 +10:00
|
|
|
} else {
|
2015-03-04 15:24:04 +01:00
|
|
|
printf("\n");
|
2015-07-20 10:59:45 +10:00
|
|
|
}
|
2015-01-22 16:41:50 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-28 11:25:40 +10:00
|
|
|
static int
|
|
|
|
|
handle_and_print_events(struct libinput *li)
|
|
|
|
|
{
|
|
|
|
|
int rc = -1;
|
|
|
|
|
struct libinput_event *ev;
|
|
|
|
|
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
while ((ev = libinput_get_event(li))) {
|
|
|
|
|
print_event_header(ev);
|
|
|
|
|
|
|
|
|
|
switch (libinput_event_get_type(ev)) {
|
|
|
|
|
case LIBINPUT_EVENT_NONE:
|
|
|
|
|
abort();
|
|
|
|
|
case LIBINPUT_EVENT_DEVICE_ADDED:
|
|
|
|
|
case LIBINPUT_EVENT_DEVICE_REMOVED:
|
|
|
|
|
print_device_notify(ev);
|
2014-12-18 15:10:09 +10:00
|
|
|
tools_device_apply_config(libinput_event_get_device(ev),
|
2015-06-24 15:07:53 +10:00
|
|
|
&context.options);
|
2014-01-28 11:25:40 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_KEYBOARD_KEY:
|
|
|
|
|
print_key_event(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION:
|
|
|
|
|
print_motion_event(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
|
|
|
|
|
print_absmotion_event(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_BUTTON:
|
2014-06-06 18:32:12 -04:00
|
|
|
print_pointer_button_event(ev);
|
2014-01-28 11:25:40 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_POINTER_AXIS:
|
2014-06-05 23:35:24 -04:00
|
|
|
print_pointer_axis_event(ev);
|
2014-01-28 11:25:40 +10:00
|
|
|
break;
|
2014-02-19 21:39:26 +01:00
|
|
|
case LIBINPUT_EVENT_TOUCH_DOWN:
|
|
|
|
|
print_touch_event_with_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_MOTION:
|
|
|
|
|
print_touch_event_with_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_UP:
|
|
|
|
|
print_touch_event_without_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_CANCEL:
|
|
|
|
|
print_touch_event_without_coords(ev);
|
2014-01-28 11:25:40 +10:00
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_TOUCH_FRAME:
|
2014-02-19 21:39:26 +01:00
|
|
|
print_touch_event_without_coords(ev);
|
2014-01-28 11:25:40 +10:00
|
|
|
break;
|
2015-01-22 16:41:50 +01:00
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN:
|
|
|
|
|
print_gesture_event_without_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE:
|
|
|
|
|
print_gesture_event_with_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_SWIPE_END:
|
|
|
|
|
print_gesture_event_without_coords(ev);
|
|
|
|
|
break;
|
2015-03-04 15:24:04 +01:00
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_BEGIN:
|
|
|
|
|
print_gesture_event_without_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_UPDATE:
|
|
|
|
|
print_gesture_event_with_coords(ev);
|
|
|
|
|
break;
|
|
|
|
|
case LIBINPUT_EVENT_GESTURE_PINCH_END:
|
|
|
|
|
print_gesture_event_without_coords(ev);
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_AXIS:
|
2014-06-05 23:35:24 -04:00
|
|
|
print_tablet_axis_event(ev);
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_PROXIMITY:
|
2015-02-16 22:48:42 -05:00
|
|
|
print_proximity_event(ev);
|
2014-06-10 23:03:46 -04:00
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_TIP:
|
2015-11-11 13:39:43 +10:00
|
|
|
print_tablet_tip_event(ev);
|
|
|
|
|
break;
|
2015-11-16 16:27:46 +10:00
|
|
|
case LIBINPUT_EVENT_TABLET_TOOL_BUTTON:
|
2014-06-06 18:32:12 -04:00
|
|
|
print_tablet_button_event(ev);
|
|
|
|
|
break;
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
libinput_event_destroy(ev);
|
|
|
|
|
libinput_dispatch(li);
|
|
|
|
|
rc = 0;
|
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-15 21:53:26 +02:00
|
|
|
static void
|
2015-01-07 14:32:16 +10:00
|
|
|
sighandler(int signal, siginfo_t *siginfo, void *userdata)
|
2014-01-28 11:25:40 +10:00
|
|
|
{
|
2015-01-07 14:32:16 +10:00
|
|
|
stop = 1;
|
|
|
|
|
}
|
2014-01-28 11:25:40 +10:00
|
|
|
|
2015-01-07 14:32:16 +10:00
|
|
|
static void
|
|
|
|
|
mainloop(struct libinput *li)
|
|
|
|
|
{
|
|
|
|
|
struct pollfd fds;
|
|
|
|
|
struct sigaction act;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
2015-01-07 14:32:16 +10:00
|
|
|
fds.fd = libinput_get_fd(li);
|
|
|
|
|
fds.events = POLLIN;
|
|
|
|
|
fds.revents = 0;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
2015-01-07 14:32:16 +10:00
|
|
|
memset(&act, 0, sizeof(act));
|
|
|
|
|
act.sa_sigaction = sighandler;
|
|
|
|
|
act.sa_flags = SA_SIGINFO;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
2015-01-07 14:32:16 +10:00
|
|
|
if (sigaction(SIGINT, &act, NULL) == -1) {
|
2014-01-28 11:25:40 +10:00
|
|
|
fprintf(stderr, "Failed to set up signal handling (%s)\n",
|
|
|
|
|
strerror(errno));
|
2015-01-07 14:09:00 +10:00
|
|
|
return;
|
2014-01-28 11:25:40 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Handle already-pending device added events */
|
|
|
|
|
if (handle_and_print_events(li))
|
|
|
|
|
fprintf(stderr, "Expected device added events on startup but got none. "
|
|
|
|
|
"Maybe you don't have the right permissions?\n");
|
|
|
|
|
|
2015-01-07 14:32:16 +10:00
|
|
|
while (!stop && poll(&fds, 1, -1) > -1)
|
2014-01-28 11:25:40 +10:00
|
|
|
handle_and_print_events(li);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
main(int argc, char **argv)
|
|
|
|
|
{
|
|
|
|
|
struct libinput *li;
|
|
|
|
|
struct timespec tp;
|
|
|
|
|
|
2015-11-09 15:42:06 +10:00
|
|
|
clock_gettime(CLOCK_MONOTONIC, &tp);
|
|
|
|
|
start_time = tp.tv_sec * 1000 + tp.tv_nsec / 1000000;
|
|
|
|
|
|
2015-06-24 15:07:53 +10:00
|
|
|
tools_init_context(&context);
|
2014-12-18 14:42:42 +10:00
|
|
|
|
2015-06-24 15:07:53 +10:00
|
|
|
if (tools_parse_args(argc, argv, &context))
|
2014-01-28 11:25:40 +10:00
|
|
|
return 1;
|
|
|
|
|
|
2015-06-24 15:07:53 +10:00
|
|
|
li = tools_open_backend(&context);
|
2014-12-18 15:02:45 +10:00
|
|
|
if (!li)
|
|
|
|
|
return 1;
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
mainloop(li);
|
|
|
|
|
|
2014-06-25 00:06:58 +02:00
|
|
|
libinput_unref(li);
|
2014-01-28 11:25:40 +10:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|