summaryrefslogtreecommitdiff
path: root/hw/xfree86/parser
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2010-06-10 06:15:41 -0700
committerPeter Hutterer <peter.hutterer@who-t.net>2010-06-11 09:30:33 +1000
commit87a1507da7e7788232d74285ef377b67b70e0fa4 (patch)
tree5fe21b2ea4299acfad7603259abfd7330781abee /hw/xfree86/parser
parent645679c1523eee7028f3244cee57936b93326a2a (diff)
xfree86: Match devices based on USB ID
Sometimes the vendor and product names aren't specific enough to target a USB device, so expose the numeric codes in the ID. A MatchUSBID entry has been added that supports shell pattern matching when fnmatch(3) is available. For example: MatchUSBID "046d:*" The IDs are stored in lowercase hex separated by a ':' like "lsusb" or "lspci -n". Signed-off-by: Dan Nicholson <dbn.lists@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'hw/xfree86/parser')
-rw-r--r--hw/xfree86/parser/InputClass.c19
-rw-r--r--hw/xfree86/parser/xf86Parser.h1
-rw-r--r--hw/xfree86/parser/xf86tokens.h1
3 files changed, 21 insertions, 0 deletions
diff --git a/hw/xfree86/parser/InputClass.c b/hw/xfree86/parser/InputClass.c
index e5ef96cde..bdcfba486 100644
--- a/hw/xfree86/parser/InputClass.c
+++ b/hw/xfree86/parser/InputClass.c
@@ -49,6 +49,7 @@ xf86ConfigSymTabRec InputClassTab[] =
{MATCH_DEVICE_PATH, "matchdevicepath"},
{MATCH_OS, "matchos"},
{MATCH_PNPID, "matchpnpid"},
+ {MATCH_USBID, "matchusbid"},
{MATCH_TAG, "matchtag"},
{MATCH_IS_KEYBOARD, "matchiskeyboard"},
{MATCH_IS_POINTER, "matchispointer"},
@@ -120,6 +121,11 @@ xf86parseInputClassSection(void)
Error(QUOTE_MSG, "MatchPnPID");
ptr->match_pnpid = xstrtokenize(val.str, TOKEN_SEP);
break;
+ case MATCH_USBID:
+ if (xf86getSubToken(&(ptr->comment)) != STRING)
+ Error(QUOTE_MSG, "MatchUSBID");
+ ptr->match_usbid = xstrtokenize(val.str, TOKEN_SEP);
+ break;
case MATCH_TAG:
if (xf86getSubToken(&(ptr->comment)) != STRING)
Error(QUOTE_MSG, "MatchTag");
@@ -245,6 +251,14 @@ xf86printInputClassSection (FILE * cf, XF86ConfInputClassPtr ptr)
*list);
fprintf(cf, "\"\n");
}
+ if (ptr->match_usbid) {
+ fprintf(cf, "\tMatchUSBID \"");
+ for (list = ptr->match_usbid; *list; list++)
+ fprintf(cf, "%s%s",
+ list == ptr->match_usbid ? "" : TOKEN_SEP,
+ *list);
+ fprintf(cf, "\"\n");
+ }
if (ptr->match_tag) {
fprintf(cf, "\tMatchTag \"");
for (list = ptr->match_tag; *list; list++)
@@ -311,6 +325,11 @@ xf86freeInputClassList (XF86ConfInputClassPtr ptr)
free(*list);
free(ptr->match_pnpid);
}
+ if (ptr->match_usbid) {
+ for (list = ptr->match_usbid; *list; list++)
+ free(*list);
+ free(ptr->match_usbid);
+ }
if (ptr->match_tag) {
for (list = ptr->match_tag; *list; list++)
free(*list);
diff --git a/hw/xfree86/parser/xf86Parser.h b/hw/xfree86/parser/xf86Parser.h
index 87fc31c5f..a86462f93 100644
--- a/hw/xfree86/parser/xf86Parser.h
+++ b/hw/xfree86/parser/xf86Parser.h
@@ -348,6 +348,7 @@ typedef struct
char **match_device;
char **match_os;
char **match_pnpid;
+ char **match_usbid;
char **match_tag;
xf86TriState is_keyboard;
xf86TriState is_pointer;
diff --git a/hw/xfree86/parser/xf86tokens.h b/hw/xfree86/parser/xf86tokens.h
index aa33935d1..23460dd73 100644
--- a/hw/xfree86/parser/xf86tokens.h
+++ b/hw/xfree86/parser/xf86tokens.h
@@ -281,6 +281,7 @@ typedef enum {
MATCH_DEVICE_PATH,
MATCH_OS,
MATCH_PNPID,
+ MATCH_USBID,
MATCH_TAG,
MATCH_IS_KEYBOARD,
MATCH_IS_POINTER,