mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2025-07-01 07:15:27 +00:00
Allow game controllers to be ignored during streaming only
STREAM_GAMECONTROLLER_IGNORE_DEVICES and STREAM_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT environment variables provide the same functionality as SDL_GAMECONTROLLER_IGNORE_DEVICES and SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, with the difference being SDL_* variables take effect at all times (UI and streaming) while STREAM_* variables take place only while streaming. Fixes #425
This commit is contained in:
parent
5a7a49d1d5
commit
eded86bc10
@ -63,6 +63,23 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1");
|
||||
#endif
|
||||
|
||||
m_OldIgnoreDevices = SDL_GetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES);
|
||||
m_OldIgnoreDevicesExcept = SDL_GetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT);
|
||||
|
||||
QString streamIgnoreDevices = qgetenv("STREAM_GAMECONTROLLER_IGNORE_DEVICES");
|
||||
QString streamIgnoreDevicesExcept = qgetenv("STREAM_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT");
|
||||
|
||||
if (!streamIgnoreDevices.isEmpty() && !streamIgnoreDevices.endsWith(',')) {
|
||||
streamIgnoreDevices += ',';
|
||||
}
|
||||
streamIgnoreDevices += m_OldIgnoreDevices;
|
||||
|
||||
// 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.
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, streamIgnoreDevices.toUtf8());
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, streamIgnoreDevicesExcept.toUtf8());
|
||||
|
||||
// We must initialize joystick explicitly before gamecontroller in order
|
||||
// to ensure we receive gamecontroller attach events for gamepads where
|
||||
// SDL doesn't have a built-in mapping. By starting joystick first, we
|
||||
@ -167,6 +184,10 @@ SdlInputHandler::~SdlInputHandler()
|
||||
// Return background event handling to off
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "0");
|
||||
|
||||
// Restore the ignored devices
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES, m_OldIgnoreDevices.toUtf8());
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT, m_OldIgnoreDevicesExcept.toUtf8());
|
||||
|
||||
#ifdef STEAM_LINK
|
||||
// Hide SDL's cursor on Steam Link after quitting the stream.
|
||||
// FIXME: We should also do this for other situations where SDL
|
||||
|
@ -135,6 +135,8 @@ private:
|
||||
GamepadState m_GamepadState[MAX_GAMEPADS];
|
||||
QSet<short> m_KeysDown;
|
||||
bool m_FakeCaptureActive;
|
||||
QString m_OldIgnoreDevices;
|
||||
QString m_OldIgnoreDevicesExcept;
|
||||
|
||||
SDL_TouchFingerEvent m_LastTouchDownEvent;
|
||||
SDL_TouchFingerEvent m_LastTouchUpEvent;
|
||||
|
Loading…
x
Reference in New Issue
Block a user