Title: SDL and Key Trapping Post by: Nathan1993 on February 08, 2005, 05:48:05 PM please, point me to where I can learn key trapping and sdl. if you want me to look at code please comment it! :lol:
Title: SDL and Key Trapping Post by: na_th_an on February 08, 2005, 06:14:08 PM This is the best source I know about SDL: http://sdldoc.csn.ul.ie/index.php ;)
and, of course, http://www.libsdl.org/tutorials.php Title: SDL and Key Trapping Post by: BastetFurry on February 08, 2005, 07:37:08 PM This goes as follow:
Code: dim keys as uint8 ptr keys = SDL_GetKeyState(NULL) if keys[SDLK_UP] then ' Do something endif if keys[SDLK_DOWN] then ' Do something endif if keys[SDLK_LEFT] then ' Do something endif if keys[SDLK_RIGHT] then ' Do something endif Problem here is that you cannot do it with a nice looking select but have to use if´s as keys is an array of 255 elements. If you need to know what SDLK_Something you need have a look at SDL_keysym.bi Have fun ^.^ EDIT: If you just want to check it when a key is actauly pressed, check your event holder for SDL_KEYDOWN (Just copied my simple keywait routine) Code: sub SDL_WaitForKeypress() dim WaitForKeyEvent as SDL_Event do SDL_PollEvent(@WaitForKeyEvent) select case WaitForKeyEvent.type case SDL_KEYDOWN: 'Do your key stuff here! exit do case SDL_MOUSEDOWN: 'Do your mouse stuff here exit do end select loop end sub |