From f4a9d6897e39cfab4ccbc919df8690ee60c874b6 Mon Sep 17 00:00:00 2001 From: OleSTEEP Date: Tue, 9 Jan 2024 02:09:56 +0300 Subject: [PATCH] Add FPSCounter toggle button (Debug only) --- www/js/porting/css/controls.css | 9 +++++++++ www/js/porting/jscontrols.js | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/www/js/porting/css/controls.css b/www/js/porting/css/controls.css index 1237b4b..1ec163f 100644 --- a/www/js/porting/css/controls.css +++ b/www/js/porting/css/controls.css @@ -38,6 +38,15 @@ min-height: 6vh; } +.fps-button { + position: absolute; + left: 5px; + top: 5px; + width: 90px; + height: 40px; + z-index: 1489; +} + .gamepad-buttons { opacity: 0.9; z-index: 1488; diff --git a/www/js/porting/jscontrols.js b/www/js/porting/jscontrols.js index 7f75e84..0516beb 100644 --- a/www/js/porting/jscontrols.js +++ b/www/js/porting/jscontrols.js @@ -50,6 +50,22 @@ function create_control_buttons() { document.body.appendChild(DivBMain); } +function create_fps_button() { + // Remove in release + const keys = [{ key: 'F2', keyCode: 113 }]; + + const FPSBtn = document.createElement("div"); + FPSBtn.className = "fps-button"; + FPSBtn.id = "buttonF2"; + document.body.appendChild(FPSBtn); + + for (const key of keys) { + const elementId = key.id === undefined ? `button${key.key}` : key.id; + console.log(`Setting up the ${elementId} key...`); + setupKey(elementId, key.key, key.keyCode); + } +} + function create_dpad_buttons() { // Скуфting elements const DivDMain = document.createElement("div"); @@ -266,6 +282,7 @@ function setupKey(id, key, keyCode) { } window.addEventListener('load', () => { + create_fps_button(); // Remove in release if (navigator.getGamepads().length == 0) { create_control_buttons(); create_dpad_buttons();