Re: [AD] key[] array with non-qwerty keyboards |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] key[] array with non-qwerty keyboards
- From: Elias Pschernig <elias@xxxxxxxxxx>
- Date: Sat, 16 Feb 2008 21:19:32 +0100
On Sat, 2008-02-16 at 19:43 +0000, Chris Jones wrote:
> Hi,
>
> I've come across what I think is a bug in allegro 4.2's Windows keyboard
> driver.
>
> If you're using a non-qwerty keyboard (for example the German QWERTZ
> keyboard, where Y and Z are swapped), then readkey() seems to handle this
> correctly and pressing Z returns a Z.
>
> However, when I then check the key[KEY_Z] array to determine when the key is
> released, it just returns 0 -- and on further investigation it seems that
> the key[KEY_Y] is set instead.
>
> Having had a look at the allegro code, it seems to be because the key[]
> array is based on the hw_to_mycode mapping, which is hardcoded for qwerty
> keyboards. But as I'm not that familiar with how the keyboard driver works,
> I don't want to change this myself -- there's even a comment in the code
> saying "TODO: shouldn't we base the mapping on vkey?"
>
> Any ideas about this one?
>
Yes, the KEY_* are meant to work that way. If you base your game input
on KEY_* keys, always allow the user to change the mapping, and store
their mapping in a configuration file.
The main problem is that we only have around 100 KEY_* constants, but to
have a meaningful mapping for all possible keys on all possible
keyboards we would need a lot more. For Allegro 5 this will (hopefullly)
be fixed.
Also note that some games do things like using Y and X for left and
right or using ASDW as left-handed cursor keys, and in such cases using
the actual keys would break horribly on non-qwerty keyboards as well -
so again, *always* provide a way to change the mapping :)
--
Elias Pschernig <elias@xxxxxxxxxx>