optimized gamepad scanning

This commit is contained in:
e7d 2020-08-18 09:33:03 +02:00
parent c5e78eadcc
commit 3f4fed06f3
No known key found for this signature in database
GPG Key ID: F320BE007C0B8881

View File

@ -268,10 +268,12 @@ class Gamepad {
*/
refresh() {
// get fresh information from DOM about gamepads
this.gamepads = this.getNavigatorGamepads();
const gamepads = this.getNavigatorGamepads();
if (gamepads !== this.gamepads) {
this.gamepads = gamepads;
this.buildHelpGamepadList();
}
}
/**
* Builds the help gamepad list
@ -453,7 +455,7 @@ class Gamepad {
* @param {*} gamepad
*/
loadTemplate(gamepad) {
$.ajax(`templates/${this.type}/template.html`, {async: true}).done((template) => {
$.ajax(`templates/${this.type}/template.html`).done((template) => {
// inject the template HTML
this.$gamepad.html(template);
window.setTimeout(() => {
@ -593,9 +595,11 @@ class Gamepad {
}
} else {
this.backgroundColorIndex = color;
this.backgroundColorName
this.backgroundColorName;
}
this.backgroundColorName = this.backgroundColors[this.backgroundColorIndex];
this.backgroundColorName = this.backgroundColors[
this.backgroundColorIndex
];
this.$body.css({
background: this.backgroundColorName,