Re: [AD] key_shifts bug under windows partially fixed (was: Re: Patch for wkeybd.c)

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


Victor wrote:
The ALT-GR == CTRL bug is a known bug in windows unfixed for years. I
got that bug in visual basic in 2001. At least for windows 2000 and XP
i can confirm the bug. I think it is on windows 95 and 98 too, but i'm
not sure because it was some years ago and i don't remember clearly.
Don't know if that was fixed in Windows 2003 or Vista.

The following results are from using my example compiled as a static-build using gcc 3.4.4 under Cygwin using allegro 4.2.2 with the key-shifts patch applied:

What happens in Windows 2000 (SP4 + SP4 Rollup 1 + latest patches, Direct X 9.0c) is that when I press ALT-GR (right ALT), as well as the expected behavour with the ALT-GR key, the key_shifts flag for CONTROL is set, and in the key[] array, the entry for left-control is also set. While still holding down ALT-GR and then pressing the left-control key, the left control is set as it should be, and when the left-control key is released (while still holding down ALT-GR), the flag for [left]-control is cleared in both key_shifts and key[]. Using Windows 98 on the same machine (DirectX 8.1) the key[] array is correct on press of ALT-GR, but key_shifts states that CONTROL is also pressed. The keyboard on this machine is a "Standard 101/102-Key or Microsoft Natrual PS/2 Keyboard". The keyboard-language is "En English (british)" and the layout is "British"

I tried this on another machine and I've discovered that this bug does not always occur under Windows 2000. On this machine the ALT-GR key behaved as expected. This machine also has a "Standard 101/102 key or Microsoft Natral PS/2 Keyboard", but unlike the other machine, it has a US keyboard (Input language: English (United Kingdom). Keyboard layout / IME: US). Likewise, under Windows 98 on that machine, the same (correct) behaviour was also exhibited.

I tried this on a third machine (Windows 2000 only) and like the second machine, ALT-GR behaved properly. This one has a "Keyboard: HID Keyboard device. Location: On USB Human Iterface Device" (Input language: English (United Kingdom). Keyboard layout / IME: US).


So, for Allegro we will need to workaround it in some way, since it's
not an allegro bug.

At least now we know that the ALT-GR issue is a windows bug and not an
Allegro bug, but we still need to find a workaround. Once we have, the
key_shifts issue should be completely resolved. If this is a windows bug, then there must already be several workarounds out there already. However, from my tests above, it seems like the bhaviour is determined not only by windows version, but by some other factors (possibly having to do with using a British keyboard instead of a US keyboard, but my test-sample is too small to determine if that's the case).

One idea I had is for the manual to mention a list of forbidden keycombos because some of them cause the OS to do something. For example, CTRL-ESC brings up the statrmenu in Windows. That way, if someone is developing on a platform where CTRL-ESC does not do anything, when their product is compiled on Windows, they will find the start-menu keeps popping up whenever they use CTRL+ESC. If we can't find a worlaround for the ALT-GR bug, perhaps we could add "ALT-GR + CONTROL" to the forbidden keycombos list.


AE.



--- Andrei Ellman <ae-a-alleg@xxxxxxxxxx> escreveu:

David A. Capello wrote:
And I found a bug with the keyboard handler of Windows.
Mainly the state of SHIFT, CTRL and ALT keys in the
global variable "key_shifts" aren't working right.

I think that the problems is because "GetKeyboardState"
is getting an old state of the keyboard (before to
process the queue of messages). So using "GetAsyncKeyState"
fix the problem. Anyway, I'm not very sure about the
cause of the bug.

I attached a simple test (bug.c) and a patch for
the src/win/wkeybd.c file which fix the problem.

Remember that key_shifts bug in Windows I reported last year ( see
http://sourceforge.net/mailarchive/forum.php?thread_name=44512457.3040902%40mailbag.wackonet.net&forum_name=alleg-developers
)? I tried 4.2.2 with the patch David posted, and it partially fixes
the problem. The flags for SHIFT, CTRL and ALT in key_shifts now no longer get stuck as I previously reported. However, the problem with ALT-GR where pressing ALT-GR also activates the left CTRL indicator (in both

key_shifts and key[]) still persists.

Attatched is the latest vertsion of the test-program I used. However,

David's bug.c program also demonstrates ALT-GR activating the CTRL indicator.

Note that I've only tried 4.2.1 and 4.2.2 with the patch. Not tried 4.2.2 without the patch, but the changelog says nothing happened to the keyboard driver from 4.2.1 to 4.2.2



AE.





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