diff options
author | Dan Nicholson <dbn.lists@gmail.com> | 2010-06-10 06:15:41 -0700 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2010-06-11 09:30:33 +1000 |
commit | 87a1507da7e7788232d74285ef377b67b70e0fa4 (patch) | |
tree | 5fe21b2ea4299acfad7603259abfd7330781abee /hw/xfree86 | |
parent | 645679c1523eee7028f3244cee57936b93326a2a (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')
-rw-r--r-- | hw/xfree86/common/xf86Xinput.c | 4 | ||||
-rw-r--r-- | hw/xfree86/doc/man/xorg.conf.man.pre | 9 | ||||
-rw-r--r-- | hw/xfree86/parser/InputClass.c | 19 | ||||
-rw-r--r-- | hw/xfree86/parser/xf86Parser.h | 1 | ||||
-rw-r--r-- | hw/xfree86/parser/xf86tokens.h | 1 |
5 files changed, 34 insertions, 0 deletions
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c index 5b0ec8f26..421803962 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -604,6 +604,10 @@ InputClassMatches(const XF86ConfInputClassPtr iclass, if (!MatchAttrToken(attrs->pnp_id, iclass->match_pnpid, match_pattern)) return FALSE; + /* MatchUSBID pattern */ + if (!MatchAttrToken(attrs->usb_id, iclass->match_usbid, match_pattern)) + return FALSE; + /* * MatchTag string * See if any of the device's tags match any of the MatchTag tokens. diff --git a/hw/xfree86/doc/man/xorg.conf.man.pre b/hw/xfree86/doc/man/xorg.conf.man.pre index c17ecb941..63dbb68b1 100644 --- a/hw/xfree86/doc/man/xorg.conf.man.pre +++ b/hw/xfree86/doc/man/xorg.conf.man.pre @@ -1101,6 +1101,15 @@ The device's Plug and Play (PnP) ID can be checked against the shell wildcard pattern. Multiple IDs can be matched by separating arguments with a '|' character. .TP 7 +.BI "MatchUSBID \*q" matchusb \*q +The device's USB ID can be checked against the +.RI \*q matchusb \*q +shell wildcard pattern. The ID is constructed as lowercase hexadecimal numbers +separated by a ':'. This is the same format as the +.BR lsusb (8) +program. Multiple IDs can be matched by separating arguments with a '|' +character. +.TP 7 .BI "MatchTag \*q" matchtag \*q This entry can be used to check if tags assigned by the config backend matches the 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, |