Skip to content

Conversation

@pavelmachek
Copy link
Contributor

I find SDL support in Espruino useful. And it would be even more useful if it has input ... so I did that. I'm now using it for developing applications for Bangle.js2 without hardware and without emulator, and it is rather useful.

It now generates "touch" event on E, so should be compatible with other hardware.

@gfwilliams
Copy link
Member

Looks great, thanks! Please can you just remove the fflush(stdout); line and I'll merge this?

@pavelmachek
Copy link
Contributor Author

Sorry, debugging leftover. It should be fixed now.

I would like to handle "window close" event from sdl. Can I just exit(0) from C or should I do something more complex. Would it make sense to add keyboard handling?

@gfwilliams
Copy link
Member

Can I just exit(0) from C or should I do something more complex.

Since this is for Linux only you could do:

void nativeQuit();
nativeQuit();

Which basically causes it to quit loopin and exit nicely: https://github.com/espruino/Espruino/blob/master/targets/linux/main.c#L564-L566

Would it make sense to add keyboard handling?

You could add jshPushIOCharEvent(EV_USBSERIAL, (char)ch); for each typed key - so that it goes to the console as if the terminal window had focus?

I don't think going further really helps as it's not something exposed on other platforms - so it wouldn't be any good for emulating/etc

@pavelmachek
Copy link
Contributor Author

Ok, thanks for the hints. I added quit handling as suggested.

I guess translating keyboard between sdl and serial would not be trivial, lets postpone that for now. (SDL sees left arrow but serial expects escape sequence... etc.)

@gfwilliams
Copy link
Member

Ok, thanks! This all looks good then - just merging!

@gfwilliams gfwilliams merged commit 7345ea6 into espruino:master Jan 16, 2025
21 checks passed
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