edgetx icon indicating copy to clipboard operation
edgetx copied to clipboard

refactor(simu): use SDL & ImGui

Open raphaelcoeffic opened this issue 7 months ago • 6 comments

This is a refactor of the good old simu that now uses only SDL & ImGui (fetched via CMake). On macOS, this does not require XQuartz anymore. The simulated screen scales automatically with the window size.

raphaelcoeffic avatar May 10 '25 09:05 raphaelcoeffic

The function switches I recently added to the simu are missing from this variant

Yeah, sorry, that’s really for now just a simple rebase of what I had since a long time. I can add them later.

raphaelcoeffic avatar May 10 '25 11:05 raphaelcoeffic

Looks very nice, I miss the CFS too, but other than that works fine on MacOSX Sequoia

3djc avatar May 13 '25 11:05 3djc

Issues:

  • build fails for radios without function switches (tx16s)
  • function switch buttons are invisible for radios without LEDs (t15)

philmoz avatar May 13 '25 22:05 philmoz

build fails for radios without function switches (tx16s) function switch buttons are invisible for radios without LEDs (t15)

Both fixed. I improved the visuals a bit more, and switching to dark/light mode should work properly as well (d/l keys).

raphaelcoeffic avatar May 14 '25 08:05 raphaelcoeffic

C'est comme les Kinder : Bueno !

3djc avatar May 14 '25 09:05 3djc

Hm ... hoping this will go away when we finally jump to Ubuntu 22.04 for the build container, else will now need to manually build/install libSDL2 in order to use simu ... either that, or add it to the build container ...

/workspaces/edgetx/build-tx16s/native/radio/src/targets/simu/imgui/backends/imgui_impl_sdlrenderer2.cpp:50:2: error: #error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function 50 | #error This backend requires SDL 2.0.17+ because of SDL_RenderGeometry() function | ^~~~~

libsdl2-2.0-0 is already the newest version (2.0.10+dfsg1-3).

On Linux Mint, running VSCode devcontainer, moving the simu window makes the window go nuts - I think it is trying to auto-resize and gets it wrong in a big way? I've not tried yet on Windows via WSL2 so will be interesting to see if that behaves the same, or actually works now... :open_mouth: Plus not every screen is a Retina screen, so the screen sizing is a bit big ;)

https://youtu.be/KEcgpNYAU0Y

pfeerick avatar Jun 17 '25 04:06 pfeerick

either that, or add it to the build container

Here it is: https://github.com/EdgeTX/build-edgetx/pull/30

On Linux Mint, running VSCode devcontainer, moving the simu window makes the window go nuts - I think it is trying to auto-resize and gets it wrong in a big way?

~~Ok, I'll try to find out what's going wrong.~~ Window resize is a big pain with SDL2...

It seems I cannot run simu via remote X... which makes sense since it uses the OpenGL renderer on Linux... I might have to tweak something. Running this on Windows via WSL2 might be tricky as well. I might need some software rendering fallback.

raphaelcoeffic avatar Jul 10 '25 10:07 raphaelcoeffic

@pfeerick could you try commenting out this block?

Screenshot 2025-07-10 at 15 45 06

Edit: seems it might really have been because of the minimum size. I pushed something that might fix it.

raphaelcoeffic avatar Jul 10 '25 13:07 raphaelcoeffic

Moving the window no longer results in simu having a mild seizure :) UI is still double resolution on non-ultrahigh DPI resolutions, but I can at least resize the window to fix that now also. And new build container just worked.

Running on Windows via WSL2/WSLg "worked" (which it hasn't done for quite a while) but seems to have some issues with timing... it sort of does and doesn't register mouse input as input. Given this hasn't worked properly for me for a while now, I'm not overly fussed about that working right now. i.e. if it works fine for you on macOS also, so just let me know when you're finished with this for now... ;)

pfeerick avatar Jul 11 '25 02:07 pfeerick

UI is still double resolution on non-ultrahigh DPI resolutions, but I can at least resize the window to fix that now also. And new build container just worked.

Like how big on you screen? It is meant to be big enough :-D (800 x 600 is the default size)

According to the SDL docs, SDL_WINDOW_ALLOW_HIGHDPI will only lead to a higher resolution on platforms that support it.

if it works fine for you on macOS also, so just let me know when you're finished with this for now... ;)

I even managed to make it work over X11-forwarding with simu running on an Intel NUC running Linux, and XQuartz on my Mac. Apart from being slow, it just works.

raphaelcoeffic avatar Jul 11 '25 13:07 raphaelcoeffic