char key='a';
SDLKey keycode;
if (key=='a') keycode=SDLK_a;
else if (key=='b') keycode=SDLK_b;
etc.
Thanks
'a' - SDLK_a
Is there a way to convert from char values into SDLK keycodes (in SDL of course), or I have to specialcase each code? If it matters, I'm actually storing each key as a std::string.
You can probably assume they're in order. Check to make sure though. Then you could do:
if (key >= 'a' && key <= 'z') keycode = SDLK_a + (key - 'a');
and so on...
if (key >= 'a' && key <= 'z') keycode = SDLK_a + (key - 'a');
and so on...
the SDLK_* constants were made to correspond as closely as possible with the ASCII values they represent whenever they could. Check out SDL_keysym.h. If the value is less than 128, then the value is the ASCII value and needs no translation.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement