Skip to content

Port keymapper to SDL renderer #2763

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

Merged
merged 4 commits into from
Aug 15, 2023
Merged

Port keymapper to SDL renderer #2763

merged 4 commits into from
Aug 15, 2023

Conversation

GranMinigun
Copy link
Contributor

@GranMinigun GranMinigun commented Aug 15, 2023

Does what it says: moves mapper from software surface to SDL's rendering API. The emulator window is now reused instead of creating a new one.

If you're not happy with the mapper's pseudo-lambdas and how they're formatted, you're welcome to steal this branch. These changes would go far beyond the scope of the PR though, and the whole thing will be eventually rewritten anyway, hence why I'm leaving it as is.

While it seems to work with the surface output, this is not intentional, and it will be removed in a subsequent PR anyway. (Damn, that sounds broken...)

Extracted from - and is a prerequisite to - #2450. Closes #2237.

@GranMinigun GranMinigun self-assigned this Aug 15, 2023
@kcgen kcgen added plumbing Issues related to low-level support functions and classes refactoring Code refactoring without any functional changes labels Aug 15, 2023
Window reusing is done in a hackish way, adding new renderers will break
the mapper. Handle with care.
@kcgen
Copy link
Member

kcgen commented Aug 15, 2023

Awesome overhaul and function improvement.

  • De-Bitu
  • #define constants to constexpr; now we can see variables in debuggers and not literals
  • #define functions to lamdas: now we can get valid backtraces

The functional chunks of code are made more readable.

Copy link
Member

@johnnovak johnnovak left a comment

Choose a reason for hiding this comment

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

Good stuff @GranMinigun! These changes improve readability a lot too. 🎉

No comments from me as the days of the old mapper are numbered, like you mentioned. We only need to keep it limping along for a bit longer. In a way it got a lot more love from you than it deserves 😎

(On a related note, glad to see you returning to our circles, man. I've been missing you, your graphics pipeline related insights, and the snarky remarks 😎🤘🏻 )

@kcgen
Copy link
Member

kcgen commented Aug 15, 2023

@GranMinigun "Sanitizers seem to be happy here"

👍

Scaling perfectly to various DPIs on Linux and macOS:

mapper

@kcgen kcgen merged commit e410259 into main Aug 15, 2023
@johnnovak
Copy link
Member

johnnovak commented Aug 15, 2023

@GranMinigun @kcgen Ok, that merging was a bit premature, so it seems.

I can open the mapper fine on macOS and the coordinate mappings work fine, so it's fully functional. But the Exit button does not hide it, so once opened, I'm stuck with it.

@johnnovak
Copy link
Member

Shall I create a regression ticket for this @GranMinigun or are looking into it? This broke the mapper in main at least on macOS.

@GranMinigun
Copy link
Contributor Author

I'm not sure how you're unable to exit from the mapper. Definitely cannot reproduce here. No need for a separate ticket, it can be discussed here.

@johnnovak
Copy link
Member

johnnovak commented Aug 16, 2023

I'm not sure how you're unable to exit from the mapper. Definitely cannot reproduce here. No need for a separate ticket, it can be discussed here.

In OpenGL output modes if I click on Exit, the mapper never disappears. That's it, plain and simple! 😄 Switching to fullscreen then back to windowed doesn't fix it, changing the window size doesn't fix it, nothing fixes it. The mapper screen never disappears, and the Exit button stays higlighted:

image

The emulator keeps working though. So I'm a sneaky bastard and I'm typing output = texture in the console, completely blind, then lo and behold:

image

So somehow the Exit button press never triggers the "hide mapper" event or something.

If I use output = texture, it works fine; Exit closes the mapper.

@johnnovak
Copy link
Member

johnnovak commented Aug 16, 2023

@GranMinigun Works fine on Windows 10 🥶 SDL... 😐

This is a bit of a problem because you don't have a Mac... I guess it will be @kklobe, @kcgen or myself who fixes it.

Any suggestions are welcome. I've done some quick tracing, and render_reset() does get callled after exiting the mapper. Just that Rube Goldberg machine from hell that is sdlmain pokes SDL slightly the wrong way on macOS... I guess... Or maybe it pokes it the same way on all three platforms, but macOS needs a bit of "special poking". 😅 Sheeeet.

@kcgen
Copy link
Member

kcgen commented Aug 16, 2023

Sorry for merging too soon. Been offline, but will check it out tomorrow and see what you think, @GranMinigun.

@GranMinigun
Copy link
Contributor Author

Two things to check: whether other renderer backends work (e.g. texture_renderer=opengl and others); and whether context variable gets populated properly and is still valid by the time it is made current.

@kcgen
Copy link
Member

kcgen commented Aug 16, 2023

Two things to check: whether other renderer backends work (e.g. texture_renderer=opengl and others)

That's it @GranMinigun; results from macos:

This exits the mapper properly:

output = opengl
texture_renderer = opengl

These also exit properly:

output = texture
texture_renderer = (all: metal, software, opengles2, opengl)

However these don't:

output = opengl
texture_renderer = metal, opengles2, or software

The context is always getting populated.

@GranMinigun
Copy link
Contributor Author

Alright, I see software renderer outright crashes on my side. Will think about what to do and raise a follow-up PR.

@kcgen kcgen deleted the gm/sdl-mapper-1 branch August 25, 2023 00:07
@johnnovak johnnovak added the enhancement New feature or enhancement of existing features label Nov 13, 2023
@johnnovak johnnovak added the input handling Issues related to handling any input (keyboard, mouse, joystick & game controllers) label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement of existing features input handling Issues related to handling any input (keyboard, mouse, joystick & game controllers) plumbing Issues related to low-level support functions and classes refactoring Code refactoring without any functional changes
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Mapping Tool Not Scaling Correctly
3 participants