[AD] fix scancode_to_name on Windows (was: r5642 - allegro/branches/4.2/src/win)

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


On 2006-01-02, Elias Pschernig <elias@xxxxxxxxxx> wrote:
> On Mon, 2006-01-02 at 02:39 -0500, tjaden wrote:
> > -   for (i = 0; i < 256; i++) {
> > -      for (j = 0; j < 256; j++) {
> > -         if (hw_to_mycode[j] == i) {
> > -            reverse_mapping[i] = j;
> > -            break;
> > -         }
> > +
> > +   for (j = 0; j < 256; j++) {
> > +      i = hw_to_mycode[j];
> > +      if (i > 0) {
> > +         ASSERT(i < sizeof reverse_mapping/sizeof reverse_mapping[0]);
> > +         reverse_mapping[i] = j;
> 
> Oh my god, thanks for spotting this. Let's just claim I had coded the
> original version after lots of sleep deprivation :)

Well, it seems it will be a short-lived fix :-)

Here is a patch to fix scancode_to_name(KEY_NUMLOCK) returning "PAUSE"
in Windows.  The problem was that:

   GetKeyNameText(reverse_mapping[scancode] << 16, str, sizeof str)

as used currently is not quite right.  It caused quite a number of keys
to default to the key names in _keyboard_common_names[] rather that the
names that Windows gives.  After this patch all the Windows key names
can be gotten except for Print Screen (don't know why it doesn't work),
and the Japanese keys (don't have such a keyboard).

Peter

Attachment: wkeybd_fix_names.diff.gz
Description: application/gunzip



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