Skip to content
Snippets Groups Projects
Commit 8f47888a authored by Stephen D's avatar Stephen D
Browse files

qr

parent 5a14ce0b
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,7 @@ const b = document.getElementById("b");
const select = document.getElementById("select");
const start = document.getElementById("start");
let qr = {};
let pressedButtons = {};
// SO BAD AAAAAAA
......@@ -130,16 +131,27 @@ select.onpointerup = () => {
};
function checkButtonStatus() {
up.style = pressedButtons.up ? "background-color: red;" : "";
down.style = pressedButtons.down ? "background-color: red;" : "";
left.style = pressedButtons.left ? "background-color: red;" : "";
right.style = pressedButtons.right ? "background-color: red;" : "";
a.style = pressedButtons.a ? "background-color: red;" : "";
b.style = pressedButtons.b ? "background-color: red;" : "";
start.style = pressedButtons.start ? "background-color: red;" : "";
select.style = pressedButtons.select ? "background-color: red;" : "";
nesWorker.postMessage({ keys: pressedButtons });
const pressed = {
left: pressedButtons.left || qr.left,
right: pressedButtons.right || qr.right,
up: pressedButtons.up || qr.up,
down: pressedButtons.down || qr.down,
a: pressedButtons.a || qr.a,
b: pressedButtons.b || qr.b,
start: pressedButtons.start || qr.start,
select: pressedButtons.select || qr.select,
};
up.style = pressed.up ? "background-color: red;" : "";
down.style = pressed.down ? "background-color: red;" : "";
left.style = pressed.left ? "background-color: red;" : "";
right.style = pressed.right ? "background-color: red;" : "";
a.style = pressed.a ? "background-color: red;" : "";
b.style = pressed.b ? "background-color: red;" : "";
start.style = pressed.start ? "background-color: red;" : "";
select.style = pressed.select ? "background-color: red;" : "";
nesWorker.postMessage({ keys: pressed });
}
let datas = {};
......@@ -204,13 +216,16 @@ function tick() {
latencyDiv.innerText = `Frame latency: ${delta}ms`;
// reset
qr = {};
if (code?.data.length > 0) {
latencyScan.innerText = `Scan latency: ${delta}ms`;
// TODO Spencer
//if code.data.length {
//}
if (code.data == "ABCDEFGHIJKLNOPQRSTUVWXYZ") {
qr.a = true;
}
drawLine(
code.location.topLeftCorner,
......@@ -238,6 +253,8 @@ function tick() {
renderData();
}
checkButtonStatus();
}
requestAnimationFrame(tick);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment