Keys get stuck when switching windows with ALT+TAB
promitheas

I am working on a game, and I noticed that when using al_key_down, if I switch windows with alt+tab, allegro will think that I am holding alt down, until I press and release it again. Anyone know anything I can do to fix this?

torhu

What version of Allegro? IIRC, this was fixed many years ago.

promitheas

ALLEGRO_VERSION_STR is 5.2.7, so that's probably the version

torhu

The headers can have a different version from the binaries. You can check the real version by printing what al_get_allegro_version returns. Did you build the binaries yourself?

APPEND:
Maybe I'm mistaken, sorry. You can try calling al_clear_keyboard_state when you get the ALLEGRO_EVENT_DISPLAY_SWITCH_OUT event, that should fix it.

Edgar Reynaldo

The event system is preferable to the state system. Look for keyboard events, not states. It doesn't have this problem.

promitheas

Thanks, al_clear_keyboard_state() fixed it.
To use it I had to define ALLEGRO_UNSTABLE. Will it be wrong to only define ALLEGRO_UNSTABLE when I want to use functions that require it, or do I have to always define it before including anything from ALLEGRO?

Edgar Reynaldo

#define ing ALLEGRO_UNSTABLE allows you to access the unstable parts of allegro. It is optional.

Thread #618735. Printed from Allegro.cc