mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-03 16:25:54 +00:00
Allow to specify gamepad GUIDs to be ignored when streaming
This commit is contained in:
parent
d165bf7498
commit
85d4037a89
@ -474,6 +474,17 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||||||
return;
|
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];
|
state = &m_GamepadState[i];
|
||||||
if (m_MultiController) {
|
if (m_MultiController) {
|
||||||
state->index = i;
|
state->index = i;
|
||||||
@ -534,15 +545,18 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_JoystickGetGUIDString(SDL_JoystickGetGUID(SDL_GameControllerGetJoystick(state->controller)),
|
|
||||||
guidStr, sizeof(guidStr));
|
|
||||||
mapping = SDL_GameControllerMapping(state->controller);
|
mapping = SDL_GameControllerMapping(state->controller);
|
||||||
name = SDL_GameControllerName(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,
|
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,
|
i,
|
||||||
state->index,
|
state->index,
|
||||||
name != nullptr ? name : "<null>",
|
name != nullptr ? name : "<null>",
|
||||||
|
vendorId,
|
||||||
|
productId,
|
||||||
hapticCaps,
|
hapticCaps,
|
||||||
guidStr,
|
guidStr,
|
||||||
mapping != nullptr ? mapping : "<null>");
|
mapping != nullptr ? mapping : "<null>");
|
||||||
@ -888,7 +902,14 @@ int SdlInputHandler::getAttachedGamepadMask()
|
|||||||
count = mask = 0;
|
count = mask = 0;
|
||||||
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
for (int i = 0; i < SDL_NumJoysticks(); i++) {
|
||||||
if (SDL_IsGameController(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++);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,6 +130,16 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i
|
|||||||
}
|
}
|
||||||
streamIgnoreDevices += m_OldIgnoreDevices;
|
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:
|
||||||
|
//
|
||||||
|
// <GUID>,<GUID>,<GUID>,...
|
||||||
|
//
|
||||||
|
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
|
// 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
|
// and STREAM_GAMECONTROLLER_IGNORE_DEVICES while streaming. STREAM_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT
|
||||||
// overrides SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT while streaming.
|
// overrides SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT while streaming.
|
||||||
|
@ -179,6 +179,7 @@ private:
|
|||||||
bool m_FakeCaptureActive;
|
bool m_FakeCaptureActive;
|
||||||
QString m_OldIgnoreDevices;
|
QString m_OldIgnoreDevices;
|
||||||
QString m_OldIgnoreDevicesExcept;
|
QString m_OldIgnoreDevicesExcept;
|
||||||
|
QStringList m_IgnoreDeviceGuids;
|
||||||
StreamingPreferences::CaptureSysKeysMode m_CaptureSystemKeysMode;
|
StreamingPreferences::CaptureSysKeysMode m_CaptureSystemKeysMode;
|
||||||
int m_MouseCursorCapturedVisibilityState;
|
int m_MouseCursorCapturedVisibilityState;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user