SDL and aalib: No SDL_KEYUP event?

I have my small project in which I use SDL, and I played with various available drivers. I came across the aalib driver, and I realized that the SDL_KEYUP event was never raised.

This, however, only occurs under certain conditions. The event is dispatched when using the X-driver, but not when used in console mode (for example, using Ctrl + Alt + F1).

Here is the minimal code to verify this:

#include <SDL/SDL.h> #include <stdio.h> int main() { SDL_Init(0); SDL_SetVideoMode(64, 64, 32, SDL_SWSURFACE); while(1) { SDL_Event event; while(SDL_PollEvent(&event)) { if(event.type == SDL_KEYDOWN) printf("Key down: %d\n", event.key.keysym.sym); else if(event.type == SDL_KEYUP) printf("Key up: %d\n", event.key.keysym.sym); else if(event.type == SDL_QUIT) SDL_Quit(); } } } 

Then, to run it using aalib:

 env SDL_VIDEODRIVER=aalib ./a.out 

My question is: is this considered a mistake? Or is this something aalib cannot know because the console will not give this information?

If aalib cannot get this information, I feel ashamed that the SDL cannot provide the same functions for all drivers.

OS: FreeBSD 8.2

SDL Version: 1.2.14

+6
source share
1 answer

TTYs (like the console) do not receive raw keyboard events at all; they receive only one character input event. You may find that modifier keys (such as a shift) do not fire SDL events at all, because the corresponding character is not sent.

This is an inherent limitation of the TTY level. SDL is not really to blame.

+4
source

Source: https://habr.com/ru/post/897940/


All Articles