Hi, the documentation for these two functions isn't clear about the contents of the bits of the return value, except for the highest and lowest bit. Some programs assume that the others are always set to zero, which seems to be the actual behavior in Windows.
Specifically, this leads to stuck keys in "Age of Empires 2 HD" and "Age of Empires 2: Definitive Edition" when tabbing out as reported in https://bugs.winehq.org/show_bug.cgi?id=30814 .
The following patch makes sure that all undefined bits in the first byte are set to zero.
Markus
v2: As the test for the first version revealed, Windows XP indeed behaves differently from all newer versions. The patch now only clears bits 1-6 in the first byte and uses sign extension to create the SHORT return value again.
Signed-off-by: Markus Engel markus_wine@familie-engel.online
Markus Engel (2): user32: Force undefined bits in GetKeyState() and GetKeyboardState() to zero. user32/tests: Add more tests for GetKeyState().
dlls/user32/input.c | 6 +++++- dlls/user32/tests/input.c | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-)