Sign in to follow this  

[SDL] Help with keyboard input

Recommended Posts

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 {
    virtual int input() = 0; //Wait until key is pressed and return ascii keycode

class NCursesInputAdapter : public InputAdapter {
    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

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this