Jump to content
  • Advertisement
Sign in to follow this  

[SDL] Help with keyboard input

This topic is 3200 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

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!