config: add finding touch configurations

This commit is contained in:
Jens Peters 2024-01-19 10:07:52 +01:00 committed by Johan Malm
parent 2c3ab16f39
commit 3f77514459
3 changed files with 36 additions and 0 deletions

View file

@ -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 */

View file

@ -3,6 +3,7 @@ labwc_sources += files(
'keybind.c',
'session.c',
'mousebind.c',
'touch.c',
'tablet.c',
'libinput.c',
)

33
src/config/touch.c Normal file
View file

@ -0,0 +1,33 @@
// SPDX-License-Identifier: GPL-2.0-only
#define _POSIX_C_SOURCE 200809L
#include <strings.h>
#include <wlr/util/log.h>
#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();
}