Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDL3 : WIP #1182

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

SDL3 : WIP #1182

wants to merge 1 commit into from

Conversation

boberfly
Copy link

Hello,

I went on an adventure to port moonlight-qt to SDL3. Now SDL3 isn't stable yet so I don't expect this to be merged anytime soon, however I put this PR up so it is known that this has been done and there isn't any duplicated efforts.

SDL2 is still supported with a lot of pre-processor checks. Linux-only on Wayland/X11 for now until other platforms are tested. I've made a best-effort conversion for the other platforms kmsdrm/EGL, windows/win32 but left macOS video decode alone, looks like that code is being worked upon right now.

Audio was a rewrite so this one needs checking with care to see if I'm doing the right thing.

My ultimate goal is to use the new SDL_pen.h API so I'll be working on this next.

Cheers, I'll set to draft and continue to force-push things as I discover them and do some testing.

@boberfly boberfly force-pushed the SDL3 branch 3 times, most recently from 8b1de99 to 4d86a06 Compare February 12, 2024 12:00
Copy link

@icculus icculus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As requested on Twitter, I took a super-fast look at this (up to the gamepad parts) to provide feedback on the SDL3 integration details. If this was helpful/interesting, I can do a more thorough examination later on.

@@ -30,13 34,19 @@ Uint32 SdlInputHandler::longPressTimerCallback(Uint32, void*)

void SdlInputHandler::disableTouchFeedback()
{
#ifdef Q_OS_WIN32
#if SDL_VERSION_ATLEAST(3, 0, 0)
if (SDL_strcmp(SDL_GetCurrentVideoDriver(), "win32") == 0) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"windows" not "win32"

#if SDL_VERSION_ATLEAST(3, 0, 0)
if (m_AudioStream) {
// Stop and destroy audio stream
SDL_PauseAudioDevice(SDL_GetAudioStreamDevice(m_AudioStream));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These can be SDL_PauseAudioStreamDevice to cut out the SDL_GetAudioStreamDevice call. There's an equivalent SDL_ResumeAudioStreamDevice, too, for elsewhere.

While one does need to resume to get a device from SDL_OpenAudioDeviceStream moving, pausing it before destroying the stream isn't necessary; it will halt playback just the same.

@@ -102,7 151,11 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)
{
// Our device may enter a permanent error status upon removal, so we need
// to recreate the audio device to pick up the new default audio device.
#if SDL_VERSION_ATLEAST(3, 0, 0)
if (SDL_AudioDevicePaused(SDL_GetAudioStreamDevice(m_AudioStream))) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just realized we never added a stream-specific equivalent of SDL_AudioDevicePaused (whoops!), so for now at least, this part does need to call SDL_GetAudioStreamDevice().

@@ -119,11 172,22 @@ bool SdlAudioRenderer::submitAudio(int bytesWritten)

// Provide backpressure on the queue to ensure too many frames don't build up
// in SDL's audio queue.
#if SDL_VERSION_ATLEAST(3, 0, 0)
// TODO: Check to see if this is correct and doing what SDL2 was doing.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This roughly matches SDL2, so this TODO can be removed.


// SDL will report "pen" as the name of pen input devices on Windows.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual pen support (using Windows Ink for now, WinTab support coming later) just landed in SDL3, so if you want actual pens and not touches, you should look for SDL_EVENT_PEN_* events.

Pens are a mess; in most cases we should be able to tell you all sorts of stuff about the hardware that's available, but most operating systems just sort of surprise you with the presence of a pen when it starts sending input events about it, and won't tell you anything about the pen's abilities. As such, we built SDL's pen support to match that. Take a look at the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants