开发者

SDL and aalib: No SDL_KEYUP event?

I have my small project in which I use SDL, and I was playing around with the different available drivers. I came across the aalib driver, and I realized the SDL_KEYUP event was never called.

This, however, happens only in certain conditions. The event is sent when using the X driver, however not when using in console mode (ie. using Ctrl + Alt + F1).

Here is a minimal code to test 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 with aalib:

env SDL_VIDEODRIVER=aalib ./a.out

My question is: Is this to b开发者_如何学JAVAe considered a bug? Or is it something aalib cannot know because of the console won't give this information?

If aalib cannot have this information, I find it a shame SDL cannot provide the same features for all it's drivers.

OS: FreeBSD 8.2

SDL version: 1.2.14


TTYs (such as the console) don't receive raw keyboard events at all; they only receive a single "character input" event. You may find that modifier keys (e.g, shift) don't fire SDL events at all, because there's no corresponding character sent.

This is an inherent limitation of the TTY layer. SDL isn't really to blame.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜