From 9b5135920d068442e25ee9387cd7881c8793cc50 Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Tue, 4 Aug 2020 15:12:08 +0200 Subject: [PATCH] fix javascript --- .../views/frontend/templates/gamepad.js | 2 ++ .../views/frontend/templates/index.html | 36 +++++++++---------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/raspberry/roberto/views/frontend/templates/gamepad.js b/raspberry/roberto/views/frontend/templates/gamepad.js index 27a2068..f189048 100644 --- a/raspberry/roberto/views/frontend/templates/gamepad.js +++ b/raspberry/roberto/views/frontend/templates/gamepad.js @@ -97,6 +97,8 @@ if (haveEvents) { // Virtual Joystick var joystick = nipplejs.create({ zone: document.getElementById('controls'), + mode: 'static', + position: {left: '50%', top: '50%'}, color: 'blue' }); /* diff --git a/raspberry/roberto/views/frontend/templates/index.html b/raspberry/roberto/views/frontend/templates/index.html index df044f2..5403cd9 100644 --- a/raspberry/roberto/views/frontend/templates/index.html +++ b/raspberry/roberto/views/frontend/templates/index.html @@ -26,6 +26,7 @@ right: 0; width: 100%; height: 33%; + pointer-events: all; } p { position: relative; @@ -45,12 +46,9 @@ opacity: 0.6; z-index: 1; } - #textoverlay, #controls, .stats-box { + #textoverlay, .stats-box { pointer-events: none; } - #controls canvas { - pointer-events: all; - } @@ -199,24 +197,26 @@ socket.on('battery', (data) => { }; -statsInterval = window.setInterval(getConnectionStats, 1000); +function getConnectionStats() { + if (webrtcPeerConnection) { + webrtcPeerConnection.getStats(null).then(stats => { + var statsOutput = ""; -function getConnectionStats() { - webrtcPeerConnection.getStats(null).then(stats => { - var statsOutput = ""; - - stats.forEach(report => { - if (report.type === "inbound-rtp" && report.kind === "video") { - Object.keys(report).forEach(statName => { - statsOutput += `${statName}: ${report[statName]}
\n`; - }); - } + stats.forEach(report => { + if (report.type === "inbound-rtp" && report.kind === "video") { + Object.keys(report).forEach(statName => { + statsOutput += `${statName}: ${report[statName]}
\n`; + }); + } + }); + + document.querySelector(".stats-box").innerHTML = statsOutput; }); - - document.querySelector(".stats-box").innerHTML = statsOutput; - }); + } } +var statsInterval = window.setInterval(getConnectionStats, 1000); +