From 9dd2cd5ea44738638529ee1bc46bf12c375c7b2c Mon Sep 17 00:00:00 2001 From: vishalrao8 Date: Sun, 13 Sep 2026 04:15:16 +0530 Subject: [PATCH] fix(settings): fix controller indexing and detection in input settings - Convert navigator.getGamepads() to an array and filter by connected gamepads - Render up to 4 controller slots with fallback when no controllers are connected --- .../desktop/renderer/pages/settings/input.tsx | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/desktop/renderer/pages/settings/input.tsx b/packages/desktop/renderer/pages/settings/input.tsx index 30c061a5e..ad068d608 100644 --- a/packages/desktop/renderer/pages/settings/input.tsx +++ b/packages/desktop/renderer/pages/settings/input.tsx @@ -202,18 +202,26 @@ function SettingsInput() {
{ - navigator.getGamepads().map((item, index) => { - return ( -

- #{ index+1 }   - - { (item) ? - item.id + ' ' + t('settings.input.axesLabel') + ': ' + item.axes.length + ', ' + t('settings.input.buttonsLabel') + ': ' + item.buttons.length + ', ' + t('settings.input.rumbleLabel') + ': ' + ((item.vibrationActuator !== null) ? (item.vibrationActuator as any).type : t('settings.input.notSupportedLabel')) - : t('settings.input.noControllerDetected') - } -

- ) - }) + (() => { + const connectedGamepads = Array.from(navigator.getGamepads()).filter((item) => item?.connected) + + if (connectedGamepads.length === 0) { + return

{t('settings.input.noControllerDetected')}

+ } + + return [0, 1, 2, 3].map((slot) => { + const item = connectedGamepads[slot] + return ( +

+ #{ slot + 1 }   + { (item) ? + item.id + ' ' + t('settings.input.axesLabel') + ': ' + item.axes.length + ', ' + t('settings.input.buttonsLabel') + ': ' + item.buttons.length + ', ' + t('settings.input.rumbleLabel') + ': ' + ((item.vibrationActuator !== null) ? (item.vibrationActuator as any).type : t('settings.input.notSupportedLabel')) + : t('settings.input.noControllerDetected') + } +

+ ) + }) + })() }