labwc/src/config/libinput.c

65 lines
1.3 KiB
C
Raw Normal View History

2021-10-15 10:26:00 -04:00
// SPDX-License-Identifier: GPL-2.0-only
#include <string.h>
#include <strings.h>
#include "common/mem.h"
2021-10-15 10:26:00 -04:00
#include "config/libinput.h"
#include "config/rcxml.h"
2021-10-15 10:26:00 -04:00
static void
libinput_category_init(struct libinput_category *l)
{
l->type = DEFAULT_DEVICE;
2021-10-15 10:26:00 -04:00
l->name = NULL;
l->pointer_speed = -2;
l->natural_scroll = -1;
l->left_handed = -1;
l->tap = LIBINPUT_CONFIG_TAP_ENABLED;
l->tap_button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
l->tap_and_drag = -1;
l->drag_lock = -1;
2021-10-15 10:26:00 -04:00
l->accel_profile = -1;
l->middle_emu = -1;
l->dwt = -1;
}
enum device_type
get_device_type(const char *s)
{
if (!s) {
return DEFAULT_DEVICE;
}
if (!strcasecmp(s, "touch")) {
return TOUCH_DEVICE;
}
if (!strcasecmp(s, "non-touch")) {
return NON_TOUCH_DEVICE;
}
return DEFAULT_DEVICE;
}
struct libinput_category *
2021-10-15 20:52:36 +01:00
libinput_category_create(void)
2021-10-15 10:26:00 -04:00
{
2022-09-18 15:22:26 -04:00
struct libinput_category *l = znew(*l);
2021-10-15 10:26:00 -04:00
libinput_category_init(l);
wl_list_insert(&rc.libinput_categories, &l->link);
return l;
}
/*
* The default category is the first one with type == DEFAULT_DEVICE and
* no name. After rcxml_read(), a default category always exists.
*/
struct libinput_category *
libinput_category_get_default(void)
{
struct libinput_category *l;
wl_list_for_each(l, &rc.libinput_categories, link) {
if (l->type == DEFAULT_DEVICE && !l->name) {
return l;
}
}
return NULL;
}