Re: [AD] key[] array with non-qwerty keyboards

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> 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.

Hmm, so this effectively means that you can't reliably pair readkey() with
key[] in allegro to determine when a key is released. If this is a known
feature and is not planned to be addressed in Allegro 4, then I think it
should at least be mentioned in the key[] section of the documentation.

In the meantime, I've found a nasty workaround which means doing this when I
want to check the key array:

int is_key_pressed(int keycode)
{
    int vkey = VkKeyScan(keycode);
    int scancode = MapVirtualKey(vkey, MAPVK_VK_TO_VSC);
    if ((scancode >= 0) && (scancode < 256))
      keycode = hw_to_mycode[scancode];
    return key[keycode];
}

which allows you to pass in 'Y' for example and for the correct key[] entry
to be checked. Perhaps hooking the keyboard_lowlevel_callback would be a
better plan in the long run...

Thanks for your reply.

Cheers
Chris






Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/