launcher: configure and preview DualSense lightbar color (#912)

launcher: configure and preview controller lightbar color

Add an optional lightbar color to launcher settings and pass it to the emulator with --controller-color. Preview changes on RGB gamepads, handle controller hotplug events, and restore the saved color when settings dialogs close. Release launcher preview handles when starting a game.

Co-authored-by: m66401970-eng <m66401970@gmail.com>
This commit is contained in:
Pyxellator
2026-09-29 22:46:44 +02:00
committed by GitHub
parent af4edc2865
commit 05057c9441
13 changed files with 255 additions and 8 deletions
+8
View File
@@ -297,6 +297,9 @@ void GameController::Connect(int id) {
if (id != HOST_INPUT_CONTROLLER_ID) {
if (auto* pad = SDL_GetGamepadFromID(static_cast<SDL_JoystickID>(id));
pad != nullptr) {
if (const auto& color = Config::GetControllerColor()) {
(void)SDL_SetGamepadLED(pad, (*color)[0], (*color)[1], (*color)[2]);
}
for (auto sensor: {SDL_SENSOR_ACCEL, SDL_SENSOR_GYRO}) {
if (SDL_GamepadHasSensor(pad, sensor) &&
!SDL_SetGamepadSensorEnabled(pad, sensor, true)) {
@@ -581,6 +584,11 @@ int GameController::GetActiveControllerId() {
void GameController::SetLightBar(uint8_t r, uint8_t g, uint8_t b) {
Common::LockGuard lock(m_mutex);
if (const auto& color = Config::GetControllerColor()) {
r = (*color)[0];
g = (*color)[1];
b = (*color)[2];
}
if (auto* pad = SDL_GetGamepadFromID(static_cast<SDL_JoystickID>(m_active_id));
pad != nullptr) {
(void)SDL_SetGamepadLED(pad, r, g, b);