It's been randomly failing on Wine and on some VMs (only some fvwm / mutter) [1], so I'm assuming this is caused by a focus-related Wine or WM bug. This also only affects older dinput versions, which are using LL-hooks for keyboard input.
[1]: https://test.winehq.org/data/patterns.html#dinput:device8
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dinput/tests/device8.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c index 5d4c2bb4366..3a702b8f2fe 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device8.c @@ -2234,6 +2234,7 @@ static void test_sys_keyboard( DWORD version ) memset( key_state, 0xcd, sizeof(key_state) ); hr = IDirectInputDevice8_GetDeviceState( device, sizeof(key_state), key_state ); ok( hr == DI_OK, "GetDeviceState returned %#lx\n", hr ); + flaky_wine_if( version < 0x800 && key_state[0] == 0 ) ok( key_state[0] == (version < 0x800 ? 0x80 : 0), "got key_state[0] %lu\n", key_state[0] );
/* unacquiring should reset the device state */