http://bugs.winehq.org/show_bug.cgi?id=29857
Bug #: 29857 Summary: GetAsyncKeyState says Escape key is permanently down once it has been pressed Product: Wine Version: 1.3.28 Platform: x86 OS/Version: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown AssignedTo: wine-bugs@winehq.org ReportedBy: silas-wine@flatline.org.uk Classification: Unclassified
I am debugging a Windows application that has a long-running processing thread which periodically checks for interrupts using
GetAsyncKeyState(VK_ESCAPE) < 0
This worked fine on WINE 1.2.2, but on 1.3.28 the app kept behaving as if it were interrupted immediately when it had not been. Further investigation showed that, after Escape has been pressed just once, any future calls to GetAsyncKeyState (no matter how many events have been processed in the meantime) always return ffff8001. In other words, if you press Escape just once while running your app, any future calls that app makes to GetAsyncKeyState(VK_ESCAPE) will behave as though the Escape key is still down. Again this does not happen with WINE 1.2.2, only with 1.3.28.
I was able to work around this bug by adding a call to GetKeyState(VK_ESCAPE) just before the test for GetAsyncKeyState(VK_ESCAPE) < 0. I ignored the return value of GetKeyState (http://msdn.microsoft.com/en-us/library/windows/desktop/ms646301%28v=vs.85%2... says it should be called in response to a message; it doesn't say what happens if it's called when there has been no message, so I assume we can't rely on it to return meaningful values if called at just any time) however somehow the presence of the GetKeyState call caused WINE 1.3.28's GetAsyncKeyState to behave correctly.