[SDL] Help with keyboard input

Started by
1 comment, last by zeeli 14 years, 1 month ago
Hi. I'm currently writing an SDL input adapter for my game. This game of mine can be compiled to use either NCurses or SDL. The NCurses adapter is simple, it just returns exactly what getch() returns(an integer in range of 0-255). My plan is the make the SDL adapter perform identically with the Ncurses one. The InputAdapter interface looks roughly like this:

class InputAdapter {
public:
    virtual int input() = 0; //Wait until key is pressed and return ascii keycode
};

class NCursesInputAdapter : public InputAdapter {
public:
    int input() {
        return getch();
    }
};


Do you have any pointers or tips on how to implement the SDL part? for example, how do I get ^A-^Z (that is, CTRL + A-Z (ascii 1-26)) with SDL? I apologize for such a novice question, but the SDL documentation sucks a bit and it's always nice to hear if someone has tackled similar issues in the past. Best regards, zEeLi
Advertisement
You should check these links:
SDLKey
SDL_GetModState
SDL_GetKeyState
Quote:Original post by Haytal
You should check these links:
SDLKey
SDL_GetModState
SDL_GetKeyState


Thanks dude! Those seem excactly what I've been looking for.

This topic is closed to new replies.

Advertisement