Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SDL and Key Trapping
#3
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
color=red]Look at you, Hacker. A pathetic creature of meat and bone, panting and sweating as you run through my corridors. How can you challenge a perfect, immortal machine?" - Shodan, AI at Citadel Station orbiting Earth[/color]
Reply


Messages In This Thread
SDL and Key Trapping - by Nathan1993 - 02-09-2005, 01:48 AM
SDL and Key Trapping - by na_th_an - 02-09-2005, 02:14 AM
SDL and Key Trapping - by BastetFurry - 02-09-2005, 03:37 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)