We don't need -ffreestanding anymore, and it gets in the way of the more
complex headers in libstdc++. However, due to an LD bug regarding
re-scanning of LTO archives we still have to keep -fno-builtin. This may
be fixed in future binutils versions (I haven't tested in a while).
When loading SDL2 with pkg-config the -mwindows flag is added, which
instructs the loader to load the program through WinMain() and not
create a console for it. This is intended for GUI programs. However,
fxlink is a CLI program with just occasionally an SDL window on top of
it. Disable -mwindows to keep the console and terminal output. I don't
know how to do that with the pkg-config CMake module, so use the SDL2
module for the Windows build instead.
There is no direct replacement for poll() in the Windows API, so I'm
gonna disable the fxlink TUI for now and maybe later figure out how to
do something equivalent, even if more brute-forcey.
Previously converters had to return:
- 0 on success, having called fxconv.elf() themselves
- 1 on failure
Now they also have the (preferred option) to return:
- a bytes or ObjectData on success, without calling fxconv.elf()
- None of failure
Basically if the calculator sends two messages in a row, it is possible
for a single libusb_handle_events() to get both. And the comm structure
wasn't designed for that, because it could buffer only one message at a
time, which the user needed to read after event handling.
The comm structure now has a 16-message buffer, which should be more
than enough for any single event handling loop. On the user level this
has implications in that fxlink_device_finish_bulk_IN() must be called
*in a loop* after each event handling cycle.
Reported in https://git.planet-casio.com/Lephenixnoir/gint/pulls/27
Note that this only makes sense if there is only one .g3a in the current
folder. If both the cg and the fxg3a targets are used, this will send
both g3a files, which is a waste of time.