diff --git a/js/gamepad.js b/js/gamepad.js index 2ac8379..ed6a346 100644 --- a/js/gamepad.js +++ b/js/gamepad.js @@ -324,7 +324,7 @@ class Gamepad { * @returns {object} */ toGamepadInfo(id) { - return /(?.*?) \((Vendor: (?[0-9a-f]{4}) Product: (?[0-9a-f]{4})|(?.*?))\)/.exec(id).groups; + return /(?.*?) \((?:.*?Vendor: (?[0-9a-f]{4}) Product: (?[0-9a-f]{4})|(?.*?))\)/.exec(id).groups; } /** diff --git a/templates/debug/template.css b/templates/debug/template.css index fe951fb..6a94f2f 100644 --- a/templates/debug/template.css +++ b/templates/debug/template.css @@ -52,3 +52,9 @@ white-space: nowrap; color: white; } + +#info-vendor, +#info-product, +#info-id { + display: none; +} diff --git a/templates/debug/template.html b/templates/debug/template.html index ce8a3d5..10d0523 100644 --- a/templates/debug/template.html +++ b/templates/debug/template.html @@ -20,6 +20,12 @@
+
+
+
ID
+
+
+
diff --git a/templates/debug/template.js b/templates/debug/template.js index f782a04..d5b189c 100644 --- a/templates/debug/template.js +++ b/templates/debug/template.js @@ -1,8 +1,9 @@ function DebugTemplate(gamepad) { return { $name: $('#info-name .value'), - $vendor: $('#info-vendor .value'), - $product: $('#info-product .value'), + $vendor: $('#info-vendor'), + $product: $('#info-product'), + $id: $('#info-id'), $timestamp: $('#info-timestamp .value'), $index: $('#info-index .value'), $mapping: $('#info-mapping .value'), @@ -14,10 +15,14 @@ function DebugTemplate(gamepad) { if (!this.activeGamepad) { return; } - const { name, vendor, product } = gamepad.toGamepadInfo(this.activeGamepad.id); + const { name, vendor, product, id } = gamepad.toGamepadInfo(this.activeGamepad.id); this.$name.html(name).attr('title', name); - this.$vendor.html(vendor); - this.$product.html(product); + if (vendor && product) { + this.$vendor.css({display: 'block'}).find('.value').html(vendor); + this.$product.css({display: 'block'}).find('.value').html(product); + } else { + this.$id.css({display: 'block'}).find('.value').html(id); + } this.updateTimestamp(); this.$index.html(this.activeGamepad.index); this.$mapping.html(this.activeGamepad.mapping || 'N/A');