Archived

This topic is now archived and is closed to further replies.

i_npc

sdl and multiple keyboard inputs

Recommended Posts

i was wondering if sdl can take in mutliple inputs at the same time? (i.e. Press ''A'' + ''B'' then do some action)? or if sdl doesnt support that any suggestions on how i might go about doing this? tia.

Share this post


Link to post
Share on other sites
No problem:
I use
keys = SDL_GetKeyState(NULL);

with keys as
unsigned char *keys = new unsigned char[256].

Then just test(I think I can just pass the character in SDL. otherwise theres some definition e.g. SDLK_SOMETHING):
if(keys[''A''] && keys[''B''])
{
}

Share this post


Link to post
Share on other sites
Close, but not quite right. SDL_GetKeyState returns a pointer to an internal array, so there''s no need for you to allocate memory.
Uint8 *keys=SDL_GetKeyState(NULL);
http://sdldoc.csn.ul.ie/sdlgetkeystate.php

Share this post


Link to post
Share on other sites