fix debug information

This commit is contained in:
e7d 2023-05-31 16:21:00 +02:00
parent 3a2a2f6cad
commit eca6c946f6
No known key found for this signature in database
GPG Key ID: F320BE007C0B8881
4 changed files with 23 additions and 6 deletions

View File

@ -324,7 +324,7 @@ class Gamepad {
* @returns {object}
*/
toGamepadInfo(id) {
return /(?<name>.*?) \((Vendor: (?<vendor>[0-9a-f]{4}) Product: (?<product>[0-9a-f]{4})|(?<id>.*?))\)/.exec(id).groups;
return /(?<name>.*?) \((?:.*?Vendor: (?<vendor>[0-9a-f]{4}) Product: (?<product>[0-9a-f]{4})|(?<id>.*?))\)/.exec(id).groups;
}
/**

View File

@ -52,3 +52,9 @@
white-space: nowrap;
color: white;
}
#info-vendor,
#info-product,
#info-id {
display: none;
}

View File

@ -20,6 +20,12 @@
<div class="value"></div>
</div>
</div>
<div id="info-id" class="box medium">
<div class="content">
<div class="label">ID</div>
<div class="value"></div>
</div>
</div>
</div>
</div>
<div class="info">

View File

@ -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');