[Bug 20137] New: Bit 30 if lParam for WM_KEYDOWN / WM_KEYUP is not working as in windows

wine-bugs at winehq.org wine-bugs at winehq.org
Wed Sep 23 11:26:18 CDT 2009


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 at winehq.org
        ReportedBy: fredrik.hultin at 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_win32events.c?revision=4707&view=markup

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 :)

-- 
Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
Do not reply to this email, post in Bugzilla using the
above URL to reply.
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the wine-bugs mailing list