mirror of
https://gitlab.freedesktop.org/libevdev/libevdev.git
synced 2025-12-20 09:10:05 +01:00
Due to what must've been a copy/paste error many years ago, the license text for libevdev wasn't actually the MIT license. Let's rectify this, it was always MIT intended anyway. To make this more obvious and reduce the chance of copy/paste mistakes, use the SPDX license identifier in the various source files. The two installed public header files have the full license text. All contributors with copyrightable contributions have ACKed the license change to MIT, either in the MR directly [1] or privately in reply to an email. [1] https://gitlab.freedesktop.org/libevdev/libevdev/-/merge_requests/69 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Acked-by: Alexander Dahl <ada@thorsis.com> Acked-by: Andreas Pokorny <andreas.pokorny@canonical.com> Acked-by: Armin K <krejzi@email.com> Acked-by: Benjamin Tissoires <btissoir@redhat.com> Acked-by: David Herrmann <dh.herrmann@gmail.com> Acked-by: Deepa Dinamani <deepa.kernel@gmail.com> Acked-by: Emmanuele Bassi <ebassi@gnome.org> Acked-by: Gaetan Nadon <memsize@videotron.ca> Acked-by: George Thomas <georgefsthomas@gmail.com> Acked-by: Michael Forney <mforney@mforney.org> Acked-by: Nayan Deshmukh <nayan26deshmukh@gmail.com> Acked-by: Niclas Zeising <zeising@daemonic.se> Acked-by: Owen W. Taylor <otaylor@fishsoup.net> Acked-by: Peter Seiderer <ps.report@gmx.net> Acked-by: Ran Benita <ran234@gmail.com> Acked-by: Rosen Penev <rosenp@gmail.com> Acked-by: Scott Jann <sjann@knight-rider.org> Acked-by: Thilo Schulz <thilo@tjps.eu> Acked-by: polyphemus <rolfmorel@gmail.com>
102 lines
2.4 KiB
C
102 lines
2.4 KiB
C
// SPDX-License-Identifier: MIT
|
|
/*
|
|
* Copyright © 2013 Red Hat, Inc.
|
|
*/
|
|
|
|
#include "config.h"
|
|
#include <check.h>
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
|
|
#include "test-common.h"
|
|
|
|
void test_logfunc_abort_on_error(enum libevdev_log_priority priority,
|
|
void *data,
|
|
const char *file, int line,
|
|
const char *func,
|
|
const char *format, va_list args)
|
|
{
|
|
vprintf(format, args);
|
|
ck_abort();
|
|
}
|
|
|
|
void test_logfunc_ignore_error(enum libevdev_log_priority priority,
|
|
void *data,
|
|
const char *file, int line,
|
|
const char *func,
|
|
const char *format, va_list args)
|
|
{
|
|
}
|
|
|
|
void test_create_device(struct uinput_device **uidev_return,
|
|
struct libevdev **dev_return,
|
|
...)
|
|
{
|
|
int rc, fd;
|
|
struct uinput_device *uidev;
|
|
struct libevdev *dev;
|
|
va_list args;
|
|
|
|
va_start(args, dev_return);
|
|
|
|
rc = uinput_device_new_with_events_v(&uidev, TEST_DEVICE_NAME, DEFAULT_IDS, args);
|
|
va_end(args);
|
|
|
|
ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
|
|
|
|
fd = uinput_device_get_fd(uidev);
|
|
|
|
rc = libevdev_new_from_fd(fd, &dev);
|
|
ck_assert_msg(rc == 0, "Failed to init device device: %s", strerror(-rc));
|
|
rc = fcntl(fd, F_SETFL, O_NONBLOCK);
|
|
ck_assert_msg(rc == 0, "fcntl failed: %s", strerror(errno));
|
|
|
|
*uidev_return = uidev;
|
|
*dev_return = dev;
|
|
}
|
|
|
|
void test_create_abs_device(struct uinput_device **uidev_return,
|
|
struct libevdev **dev_return,
|
|
int nabs,
|
|
const struct input_absinfo *abs,
|
|
...)
|
|
{
|
|
int rc, fd;
|
|
struct uinput_device *uidev;
|
|
struct libevdev *dev;
|
|
va_list args;
|
|
|
|
uidev = uinput_device_new(TEST_DEVICE_NAME);
|
|
ck_assert(uidev != NULL);
|
|
|
|
va_start(args, abs);
|
|
rc = uinput_device_set_event_bits_v(uidev, args);
|
|
ck_assert_msg(rc == 0, "Failed to set uinput bits");
|
|
va_end(args);
|
|
|
|
while (--nabs >= 0) {
|
|
int code;
|
|
struct input_absinfo a;
|
|
|
|
code = abs[nabs].value;
|
|
a = abs[nabs];
|
|
a.value = 0;
|
|
|
|
rc = uinput_device_set_abs_bit(uidev, code, &a);
|
|
ck_assert_msg(rc == 0, "for abs field %d\n", nabs);
|
|
}
|
|
|
|
rc = uinput_device_create(uidev);
|
|
ck_assert_msg(rc == 0, "Failed to create uinput device: %s", strerror(-rc));
|
|
|
|
fd = uinput_device_get_fd(uidev);
|
|
|
|
rc = libevdev_new_from_fd(fd, &dev);
|
|
ck_assert_msg(rc == 0, "Failed to init device device: %s", strerror(-rc));
|
|
rc = fcntl(fd, F_SETFL, O_NONBLOCK);
|
|
ck_assert_msg(rc == 0, "fcntl failed: %s", strerror(errno));
|
|
|
|
*uidev_return = uidev;
|
|
*dev_return = dev;
|
|
}
|