From 66b21b2f455a1dfbc92f7caa571dcff3f3765808 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Mon, 7 Jun 2010 20:39:58 -0700 Subject: xfree86: Match devices based on current driver setting Often we want to apply a driver specific option to a set of devices and don't care how the driver was selected for that device. The MatchDriver entry can be used to match the current driver string: MatchDriver "evdev|mouse" Option "Emulate3Buttons" "yes" The driver string is a case sensitive match. Signed-off-by: Dan Nicholson Reviewed-by: Peter Hutterer Signed-off-by: Peter Hutterer --- hw/xfree86/parser/InputClass.c | 21 +++++++++++++++++++++ hw/xfree86/parser/xf86Parser.h | 1 + hw/xfree86/parser/xf86tokens.h | 1 + 3 files changed, 23 insertions(+) (limited to 'hw/xfree86/parser') diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c index f2b46bb1c..ce611d990 100644 --- a/hw/xfree86/parser/InputClass.c +++ b/hw/xfree86/parser/InputClass.c @@ -50,6 +50,7 @@ xf86ConfigSymTabRec InputClassTab[] = {MATCH_OS, "matchos"}, {MATCH_PNPID, "matchpnpid"}, {MATCH_USBID, "matchusbid"}, + {MATCH_DRIVER, "matchdriver"}, {MATCH_TAG, "matchtag"}, {MATCH_IS_KEYBOARD, "matchiskeyboard"}, {MATCH_IS_POINTER, "matchispointer"}, @@ -91,6 +92,7 @@ xf86parseInputClassSection(void) list_init(&ptr->match_os); list_init(&ptr->match_pnpid); list_init(&ptr->match_usbid); + list_init(&ptr->match_driver); list_init(&ptr->match_tag); while ((token = xf86getToken(InputClassTab)) != ENDSECTION) { @@ -153,6 +155,12 @@ xf86parseInputClassSection(void) add_group_entry(&ptr->match_usbid, xstrtokenize(val.str, TOKEN_SEP)); break; + case MATCH_DRIVER: + if (xf86getSubToken(&(ptr->comment)) != STRING) + Error(QUOTE_MSG, "MatchDriver"); + add_group_entry(&ptr->match_driver, + xstrtokenize(val.str, TOKEN_SEP)); + break; case MATCH_TAG: if (xf86getSubToken(&(ptr->comment)) != STRING) Error(QUOTE_MSG, "MatchTag"); @@ -283,6 +291,13 @@ xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr) *cur); fprintf(cf, "\"\n"); } + list_for_each_entry(group, &ptr->match_driver, entry) { + fprintf(cf, "\tMatchDriver \""); + for (cur = group->values; *cur; cur++) + fprintf(cf, "%s%s", cur == group->values ? "" : TOKEN_SEP, + *cur); + fprintf(cf, "\"\n"); + } list_for_each_entry(group, &ptr->match_tag, entry) { fprintf(cf, "\tMatchTag \""); for (cur = group->values; *cur; cur++) @@ -363,6 +378,12 @@ xf86freeInputClassList (XF86ConfInputClassPtr ptr) free(*list); free(group); } + list_for_each_entry_safe(group, next, &ptr->match_driver, entry) { + list_del(&group->entry); + for (list = group->values; *list; list++) + free(*list); + free(group); + } list_for_each_entry_safe(group, next, &ptr->match_tag, entry) { list_del(&group->entry); for (list = group->values; *list; list++) diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h index 26d9a5b33..337ad0718 100644 --- a/hw/xfree86/parser/xf86Parser.h +++ b/hw/xfree86/parser/xf86Parser.h @@ -357,6 +357,7 @@ typedef struct struct list match_os; struct list match_pnpid; struct list match_usbid; + struct list match_driver; struct list match_tag; xf86TriState is_keyboard; xf86TriState is_pointer; diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h index 23460dd73..c16a8f551 100644 --- a/hw/xfree86/parser/xf86tokens.h +++ b/hw/xfree86/parser/xf86tokens.h @@ -282,6 +282,7 @@ typedef enum { MATCH_OS, MATCH_PNPID, MATCH_USBID, + MATCH_DRIVER, MATCH_TAG, MATCH_IS_KEYBOARD, MATCH_IS_POINTER, -- cgit v1.2.3