From a42e8f96dcf619a16e444dd5f8f1e3167610b878 Mon Sep 17 00:00:00 2001 From: Kavin Muralikrishnan <921563@lcps.org> Date: Fri, 18 Oct 2024 17:05:22 -0400 Subject: [PATCH] Update index.js --- index.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/index.js b/index.js index 8252cee..6518520 100644 --- a/index.js +++ b/index.js @@ -614,9 +614,7 @@ function createGamepadAgent(gamepadNum) { let axisValGamepad = convertUnitFloatToByte(gamepad.axes[i]) axisValueElements[i].textContent = axisValGamepad let percentage = Math.round((gamepad.axes[i] + 1) * (100 / 2)) - if(gamepadNum==0){ - barElements[i].style.background = `linear-gradient(to right, var(--alf-green) ${percentage}%, grey 0%)`; - } + barElements[i].style.background = `linear-gradient(to right, var(--alf-green) ${percentage}%, grey 0%)`; axisArray[i] = axisValGamepad } } else { @@ -634,26 +632,19 @@ function createGamepadAgent(gamepadNum) { for (let i = 0; i < 8; i++) { if (gamepad.buttons[i].pressed) { firstByte |= (gamepad.buttons[i].pressed << i); - if(gamepadNum==0){ - buttonElements[i].style.background = 'var(--alf-green)'; - } + buttonElements[i].style.background = 'var(--alf-green)'; + } else { - if(gamepadNum==0){ - buttonElements[i].style.background = 'grey'; - } + buttonElements[i].style.background = 'grey'; } } for (let i = 8; i < 16; i++) { if (gamepad.buttons[i].pressed) { secondByte |= (gamepad.buttons[i].pressed << i - 8); - if(gamepadNum==0){ - buttonElements[i].style.background = 'var(--alf-green)'; - } + buttonElements[i].style.background = 'var(--alf-green)'; } else { - if(gamepadNum==0){ - buttonElements[i].style.background = 'grey'; - } + buttonElements[i].style.background = 'grey'; } } }