#include <string.h>
#include <time.h>
#include <unistd.h>
-#include <linux/input.h>
+#include <libudev.h>
+#include "linux/input.h"
#include <sys/ioctl.h>
#include <sys/signalfd.h>
uint32_t start_time;
static const uint32_t screen_width = 100;
static const uint32_t screen_height = 100;
+static int verbose = 0;
static void
usage(void)
{
- printf("Usage: %s [--udev [<seat>]|--device /dev/input/event0]\n"
+ printf("Usage: %s [--verbose] [--udev [<seat>]|--device /dev/input/event0]\n"
+ "--verbose ....... Print debugging output.\n"
"--udev <seat>.... Use udev device discovery (default).\n"
" Specifying a seat ID is optional.\n"
"--device /path/to/device .... open the given device only\n",
{ "device", 1, 0, 'd' },
{ "udev", 0, 0, 'u' },
{ "help", 0, 0, 'h' },
+ { "verbose", 0, 0, 'v'},
{ 0, 0, 0, 0}
};
if (optarg)
seat = optarg;
break;
+ case 'v': /* --verbose */
+ verbose = 1;
+ break;
default:
usage();
return 1;
close(fd);
}
-const static struct libinput_interface interface = {
+static const struct libinput_interface interface = {
.open_restricted = open_restricted,
.close_restricted = close_restricted,
};
{
struct libinput_device *dev = libinput_event_get_device(ev);
struct libinput_seat *seat = libinput_device_get_seat(dev);
+ double w, h;
- printf("%s %s\n",
+ printf("%s %s",
libinput_seat_get_physical_name(seat),
libinput_seat_get_logical_name(seat));
+
+ if (libinput_device_get_size(dev, &w, &h) == 0)
+ printf("\tsize %.2f/%.2fmm", w, h);
+
+ printf("\n");
}
static void
print_key_event(struct libinput_event *ev)
{
struct libinput_event_keyboard *k = libinput_event_get_keyboard_event(ev);
- enum libinput_keyboard_key_state state;
+ enum libinput_key_state state;
print_event_time(libinput_event_keyboard_get_time(k));
state = libinput_event_keyboard_get_key_state(k);
printf("%d %s\n",
libinput_event_keyboard_get_key(k),
- state == LIBINPUT_KEYBOARD_KEY_STATE_PRESSED ? "pressed" : "released");
+ state == LIBINPUT_KEY_STATE_PRESSED ? "pressed" : "released");
}
static void
print_motion_event(struct libinput_event *ev)
{
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
- li_fixed_t x = libinput_event_pointer_get_dx(p),
- y = libinput_event_pointer_get_dy(p);
+ double x = libinput_event_pointer_get_dx(p);
+ double y = libinput_event_pointer_get_dy(p);
print_event_time(libinput_event_pointer_get_time(p));
- printf("%6.2f/%6.2f\n",
- li_fixed_to_double(x),
- li_fixed_to_double(y));
+ printf("%6.2f/%6.2f\n", x, y);
}
static void
print_absmotion_event(struct libinput_event *ev)
{
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
- li_fixed_t x = libinput_event_pointer_get_absolute_x_transformed(
+ double x = libinput_event_pointer_get_absolute_x_transformed(
p, screen_width);
- li_fixed_t y = libinput_event_pointer_get_absolute_y_transformed(
+ double y = libinput_event_pointer_get_absolute_y_transformed(
p, screen_height);
print_event_time(libinput_event_pointer_get_time(p));
- printf("%6.2f/%6.2f\n",
- li_fixed_to_double(x),
- li_fixed_to_double(y));
+ printf("%6.2f/%6.2f\n", x, y);
}
static void
print_button_event(struct libinput_event *ev)
{
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
- enum libinput_pointer_button_state state;
+ enum libinput_button_state state;
print_event_time(libinput_event_pointer_get_time(p));
state = libinput_event_pointer_get_button_state(p);
- printf("%3d %s\n",
+ printf("%3d %s, seat count: %u\n",
libinput_event_pointer_get_button(p),
- state == LIBINPUT_POINTER_BUTTON_STATE_PRESSED ? "pressed" : "released");
+ state == LIBINPUT_BUTTON_STATE_PRESSED ? "pressed" : "released",
+ libinput_event_pointer_get_seat_button_count(p));
}
static void
struct libinput_event_pointer *p = libinput_event_get_pointer_event(ev);
enum libinput_pointer_axis axis = libinput_event_pointer_get_axis(p);
const char *ax;
- li_fixed_t val;
+ double val;
switch (axis) {
- case LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL:
+ case LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL:
ax = "vscroll";
break;
- case LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL:
+ case LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL:
ax = "hscroll";
break;
default:
print_event_time(libinput_event_pointer_get_time(p));
val = libinput_event_pointer_get_axis_value(p);
- printf("%s %.2f\n",
- ax, li_fixed_to_double(val));
+ printf("%s %.2f\n", ax, val);
}
static void
print_touch_event_with_coords(struct libinput_event *ev)
{
struct libinput_event_touch *t = libinput_event_get_touch_event(ev);
- li_fixed_t x = libinput_event_touch_get_x_transformed(t, screen_width),
- y = libinput_event_touch_get_y_transformed(t, screen_height);
+ double x = libinput_event_touch_get_x_transformed(t, screen_width);
+ double y = libinput_event_touch_get_y_transformed(t, screen_height);
+ double xmm = libinput_event_touch_get_x(t);
+ double ymm = libinput_event_touch_get_y(t);
print_event_time(libinput_event_touch_get_time(t));
- printf("%d (%d) %5.2f/%5.2f\n",
+ printf("%d (%d) %5.2f/%5.2f (%5.2f/%5.2fmm)\n",
libinput_event_touch_get_slot(t),
libinput_event_touch_get_seat_slot(t),
- li_fixed_to_double(x),
- li_fixed_to_double(y));
+ x, y,
+ xmm, ymm);
}
static int
close(fds[1].fd);
}
+static void
+log_handler(enum libinput_log_priority priority,
+ void *user_data,
+ const char *format,
+ va_list args)
+{
+ vprintf(format, args);
+}
+
int
main(int argc, char **argv)
{
if (parse_args(argc, argv))
return 1;
+ if (verbose) {
+ libinput_log_set_handler(log_handler, NULL);
+ libinput_log_set_priority(LIBINPUT_LOG_PRIORITY_DEBUG);
+ }
+
if (mode == MODE_UDEV) {
if (open_udev(&li))
return 1;
mainloop(li);
+ libinput_destroy(li);
if (udev)
udev_unref(udev);