diff --git a/app/streaming/input/gamepad.cpp b/app/streaming/input/gamepad.cpp index 8c597f17..dbdbf419 100644 --- a/app/streaming/input/gamepad.cpp +++ b/app/streaming/input/gamepad.cpp @@ -474,6 +474,17 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve return; } + SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(controller)), + guidStr, sizeof(guidStr)); + if (m_IgnoreDeviceGuids.contains(guidStr, Qt::CaseInsensitive)) + { + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, + "Skipping ignored device with GUID: %s", + guidStr); + SDL_GameControllerClose(controller); + return; + } + state = &m_GamepadState[i]; if (m_MultiController) { state->index = i; @@ -534,15 +545,18 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve } #endif - SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(state->controller)), - guidStr, sizeof(guidStr)); mapping = SDL_GameControllerMapping(state->controller); name = SDL_GameControllerName(state->controller); + + uint16_t vendorId = SDL_GameControllerGetVendor(state->controller); + uint16_t productId = SDL_GameControllerGetProduct(state->controller); SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Gamepad %d (player %d) is: %s (haptic capabilities: 0x%x) (mapping: %s -> %s)", + "Gamepad %d (player %d) is: %s (VID/PID: 0x%.4x/0x%.4x) (haptic capabilities: 0x%x) (mapping: %s -> %s)", i, state->index, name != nullptr ? name : "", + vendorId, + productId, hapticCaps, guidStr, mapping != nullptr ? mapping : ""); @@ -888,7 +902,14 @@ int SdlInputHandler::getAttachedGamepadMask() count = mask = 0; for (int i = 0; i < SDL_NumJoysticks(); i++) { if (SDL_IsGameController(i)) { - mask |= (1 << count++); + char guidStr[33]; + SDL_JoystickGetGUIDString(SDL_JoystickGetDeviceGUID(i), + guidStr, sizeof(guidStr)); + + if (!m_IgnoreDeviceGuids.contains(guidStr, Qt::CaseInsensitive)) + { + mask |= (1 << count++); + } } } diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index 6d41d4f6..a28b2c9a 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -130,6 +130,16 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i } streamIgnoreDevices += m_OldIgnoreDevices; + // STREAM_IGNORE_DEVICE_GUIDS allows to specify additional devices to be ignored when starting + // the stream in case the scope of STREAM_GAMECONTROLLER_IGNORE_DEVICES is too broad. One such + // case is "Steam Virtual Gamepad" where everything is under the same VID/PID, but different GUIDs. + // Multiple GUIDs can be provided, but need to be separated by commas: + // + // ,,,... + // + QString streamIgnoreDeviceGuids = qgetenv("STREAM_IGNORE_DEVICE_GUIDS"); + m_IgnoreDeviceGuids = streamIgnoreDeviceGuids.split(',', Qt::SkipEmptyParts); + // For SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, we use the union of SDL_GAMECONTROLLER_IGNORE_DEVICES // and STREAM_GAMECONTROLLER_IGNORE_DEVICES while streaming. STREAM_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT // overrides SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT while streaming. diff --git a/app/streaming/input/input.h b/app/streaming/input/input.h index eb638902..7799071c 100644 --- a/app/streaming/input/input.h +++ b/app/streaming/input/input.h @@ -179,6 +179,7 @@ private: bool m_FakeCaptureActive; QString m_OldIgnoreDevices; QString m_OldIgnoreDevicesExcept; + QStringList m_IgnoreDeviceGuids; StreamingPreferences::CaptureSysKeysMode m_CaptureSystemKeysMode; int m_MouseCursorCapturedVisibilityState;