Original Post
So I''ve been reading up on nehe.gamedev.net to learn OpenGL. Also, I''ve been looking at the SDL port for some cross-platform coding. The code that handles input pretty much looks like this:
// beginning of code
while(SDL_PollEvent(&event)) {
switch (event.type) {
/*
case SDL_KEYDOWN:
handleKeyPress( &event.key.keysym );
break;
*/
case SDL_QUIT:
progRun = 0;
break;
case SDL_VIDEORESIZE:
/* handle resize event */
surface = SDL_SetVideoMode( event.resize.w,
event.resize.h,
32, videoFlags );
if ( !surface )
{
fprintf( stderr, "Could not get a surface after resize: %s\n", SDL_GetError( ) );
Quit( 1 );
}
resizeWindow( event.resize.w, event.resize.h );
break;
default: break;
}
}
//end of code
handleKeyPress(SDL_keysym *keysym) handles all the keys with switch statements as well. However, this input doesn''t do what I expect it to do. Pressing left speeds up the Y rotation speed of the box, but when I hold it down, it doesn''t continue to do so. If I''m not specific enough, an example is how holding down the key to go forward in a first person shooter makes you go forward as long as you hold the key down. In my case, pressing and holding the key only modifies it once, and doesn''t continue to increase. Thus, I gotta keep tapping it repeatedly. This code seems to work:
//begin
if (event.type == SDL_KEYDOWN) handleKeyPress( &event.key.keysym );
//end
Yet, it''s very sensitive. Like pressing ''L'' enables or disables light; the slightest tap makes the light flash a couple times a second lol. How do I solve my input problem? Thanks very much in advance.