Keyboard Events and Shift

It seems to me that when keyboard events arrive in the SDL_KeyboardEvent structure, the keysym that arrives is based on the state of the ‘shift’ key at the time the event is processed, rather than the time the event happens.

In Battle for Wesnoth, which is implemented in a single thread, we have a situation where a textbox is on-screen to send messages to other players at the same time as the AI is processing. This means that sometimes a keyboard event might not be processed promptly if the AI is processing. When the keyboard event finally is processed, the user might have let go of the shift key, and a letter that was meant to be capitalized is not capitalized.

As far as I can work out from reports from users, this bug seems to be Windows-specific, as it apparently does not occur on Linux (I don’t have access to a Linux machine to test on though).

Does anyone know of a way that I can get this to work, without having to use threads?

David White
Lead Developer
Battle for Wesnoth (http://www.wesnoth.org)

If it is possible to catch the shift key-down and
key-up event, you could keep your own shift-key state,
and use that. This seems like the simplest possible
solution to me.

Hope it works, good luck.

— David White wrote:> It seems to me that when keyboard events arrive in

the SDL_KeyboardEvent structure, the keysym that
arrives is based on the state of the ‘shift’ key at
the time the event is processed, rather than the
time the event happens.

In Battle for Wesnoth, which is implemented in a
single thread, we have a situation where a textbox
is on-screen to send messages to other players at
the same time as the AI is processing. This means
that sometimes a keyboard event might not be
processed promptly if the AI is processing. When the
keyboard event finally is processed, the user might
have let go of the shift key, and a letter that was
meant to be capitalized is not capitalized.

As far as I can work out from reports from users,
this bug seems to be Windows-specific, as it
apparently does not occur on Linux (I don’t have
access to a Linux machine to test on though).

Does anyone know of a way that I can get this to
work, without having to use threads?

David White
Lead Developer
Battle for Wesnoth (http://www.wesnoth.org)>


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


Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/