diff --git a/include/config/touch.h b/include/config/touch.h index 6b453fff..96423f93 100644 --- a/include/config/touch.h +++ b/include/config/touch.h @@ -11,4 +11,6 @@ struct touch_config_entry { struct wl_list link; /* struct rcxml.touch_configs */ }; +struct touch_config_entry *touch_find_config_for_device(char *device_name); + #endif /* LABWC_TOUCH_CONFIG_H */ diff --git a/src/config/meson.build b/src/config/meson.build index a0968da8..de08f6d0 100644 --- a/src/config/meson.build +++ b/src/config/meson.build @@ -3,6 +3,7 @@ labwc_sources += files( 'keybind.c', 'session.c', 'mousebind.c', + 'touch.c', 'tablet.c', 'libinput.c', ) diff --git a/src/config/touch.c b/src/config/touch.c new file mode 100644 index 00000000..bd2bc068 --- /dev/null +++ b/src/config/touch.c @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-only +#define _POSIX_C_SOURCE 200809L +#include +#include +#include "common/list.h" +#include "config/rcxml.h" + +static struct touch_config_entry * +find_default_config(void) +{ + struct touch_config_entry *entry; + wl_list_for_each(entry, &rc.touch_configs, link) { + if (!entry->device_name) { + wlr_log(WLR_INFO, "found default touch configuration"); + return entry; + } + } + return NULL; +} + +struct touch_config_entry * +touch_find_config_for_device(char *device_name) +{ + wlr_log(WLR_INFO, "find touch configuration for %s\n", device_name); + struct touch_config_entry *entry; + wl_list_for_each(entry, &rc.touch_configs, link) { + if (entry->device_name && !strcasecmp(entry->device_name, device_name)) { + wlr_log(WLR_INFO, "found touch configuration for %s\n", device_name); + return entry; + } + } + return find_default_config(); +}