()
| 3431 | } |
| 3432 | } |
| 3433 | setVirtualGamepad() { |
| 3434 | this.virtualGamepad = this.createElement("div"); |
| 3435 | this.toggleVirtualGamepad = (show) => { |
| 3436 | this.virtualGamepad.style.display = show ? "" : "none"; |
| 3437 | } |
| 3438 | this.virtualGamepad.classList.add("ejs_virtualGamepad_parent"); |
| 3439 | this.elements.parent.appendChild(this.virtualGamepad); |
| 3440 | |
| 3441 | const speedControlButtons = [ |
| 3442 | { "type": "button", "text": "Fast", "id": "speed_fast", "location": "center", "left": -35, "top": 50, "fontSize": 15, "block": true, "input_value": 27 }, |
| 3443 | { "type": "button", "text": "Slow", "id": "speed_slow", "location": "center", "left": 95, "top": 50, "fontSize": 15, "block": true, "input_value": 29 }, |
| 3444 | ]; |
| 3445 | if (this.rewindEnabled) { |
| 3446 | speedControlButtons.push({ "type": "button", "text": "Rewind", "id": "speed_rewind", "location": "center", "left": 30, "top": 50, "fontSize": 15, "block": true, "input_value": 28 }); |
| 3447 | } |
| 3448 | |
| 3449 | let info; |
| 3450 | if (this.config.VirtualGamepadSettings && function (set) { |
| 3451 | if (!Array.isArray(set)) { |
| 3452 | console.warn("Virtual gamepad settings is not array! Using default gamepad settings"); |
| 3453 | return false; |
| 3454 | } |
| 3455 | if (!set.length) { |
| 3456 | console.warn("Virtual gamepad settings is empty! Using default gamepad settings"); |
| 3457 | return false; |
| 3458 | } |
| 3459 | for (let i = 0; i < set.length; i++) { |
| 3460 | if (!set[i].type) continue; |
| 3461 | try { |
| 3462 | if (set[i].type === "zone" || set[i].type === "dpad") { |
| 3463 | if (!set[i].location) { |
| 3464 | console.warn("Missing location value for " + set[i].type + "! Using default gamepad settings"); |
| 3465 | return false; |
| 3466 | } else if (!set[i].inputValues) { |
| 3467 | console.warn("Missing inputValues for " + set[i].type + "! Using default gamepad settings"); |
| 3468 | return false; |
| 3469 | } |
| 3470 | continue; |
| 3471 | } |
| 3472 | if (!set[i].location) { |
| 3473 | console.warn("Missing location value for button " + set[i].text + "! Using default gamepad settings"); |
| 3474 | return false; |
| 3475 | } else if (!set[i].type) { |
| 3476 | console.warn("Missing type value for button " + set[i].text + "! Using default gamepad settings"); |
| 3477 | return false; |
| 3478 | } else if (!set[i].id.toString()) { |
| 3479 | console.warn("Missing id value for button " + set[i].text + "! Using default gamepad settings"); |
| 3480 | return false; |
| 3481 | } else if (!set[i].input_value.toString()) { |
| 3482 | console.warn("Missing input_value for button " + set[i].text + "! Using default gamepad settings"); |
| 3483 | return false; |
| 3484 | } |
| 3485 | } catch(e) { |
| 3486 | console.warn("Error checking values! Using default gamepad settings"); |
| 3487 | return false; |
| 3488 | } |
| 3489 | } |
| 3490 | return true; |
no test coverage detected