[SDL] key presses

Micah Lee micah at mindgrasp.com
Thu Dec 12 17:46:00 PST 2002


I've used it for about a year or so, probably.  I introduced it to my
high school computer science class, and started using it there a lot.
I'm fairly proficient at it- though I've never tried any of the 3D
functions.

- Micah

-----Original Message-----
From: sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org] On Behalf Of
Lai Kok Cheong
Sent: Thursday, December 12, 2002 8:21 PM
To: sdl at libsdl.org
Subject: RE: [SDL] key presses

Hi Micah,
		 May I know what was your  experience on using Allegro ?

----------------------------------------
Lai Kok Cheong  
AIG Software International 
G-1, Enterprise 1, Technology Park Malaysia 
Bukit Jalil
57000, Kuala Lumpur 
Malaysia 
Tel:   + 60 3 8996 0200 
Fax:  + 60 3 8996 0096 
www.aigsi.com <http://www.aigsi.com/>
---------------------------------------- 

> -----Original Message-----
> From:	Micah Lee [SMTP:micah at mindgrasp.com]
> Sent:	Friday, December 13, 2002 7:42 AM
> To:	sdl at libsdl.org
> Subject:	[SDL] key presses
> 
> Hey, I just joined the list.  This is my first post.  I've been using
> Allegro and I just decided to switch to SDL.  Is there any way I can
get
> input from the keyboard without it flipping out on me?  Like, here's
how
> I would update the current key being pressed:
> 
> ---------------------------------
> 
> bool keys[303];
> 
> if(SDL_PollEvent(&event))
> {
> 	switch(event.type)
> 	{
> 	case SDL_KEYDOWN:
> 		keys[event.key.keysym.sym] = true;
> 		break;
> 
> 	case SDL_KEYUP:
> 		keys[event.key.keysym.sym] = false;
> 		break;
> 	}
> }
> 
> ---------------------------------
> 
> Then, later in my program, to see if the right arrow is pressed:
> 
> ---------------------------------
> 
> if(keys[SDLK_RIGHT])
> {
> 	x++;
> }
> 
> ---------------------------------
> 
> The only trouble is x gets ++ed like 20 times.  They keys are waay too
> sensitive.  In Allegro I fixed this problem by using the readkey()
> function instead of using their array of key states.  Is there any way
I
> can make the keys not too crazy sensitive, but just about as sensitive
> as they are in all other programs without using SDL_Delay()?  Thanks.
> 
> - Micah
> 
> 
> 
> _______________________________________________
> SDL mailing list
> SDL at libsdl.org
> http://www.libsdl.org/mailman/listinfo/sdl

_______________________________________________
SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl







More information about the SDL mailing list