{ BTN_TOOL_TRIPLETAP, 3 },
{ BTN_TOOL_DOUBLETAP, 2 },
};
- struct map *m;
unsigned int i, n_btn_tool_touches = 1;
absinfo = libevdev_get_abs_info(device->evdev, ABS_MT_SLOT);
KEY_ONSCREEN_KEYBOARD,
KEY_CONTROLPANEL,
};
- unsigned int *code;
/* Wacom's keys are the only ones we know anything about */
if (libevdev_get_id_vendor(device->evdev) != VENDOR_ID_WACOM)
.code = SYN_REPORT,
.value = 0 },
};
- struct input_event *e;
if (tablet_has_status(tablet, TABLET_TOOL_IN_CONTACT) ||
tablet_has_status(tablet, TABLET_BUTTONS_DOWN)) {
{ "ID_INPUT_KEYBOARD", UDEV_KEYBOARD },
{ "ID_INPUT_KEY", UDEV_KEYBOARD },
};
- struct ut_map *map;
ARRAY_FOR_EACH(mappings, map) {
if (udev_prop(device, map->prop))
#include "config.h"
#define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
+/**
+ * Iterate through the array _arr, assigning the variable elem to each
+ * element. elem only exists within the loop.
+ */
#define ARRAY_FOR_EACH(_arr, _elem) \
- for (size_t _i = 0; _i < ARRAY_LENGTH(_arr) && (_elem = &_arr[_i]); _i++)
+ for (__typeof__((_arr)[0]) *_elem = _arr; \
+ _elem < (_arr) + ARRAY_LENGTH(_arr); \
+ _elem++)
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
{ "REL_", EV_REL },
{ "SW_", EV_SW },
};
- struct map *m;
bool found = false;
ARRAY_FOR_EACH(map, m) {
{"h", 60, 48},
{"d", 24, ~0},
};
- struct c *c;
uint64_t value = us;
ARRAY_FOR_EACH(conversion, c) {
unsigned int button,
bool is_press)
{
- struct input_event *ev;
struct input_event click[] = {
{ .type = EV_KEY, .code = button, .value = is_press ? 1 : 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
void
litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press)
{
- struct input_event *ev;
struct input_event click[] = {
{ .type = EV_KEY, .code = key, .value = is_press ? 1 : 0 },
{ .type = EV_SYN, .code = SYN_REPORT, .value = 0 },
const char *format,
va_list args)
{
- char *message, **dmsg;
+ char *message;
int n;
if (priority != LIBINPUT_LOG_PRIORITY_DEBUG)
LIBINPUT_DEVICE_CAP_GESTURE,
LIBINPUT_DEVICE_CAP_SWITCH,
};
- enum libinput_device_capability *cap;
int ncaps = 0;
ARRAY_FOR_EACH(caps, cap) {
EV_KEY, KEY_A,
-1, -1,
};
- enum libinput_key_state *state;
enum libinput_key_state expected_states[] = {
LIBINPUT_KEY_STATE_PRESSED,
LIBINPUT_KEY_STATE_RELEASED,
"MatchVendor=123\n"
"ModelAppleTouchpad=1\n",
};
- const char **qf;
ARRAY_FOR_EACH(quirks_file, qf) {
struct data_dir dd = make_data_dir(*qf);
"MatchProduct=123\n"
"ModelAppleTouchpad=1\n",
};
- const char **qf;
ARRAY_FOR_EACH(quirks_file, qf) {
struct data_dir dd = make_data_dir(*qf);
"MatchVersion=123\n"
"ModelAppleTouchpad=1\n",
};
- const char **qf;
ARRAY_FOR_EACH(quirks_file, qf) {
struct data_dir dd = make_data_dir(*qf);
"MatchName=\n"
"ModelAppleTouchpad=1\n",
};
- const char **qf;
ARRAY_FOR_EACH(quirks_file, qf) {
struct data_dir dd = make_data_dir(*qf);
"MatchUdevType=123\n"
"ModelAppleTouchpad=1\n",
};
- const char **qf;
ARRAY_FOR_EACH(quirks_file, qf) {
struct data_dir dd = make_data_dir(*qf);
"MatchDMIModalias=foo\n"
"ModelAppleTouchpad=1\n",
};
- const char **qf;
ARRAY_FOR_EACH(quirks_file, qf) {
struct data_dir dd = make_data_dir(*qf);
QUIRK_ATTR_SIZE_HINT,
QUIRK_ATTR_RESOLUTION_HINT,
};
- enum quirk *a;
struct qtest_dim test_values[] = {
{ "10x10", true, 10, 10 },
{ "20x30", true, 20, 30 },
{ "0x00", false, 0, 0 },
{ "0xa0", false, 0, 0 },
};
- struct qtest_dim *t;
ARRAY_FOR_EACH(attrs, a) {
ARRAY_FOR_EACH(test_values, t) {
QUIRK_ATTR_TOUCH_SIZE_RANGE,
QUIRK_ATTR_PRESSURE_RANGE,
};
- enum quirk *a;
struct qtest_range test_values[] = {
{ "20:10", true, 20, 10 },
{ "30:5", true, 30, 5 },
{ "0xa0", false, 0, 0 },
{ "0x10:0x5", false, 0, 0 },
};
- struct qtest_range *t;
ARRAY_FOR_EACH(attrs, a) {
ARRAY_FOR_EACH(test_values, t) {
QUIRK_ATTR_PALM_PRESSURE_THRESHOLD,
QUIRK_ATTR_THUMB_PRESSURE_THRESHOLD,
};
- enum quirk *a;
struct qtest_uint test_values[] = {
{ "10", true, 10 },
{ "0", true, 0 },
{ "0xab", false, 0 },
{ "ab", false, 0 },
};
- struct qtest_uint *t;
ARRAY_FOR_EACH(attrs, a) {
ARRAY_FOR_EACH(test_values, t) {
enum quirk attrs[] = {
QUIRK_ATTR_TRACKPOINT_MULTIPLIER,
};
- enum quirk *a;
struct qtest_double test_values[] = {
{ "10", true, 10.0 },
{ "10.0", true, 10.0 },
{ "10:5", false, 0 },
{ "10x5", false, 0 },
};
- struct qtest_double *t;
ARRAY_FOR_EACH(attrs, a) {
ARRAY_FOR_EACH(test_values, t) {
QUIRK_ATTR_LID_SWITCH_RELIABILITY,
QUIRK_ATTR_KEYBOARD_INTEGRATION,
};
- enum quirk *a;
struct qtest_str test_values[] = {
{ "below", QUIRK_ATTR_TPKBCOMBO_LAYOUT },
{ "reliable", QUIRK_ATTR_LID_SWITCH_RELIABILITY },
{ "0xa", 0 },
{ "0.0", 0 },
};
- struct qtest_str *t;
ARRAY_FOR_EACH(attrs, a) {
ARRAY_FOR_EACH(test_values, t) {
QUIRK_ATTR_USE_VELOCITY_AVERAGING,
QUIRK_ATTR_TABLET_SMOOTHING,
};
- enum quirk *a;
struct qtest_bool test_values[] = {
{ "0", true, false },
{ "1", true, true },
{ "-1", false, false },
{ "a", false, false },
};
- struct qtest_bool *t;
ARRAY_FOR_EACH(attrs, a) {
ARRAY_FOR_EACH(test_values, t) {
{ BTN_1, BTN_RIGHT },
{ BTN_2, BTN_MIDDLE },
};
- const struct buttons *b;
trackpoint = litest_add_device(li,
LITEST_TRACKPOINT);
KEY_RIGHTMETA,
KEY_LEFTMETA,
};
- unsigned int *key;
if (!has_disable_while_typing(touchpad))
return;
KEY_RIGHTMETA,
KEY_LEFTMETA,
};
- unsigned int *key;
if (!has_disable_while_typing(touchpad))
return;
KEY_RIGHTMETA,
KEY_LEFTMETA,
};
- unsigned int *key;
if (!has_disable_while_typing(touchpad))
return;
KEY_RIGHTMETA,
KEY_LEFTMETA,
};
- unsigned int *key;
if (!has_disable_while_typing(touchpad))
return;
#include "check-double-macros.h"
+START_TEST(array_for_each)
+{
+ int ai[6];
+ char ac[10];
+ struct as {
+ int a;
+ char b;
+ int *ptr;
+ } as[32];
+
+ for (size_t i = 0; i < 6; i++)
+ ai[i] = 20 + i;
+ for (size_t i = 0; i < 10; i++)
+ ac[i] = 100 + i;
+ for (size_t i = 0; i < 32; i++) {
+ as[i].a = 10 + i;
+ as[i].b = 20 + i;
+ as[i].ptr = (int*)0xab + i;
+ }
+
+ int iexpected = 20;
+ ARRAY_FOR_EACH(ai, entry) {
+ ck_assert_int_eq(*entry, iexpected);
+ ++iexpected;
+ }
+ ck_assert_int_eq(iexpected, 26);
+
+ int cexpected = 100;
+ ARRAY_FOR_EACH(ac, entry) {
+ ck_assert_int_eq(*entry, cexpected);
+ ++cexpected;
+ }
+ ck_assert_int_eq(cexpected, 110);
+
+ struct as sexpected = {
+ .a = 10,
+ .b = 20,
+ .ptr = (int*)0xab,
+ };
+ ARRAY_FOR_EACH(as, entry) {
+ ck_assert_int_eq(entry->a, sexpected.a);
+ ck_assert_int_eq(entry->b, sexpected.b);
+ ck_assert_ptr_eq(entry->ptr, sexpected.ptr);
+ ++sexpected.a;
+ ++sexpected.b;
+ ++sexpected.ptr;
+ }
+ ck_assert_int_eq(sexpected.a, 42);
+}
+END_TEST
+
START_TEST(bitfield_helpers)
{
/* This value has a bit set on all of the word boundaries we want to
{ .which = 0, .prop = ":asb::::" },
{ .which = 0, .prop = "foo" },
};
- struct test *t;
ARRAY_FOR_EACH(tests, t) {
struct input_absinfo abs;
{ 1, {NULL, NULL}, 0 },
{ 3, {"hello", NULL, "World"}, 0 },
};
- struct argv_test *t;
ARRAY_FOR_EACH(tests, t) {
char **strv = strv_from_argv(t->argc, t->argv);
{ "/bar", "bar" },
{ "", NULL },
};
- struct test *t;
ARRAY_FOR_EACH(tests, t) {
const char *result = safe_basename(t->path);
{ "/bar", "bar" },
{ "", "" },
};
- struct test *t;
ARRAY_FOR_EACH(tests, t) {
char *result = trunkname(t->path);
s = suite_create("litest:utils");
tc = tcase_create("utils");
+ tcase_add_test(tc, array_for_each);
+
tcase_add_test(tc, bitfield_helpers);
tcase_add_test(tc, matrix_helpers);
tcase_add_test(tc, ratelimit_helpers);
static inline void
draw_touchpoints(struct window *w, cairo_t *cr)
{
- struct touch *t;
-
cairo_save(cr);
ARRAY_FOR_EACH(w->touches, t) {
if (t->state == TOUCH_ACTIVE)
static void
window_cleanup(struct window *w)
{
- struct libinput_device **dev;
ARRAY_FOR_EACH(w->devices, dev) {
if (*dev)
libinput_device_unref(*dev);
static void
change_ptraccel(struct window *w, double amount)
{
- struct libinput_device **dev;
-
ARRAY_FOR_EACH(w->devices, dev) {
double speed;
enum libinput_config_status status;
handle_event_device_notify(struct libinput_event *ev)
{
struct libinput_device *dev = libinput_event_get_device(ev);
- struct libinput_device **device;
struct libinput *li;
struct window *w;
const char *type;
{
struct libinput_event_tablet_tool *t = libinput_event_get_tablet_tool_event(ev);
unsigned int button = libinput_event_tablet_tool_get_button(t);
- unsigned int *btn;
enum libinput_button_state state = libinput_event_tablet_tool_get_button_state(t);
ARRAY_FOR_EACH(ctx->buttons_down, btn) {
{LIBINPUT_DEVICE_CAP_GESTURE, "gesture"},
{LIBINPUT_DEVICE_CAP_SWITCH, "switch"},
};
- struct cap *cap;
const char *sep = "";
if (!device)
struct libevdev *evdev = NULL;
int fd = -1;
int rc;
- unsigned int *code;
unsigned int axes[] = {ABS_X,
ABS_Y,
ABS_MT_POSITION_X,
static void
handle_evdev_abs(struct udev_device *device)
{
- unsigned int *code;
unsigned int axes[] = {ABS_X,
ABS_Y,
ABS_MT_POSITION_X,
struct libevdev *evdev = NULL;
int fd = -1;
int rc;
- unsigned int *code;
unsigned int axes[] = {ABS_X,
ABS_Y,
ABS_MT_POSITION_X,