开发者

SDL left control keydown event is fired when key is released

So I have the following code that listens for a keydown event and then exits as soon as it receives one:

int main(int argc, char** argv) {
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Surface* screen = SDL_SetVideoMode(640, 480, 32, SDL_DOUBLEBUF开发者_Go百科);
    SDL_Event _event;
    while (1) {
        while (SDL_PollEvent(&_event)) {
            if (_event.type == SDL_KEYDOWN) {
                return 0;
            }
        }
        SDL_GL_SwapBuffers();
    }
}

When I run it, I can press any arrow key, letter, number, F1-F12... pretty much any key except for the left control key, and the program will exit instantly.

But when I press the left control key, the program doesn't exit until I release the key.

And although the example doesn't show it, pressing another key while left-control is being held down (eg ctrl+s) causes the missing control keydown event to be triggered (along with a second event that says 's' was pressed).

Is there any way to disable this strange behavior for the left-control key?

Btw, this is on Windows using mingw. I haven't tested this behavior with any other compilers/operating systems.


So it turns out that I had forgotten to put sdl.dll into the same directory as my executable. It was loading some other sdl.dll that happened to be on the path environment variable. I put the sdl.dll that matched the version I was compiling against (1.2.14) into my application's directory, and it works fine now.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜