controller: do not send light bar colours to mono-LED pads (ASTRO BOT) #2116
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!2116
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2116/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Nawid3333 on GitHub · 2026-11-04 22:46 UTC · original
Nawid3333:fix/pad-mono-led→main· +35 −3 · 2 files · 3 commits · merged 2026-11-04 22:59 UTCSummary
ASTRO BOT (PPSA21564) drops to a few FPS while a Switch-protocol pad is connected: #1996 (8BitDo Ultimate in Switch
mode over Bluetooth: 1-2 FPS while connected, fine over USB) and #2013 (Switch Pro Controller). The light bar update
blocks every pad call on these pads. This PR skips light bar writes on pads that have only a mono LED.
Cause
PadSetLightBar holds g_router_mutex, and GameController::SetLightBar holds the pad's own mutex while it calls
SDL_SetGamepadLED (src/libs/controller.cpp). SDL's Switch HIDAPI driver reports no RGB LED: the Pro Controller and the
right Joy-Con report only SDL_JOYSTICK_CAP_MONO_LED, the HOME LED. A colour write is still mapped to the HOME LED
subcommand (SetHomeLED -> WriteSubcommand), and SDL waits for the pad's reply before returning (ReadSubcommandReply,
up to 100 ms per try, 5 tries). SDL skips only a recently sent unchanged colour. So every light bar change blocks the
calling guest thread and the other pad calls: PadRead waits for the pad's mutex (CheckPortHandle, ReadStates), and
the other output calls such as PadSetVibration wait for g_router_mutex. ASTRO BOT calls PadSetLightBar as often as
PadRead (equal counts in a gameplay trace).
Change
New helper SetLightBarColor() in src/libs/controller.cpp, used at all three SDL_SetGamepadLED call sites: the
configured colour on connect, StopHostPad, and GameController::SetLightBar. Pads that report
SDL_PROP_GAMEPAD_CAP_MONO_LED_BOOLEAN and not SDL_PROP_GAMEPAD_CAP_RGB_LED_BOOLEAN get no colour. Only SDL's Switch and
lg4ff drivers report a mono LED; the PS4/PS5 drivers report RGB and never mono, so DualSense and DualShock 4 behave as
before. The launcher's controller preview already checks CAP_RGB_LED. StopHostPad's LED-off is skipped on these pads
too: Kyty no longer writes their HOME LED at all, so there is nothing to reset.
Tests
New ControllerSettingsTests case TestMonoLedPadGetsNoLightBar. It fakes the two SDL property calls with independent
mono/RGB caps: pads with an RGB LED, with both LEDs, or with no reported LED receive the colour; a pad with only a mono
LED keeps its old colour. With controller.cpp of main the case fails ("a pad with only a mono LED received the light
bar"); with the guard changed to "skip unless RGB" it fails too ("a pad that reports no LED did not receive the light
bar"). The full ControllerSettingsTests suite passes in a local Windows build of this branch. Fork CI for the head commit is running; on the first commit it
passed on Windows and Linux (macOS got no runner).
In-game
ASTRO BOT, reporter of #1996 (Windows 11 Pro 26H2, Ryzen 9 7950X3D, Radeon RX 7900 XTX, 8BitDo Ultimate firmware
1.11 paired over Bluetooth in Switch mode), test build of this change: without it 1-2 FPS while the pad is connected;
with it 60 FPS with and without the pad connected
(#1996).
Related
#2060 also edits controller.cpp: its PadResetLightBar calls GameController::SetLightBar, which goes through
SetLightBarColor() with this change, so the reset skips mono-LED pads too. The two only meet in ControllerSettingsTests.cpp
(both add a case).
AI use: drafted with AI assistance (Claude Code); verified and tested by me.
@coderabbitai[bot] on GitHub · 2026-11-04 22:51 UTC · original
Walkthrough
The controller now checks gamepad LED capabilities before setting light-bar colors. It skips the update when a pad reports a monochrome LED but no RGB LED. Device assignment, host-pad shutdown, and the light-bar setter use the shared helper. Tests cover four combinations of monochrome and RGB capabilities.
Suggested reviewers:
nmzik,pyxellatorChange: Bug fix
Merge Risk:
Minimal · up to
36337No merge-blocking risk is established; the intended mono-only light-bar behavior is covered by the supplied tests.
Pre-merge checks:
4 ·
1
Full details: Title check
Explanation
The title names the main change: light bar colour writes are no longer sent to mono-LED pads. It also names the affected device case (ASTRO BOT). The changeset adds SetLightBarColor() in controller.cpp, which skips mono-only LED pads, and adds a test for those capability combinations. The title is specific and matches the diff summary.
Full details: Description check
Explanation
The description is related to the changeset. It explains the cause (light bar writes to Switch-protocol pads block other pad calls), describes the new SetLightBarColor() helper and its three call sites, and covers the added TestMonoLedPadGetsNoLightBar test. It also gives test results and in-game measurements. The description is detailed and on-topic.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
@coderabbitai[bot] on GitHub · 2026-11-04 22:51 UTC · original · reviewed
7dbad941-377a-4e0c-bfad-8867877ce267Reviewing files that changed from the base of the PR and between
23d0db3313and363371e17d.src/libs/controller.cpptests/ControllerSettingsTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
@Nawid3333 on GitHub · 2026-11-04 23:11 UTC · original
@Nmzik Thanks for merging this and for the cleanup. #1996 and #2013 can be closed: the reporter of #1996 got 60 FPS with the fix (8BitDo Ultimate in Switch mode over Bluetooth), and #2013 is the same Switch Pro Controller path (its reporter has not retested yet).
Is there something you'd like me to focus on? This is what I'm working on now and next:
failed to create image: extent=4096x4096x1). I'm checking whether the texture cache garbage collector gets stuck on images it can't evict, or whether something leaks.1be1c6c4freverteda358b847c, waitUntilSafeForRendering stalls the whole GPU thread again instead of only its command processor. I'll compare ASTRO BOT on 97cda2fb3, which still hasa358b847c, with current main. Do you remember what broke witha358b847c?