SDLK_Return

I use new SDL1.2 and it seem that i found a bug (not sure, thats why i’m
asking). Here’s a part of my code:

while(1) {
if (SDL_PollEvent(&event) == 0) {
} else {
if (event.type == SDL_KEYDOWN) {
keys = SDL_GetKeyState(NULL);
if (keys[SDLK_ESCAPE] == SDL_PRESSED) {
dummy();
}
if (keys[SDLK_UP] == SDL_PRESSED) {
dummy();
}
if (keys[SDLK_DOWN] == SDL_PRESSED) {
dummy();
}
if (keys[SDLK_RETURN] == SDL_PRESSED) {
printf(“wtf?\n”);
}

        }
      } else if (event.type == SDL_QUIT) {
        return 1;
     }
  }

so whenever i press any key, it thinks that i press return key. Other keys
work fine. So is it my mistake or is it a bug?
Thanks,
–skinncode

so whenever i press any key, it thinks that i press return key. Other keys
work fine. So is it my mistake or is it a bug?

I see nothing wrong with it (except for a mismatched brace). try making a
complete minimal program that exhibits your problem and we’ll look again

I will not send the whole source but try to explain it over again.
I have a menu which is navigated by up arrow and down arrow. If lets say up
arrow pressed it changes int x to x-- (or x++); flowing by another
conditional sentence:

if( (keys[SDLK_RETURN]==SDL_PRESSED)) && x == 1) {
do_something();
exit(0);
}

so i load a menu, press up arrow (or any key) and it thinks that RETURN is
pressed and exits the program…
Now i have
if(keys[SDLK_SPACE] == SDL_PRESSED)) && x==1){

}
and it works fine…:confused:
Thats my problem…bye for now…

–skinncodeOn Monday 19 March 2001 14:00, you wrote:

so whenever i press any key, it thinks that i press return key. Other keys
work fine. So is it my mistake or is it a bug?

I see nothing wrong with it (except for a mismatched brace). try making a
complete minimal program that exhibits your problem and we’ll look again

so whenever i press any key, it thinks that i press return key.

As Mattias said, a minimal program to show this problem would help,
as well as information on what platform(s) this problem shows up.

Thanks!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software

I will not send the whole source but try to explain it over again.

that’s pointless since you can have done any number of errors in what you
don’t show us

ok, here it is. It should compile :). Start it and press up, down. left, or
right, or any other key… Just don’t press RETURN…but you will still see
in the output that you’ve pressed it.

//test

#include <SDL/SDL.h>

int main()
{
Uint8 *keys;
SDL_Event event;
SDL_Surface *screen;

SDL_Init(SDL_INIT_VIDEO);
atexit(SDL_Quit);
SDL_WM_SetCaption(“Bug Test”, NULL);
screen = SDL_SetVideoMode(640, 480, 16, SDL_HWACCEL);

while(1) {
  if (SDL_PollEvent(&event) == 0) {
  } else {

     if (event.type == SDL_KEYDOWN) {
        keys = SDL_GetKeyState(NULL);
        if (keys[SDLK_ESCAPE] == SDL_PRESSED) {
            printf("ESCAPE\n");
            return 1;
         }

        if (keys[SDLK_LEFT] == SDL_PRESSED) {
            printf("LEFT\n");
        }

        if (keys[SDLK_RIGHT] == SDL_PRESSED) {
            printf("RIGHT\n");
        }

        if((keys[SDLK_RETURN] == SDL_PRESSED)) {
            printf("RETURN ...wtf?\n");
        }

if((keys[SDLK_UP] == SDL_PRESSED)){
                    printf("UP\n");
    }

if((keys[SDLK_DOWN] == SDL_PRESSED)){
                    printf("DOWN\n");
    }

        }
        }

        }

}

I asked a couple of my friends to see if they have the same problem…some of
them did, some of them didn’t…:confused:

Here’s my box:
I run latest SDL (CVS) on Slackware 7.1 Linux. I use X4.0.3 (i have also
tested on 4.0.2 4.0.1). Video: nvdia GeForce2 MX…256MB ram, Athalon 650Mhz
cpu…

bye,
–skinncodeOn Monday 19 March 2001 16:53, you wrote:

I will not send the whole source but try to explain it over again.

that’s pointless since you can have done any number of errors in what you
don’t show us

Hmm, it works for me ™. I think this may have been fixed in the latest
CVS snapshot: http://www.libsdl.org/cvs.html

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software> On Monday 19 March 2001 16:53, you wrote:

I will not send the whole source but try to explain it over again.

that’s pointless since you can have done any number of errors in what you
don’t show us

ok, here it is. It should compile :). Start it and press up, down. left, or
right, or any other key… Just don’t press RETURN…but you will still see
in the output that you’ve pressed it.

thanks,On Monday 19 March 2001 18:41, you wrote:

On Monday 19 March 2001 16:53, you wrote:

I will not send the whole source but try to explain it over again.

that’s pointless since you can have done any number of errors in what
you don’t show us

ok, here it is. It should compile :). Start it and press up, down. left,
or right, or any other key… Just don’t press RETURN…but you will
still see in the output that you’ve pressed it.

Hmm, it works for me ™. I think this may have been fixed in the latest
CVS snapshot: http://www.libsdl.org/cvs.html

See ya!
-Sam Lantinga, Lead Programmer, Loki Entertainment Software