• Advertisement
Sign in to follow this  

Oddly behaving SDL keyboard stuff

This topic is 4710 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Some key combinations (up to 5 keys in some cases) work fine and all keys function properly, but other key combinations (as few as 3) lock up and prevent further keypresses until they are released. I am using the following code to check keyboard events:
int key[323];
void inputinit() {
    int i;
    for (i=0;i<323;i++) {
        key=0;
    }
}
void pollkeyboard() {
    SDL_Event event;
    while(SDL_PollEvent(&event)) {          //whilst there are events in the queue
        switch(event.type) {       
            case SDL_KEYDOWN:               //check for keydown
                key[event.key.keysym.sym]=1;
                break;
            case SDL_KEYUP:
                key[event.key.keysym.sym]=0;
                break;
            case SDL_QUIT:
                running=0;
        }
    }
}

Ideas anyone?

Share this post


Link to post
Share on other sites
Advertisement
That's not a SDL problem, that's a keyboard problem. Keyboards are not designed for multiple keys being held down (other than the shift/alt/ctrl/etc keys), so they use a wiring system that doesn't allow all key combinations to be used
(it saves on wires, and makes the design simpler)

All I can say is "Don't use that key combo in your game" :(

Share this post


Link to post
Share on other sites
:'(

I just discovered that about 5 mins before you posted. Thanks for responding anyway! I just need to find some better key combinations now.

Share this post


Link to post
Share on other sites
So how do so many games manage to have 2 players on a keyboard? I've tried changing the mappings loads of times but keys are still locking each other out. It's very bizarre. Liero, for example, uses 7 keys per player and 2 on a keyboard with no apparent lockouts at all, but when I use mapping as similar as I can to Liero's, I still see problems.

Share this post


Link to post
Share on other sites
Typically, two-player-one-keyboard games don't use 3+ key combinations per player. A standard PC keyboard typically only allows for 4 or 5 simultaneous key presses.

As to some key combinations locking out the keyboard, it could be that those key combinations are platform specific. For example, on unix with the terminial in "cooked" mode, Ctrl-S will lock out keyboard input until Ctrl-Q (i think) is pressed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement