http://bugs.winehq.org/show_bug.cgi?id=20137
Summary: Bit 30 if lParam for WM_KEYDOWN / WM_KEYUP is not working as in windows Product: Wine Version: 1.1.29 Platform: PC URL: http://msdn.microsoft.com/en-us/library/ms646280%28VS. 85%29.aspx OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: fredrik.hultin@gmail.com
Created an attachment (id=23718) --> (http://bugs.winehq.org/attachment.cgi?id=23718) Small c program to demonstrate the bug
== Description ==
When a program receives the VM_KEYUP and VM_KEYDOWN notifications the 30th bit of lParam is, per the microsoft documentation, supposed to contain the the previous key state: "The value is 1 if the key is down before the message is sent, or it is zero if the key is up.".
This can be used to determine if a key was released before it was pressed again, which is helpful if you want to ignore key repeats.
lParam & (1 << 30)
...should evaluate as non-zero when the VM_KEYDOWN is generated as a repetition from the OS (rather than the user actually pressing a key).
This phenomenon is utilized in some non-direct x games to negate the effects of repeating keys in the application.
An example of this is the pure win32 version of SDL (link below, see the REPEATED_KEYMASK macro and its usage).
== Minimal Application ==
I've created and attached a minimal application that demonstrates the different behaviors of wine and windows.
Expected behavior of the application (and actual behavior in windows):
Print "first" in the console every time a key is pressed, followed by "repeat" n times until the user releases the key.
Actual behavior of the application in wine:
Prints "first" in the console every time a key is pressed followed by "first" (instead of "repeat") until the user releases the key.
I've tested this on wine 1.0.1 and 1.1.29 on Ubuntu 9.04 i386, and Windows XP x64 SP2.
As I'm on Ubuntu I've compiled it using the mingw32 package, but it should compile just fine with just about any compiler.
i586-mingw32msvc-gcc -mconsole -mwindows -o winebug.exe winebug.c
== Possible Cause ==
One possible cause for this is that wine (X?) generates a VM_KEYUP followed by a VM_KEYDOWN for every key repeat whereas windows simply generates a new VM_KEYDOWN. This is pure speculation, but that would explain why lParam indicates that the state of the key was released before the VM_KEYDOWN message was sent.
== References ==
SDL using the feature: http://www.libsdl.org/cgi/viewvc.cgi/trunk/SDL/src/video/win32/SDL_win32even...
Microsoft's description of the feature: http://msdn.microsoft.com/en-us/library/ms646280%28VS.85%29.aspx
PS. Be nice, this is my first wine bug report :)
http://bugs.winehq.org/show_bug.cgi?id=20137
--- Comment #1 from Fredrik Hultin fredrik.hultin@gmail.com 2009-09-23 11:47:50 --- By VM_KEYDOWN/VM_KEYUP I mean WM_KEYDOWN/WM_KEYUP. Sorry for the typo.
http://bugs.winehq.org/show_bug.cgi?id=20137
Austin English austinenglish@gmail.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Keywords| |testcase
http://bugs.winehq.org/show_bug.cgi?id=20137
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution| |DUPLICATE Alias|lParam+WM_KEYDOWN |
--- Comment #2 from Vitaliy Margolen vitaliy@kievinfo.com 2009-09-23 20:46:07 --- Thanks for the test, but it works here.
Duplicate (actually not a Wine bug at all).
*** This bug has been marked as a duplicate of bug 18296 ***
http://bugs.winehq.org/show_bug.cgi?id=20137
Vitaliy Margolen vitaliy@kievinfo.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED
--- Comment #3 from Vitaliy Margolen vitaliy@kievinfo.com 2009-09-23 20:46:25 --- Closing