Keyboard stuff

Today I have been porting an already written program to SDL, and although
almost everything else works fine (graphics, sound, joystick & mouse), I’m
experiencing some difficulties with the keyboard.

There is a particular key which can effect a change of mode - i.e. a fresh
call to SDL_SetVideoMode. But it seems that if I change mode on a KEYDOWN
event, then the KEYUP is never sent. Is this correct?

Just for reference, I’m using the X11/DGA target, not that I see how it
matters.

-Thomas

There is a particular key which can effect a change of mode - i.e. a fresh
call to SDL_SetVideoMode. But it seems that if I change mode on a KEYDOWN
event, then the KEYUP is never sent. Is this correct?

So, anyway, I pressed send too soon. But to expand on what I was saying - a
new KEYDOWN is not generated either. So am I supposed to assume that on a
change of graphics mode all the keys are assumed to be up and are not
signalled as down unless they change from up to down?

I also tried using SDL_GetKeyState, but without being able to check whether
it was exhibiting the same behaviour I noticed that it returns a non-0 value
for several keys even when nothing is pressed. I realise now I didn’t
explicitly check if it was a 1. Is there a special ‘key doesn’t exist’ value
not mentioned on the doc project, or am I supposed to assume SDLK_? keys
that don’t exist have an undefined state? If so, how am I supposed to
provide a redefine key procedure which doesn’t inadvertently map some of
these keys to actions, and then keep on executing those actions in game?

As you can see, I’m a little confused about this . . .

-Thomas

Today I have been porting an already written program to SDL, and although
almost everything else works fine (graphics, sound, joystick & mouse), I’m
experiencing some difficulties with the keyboard.

There is a particular key which can effect a change of mode - i.e. a fresh
call to SDL_SetVideoMode. But it seems that if I change mode on a KEYDOWN
event, then the KEYUP is never sent. Is this correct?

Yep, it’s a bug.

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