Skip to content
Browse files

From: Aurelien Jarno <aurelien@aurel32.net>

Subject: [usbutils] Patch to support reporting of keyboard country type
Date:    Thu, 18 Mar 2004 10:58:31 +0100

Hi Thomas !

Please find attached a patch against the current CVS that I received
viathe Debian Bug Tracking System. It looks up the decimal HID Country
Code in usb.ids and reports it when "lsusb -v" is used on an HID
device.

For most cheap PC USB keyboards the data may be misleading, as they
commonly report as 00 or 33 types regardless of mapping.  However, Sun
and Apple kit uses the extension.

The list of HID Country Code has already been integrated into
usb.ids.You may have to update the version in the CVS from
http://linux-usb.org

Regards,
Aurelien
  • Loading branch information...
1 parent 925f2ad commit f72b28bdea085b463c7199c72b2cd62af8d27e80 Thomas Sailer committed Mar 18, 2004
Showing with 35 additions and 2 deletions.
  1. +2 −2 lsusb.c
  2. +32 −0 names.c
  3. +1 −0 names.h
View
4 lsusb.c
@@ -1348,9 +1348,9 @@ static void dump_hid_device(struct usb_dev_handle *dev, struct usb_interface_des
" bLength %5u\n"
" bDescriptorType %5u\n"
" bcdHID %2x.%02x\n"
- " bCountryCode %5u\n"
+ " bCountryCode %5u %s\n"
" bNumDescriptors %5u\n",
- buf[0], buf[1], buf[3], buf[2], buf[4], buf[5]);
+ buf[0], buf[1], buf[3], buf[2], buf[4], names_countrycode(buf[4]) ? : "Unknown", buf[5]);
for (i = 0; i < buf[5]; i++)
printf(" bDescriptorType %5u %s\n"
" wDescriptorLength %5u\n",
View
32 names.c
@@ -116,6 +116,7 @@ static struct genericstrtable *biass[HASHSZ] = { NULL, };
static struct genericstrtable *physdess[HASHSZ] = { NULL, };
static struct genericstrtable *hutus[HASHSZ] = { NULL, };
static struct genericstrtable *langids[HASHSZ] = { NULL, };
+static struct genericstrtable *countrycodes[HASHSZ] = { NULL, };
/* ---------------------------------------------------------------------- */
@@ -164,6 +165,11 @@ const char *names_bias(u_int8_t b)
return names_genericstrtable(biass, b);
}
+const char *names_countrycode(unsigned int countrycode)
+{
+ return names_genericstrtable(countrycodes, countrycode);
+}
+
const char *names_vendor(u_int16_t vendorid)
{
struct vendor *v;
@@ -402,6 +408,11 @@ static int new_bias(const char *name, u_int8_t b)
return new_genericstrtable(biass, name, b);
}
+static int new_countrycode(const char *name, unsigned int countrycode)
+{
+ return new_genericstrtable(countrycodes, name, countrycode);
+}
+
/* ---------------------------------------------------------------------- */
#define DBG(x)
@@ -553,6 +564,27 @@ static void parse(FILE *f)
DBG(printf("line %5u audio terminal type %02x %s\n", linectr, u, cp));
continue;
}
+ if (buf[0] == 'H' && buf[1] == 'C' && buf[2] == 'C' && isspace(buf[3])) {
+ /* HID Descriptor bCountryCode */
+ cp = buf+3;
+ while (isspace(*cp))
+ cp++;
+ if (!isxdigit(*cp)) {
+ fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
+ continue;
+ }
+ u = strtoul(cp, &cp, 10);
+ while (isspace(*cp))
+ cp++;
+ if (!*cp) {
+ fprintf(stderr, "Invalid HID country code at line %u\n", linectr);
+ continue;
+ }
+ if (new_countrycode(cp, u))
+ fprintf(stderr, "Duplicate HID country code at line %u country %02u %s\n", linectr, u, cp);
+ DBG(printf("line %5u keyboard country code %02u %s\n", linectr, u, cp));
+ continue;
+ }
if (isxdigit(*cp)) {
/* vendor */
u = strtoul(cp, &cp, 16);
View
1 names.h
@@ -44,6 +44,7 @@ extern const char *names_hutus(unsigned int data);
extern const char *names_langid(u_int16_t langid);
extern const char *names_physdes(u_int8_t ph);
extern const char *names_bias(u_int8_t b);
+extern const char *names_countrycode(unsigned int countrycode);
extern int names_init(char *n);
/* ---------------------------------------------------------------------- */

0 comments on commit f72b28b

Please sign in to comment.
Something went wrong with that request. Please try again.