nesbox / TIC-80

TIC-80 is a fantasy computer for making, playing and sharing tiny games.
https://tic80.com
MIT License
5.05k stars 491 forks source link

ESC key for switching to editor or opening menu is unreliable with Kinesis Advantage II keyboard #2467

Open bryce-carson opened 9 months ago

bryce-carson commented 9 months ago

I am not sure why it would be an issue with this application alone (my escape key is recognized every press in Emacs and elsewhere), but when I am running a game and I press ESC it is often not recognized. I need to spam the key until it is picked up by TIC-80.

This does not occur with a BTC PS/2 keyboard I have, and that keyboard's ESC key is recognized no differently in Emacs than the ESC key on my Kinesis.

I rebuilt TIC-80 with a new case in src/system/sdl/player.c, and I'm not sure if that was the correct thing to do or if it made a difference. I also rebuilt it with the Pro version enabled. I have had development mode enabled.

diff --git a/src/system/sdl/player.c b/src/system/sdl/player.c
index bb3702f8..68b2b2d1 100644
--- a/src/system/sdl/player.c
+++ b/src/system/sdl/player.c
@@ -137,6 +137,7 @@ s32 runCart(void* cart, s32 size)
                     state.quit = true;
                     break;
                 case SDL_KEYUP:
+               case SDL_KEYDOWN:
                     // Quit when pressing the escape button.
                     if(event.key.keysym.sym == SDLK_ESCAPE)
                     {

I just discovered with my current build, and settings, whatever the combination is that I can press F1-F5 while the game is running and be taken directly to the editor I want (which is preferable).

Let me know if you want a configuration file or any other information. I can help troubleshoot the issue, I'm just not sure how at the moment.

bryce-carson commented 9 months ago

It would also be nice to have TIC-80 be a little "Emacs-like" and have a configuration file in any one of the supported scripting languages to control keybindings for the editor itself. A configuration or editor API, to control how TIC-80 behaves, would be nice. I think in this case, if an editor keybinding is shadowed an unbound key should be automatically set for the shadowed behaviour, and a warning displayed when running the game (for that run only).

Skeptim commented 9 months ago

Note that there is an Emacs keybind mode that one can turn on in the menu.

bryce-carson commented 9 months ago

Note that there is an Emacs keybind mode that one can turn on in the menu.

Yes, I did try that and the Vi emulation to see how well they were supported. One thing I noted is that the Emacs keybindings only work with the left control and alt keys, which is uncomfortable for commands like forward-word (M-f). I'll open an new issue for that.

Otherwise, my suggestion regarding "Emacs-like" programming API was specifically in regard to being extensible with user code, not the keyboard shortcuts. For instance, if I want to focus on some function perhaps I want to hide display of all other functions in the source code and "narrow" the text buffer to a given region until I decide to "widen" the buffer display again. Such a behaviour could be controlled through an extensive programming API, but that would just be turning TIC-80 into Emacs, I guess.

I can just use an external editor if I really, really miss all my Emacs niceties (who wouldn't?).