LONG last_hook_syskey_down;
LONG last_hook_syskey_up;
BOOL expect_alt;
+ BOOL sendinput_broken;
} key_status;
static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t);
static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD);
-#define MAXKEYEVENTS 10
+#define MAXKEYEVENTS 12
#define MAXKEYMESSAGES MAXKEYEVENTS /* assuming a key event generates one
and only one message */
HWND window;
HHOOK hook;
+ if (GetKeyboardLayout(0) != (HKL)(ULONG_PTR)0x04090409)
+ {
+ skip("Skipping Input_blackbox test on non-US keyboard\n");
+ return;
+ }
window = CreateWindow("Static", NULL, WS_POPUP|WS_HSCROLL|WS_VSCROLL
|WS_VISIBLE, 0, 0, 200, 60, NULL, NULL,
NULL, NULL);
SetWindowPos( window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
SetForegroundWindow( window );
- hook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, GetModuleHandleA( NULL ), 0);
+ if (!(hook = SetWindowsHookExA(WH_KEYBOARD_LL, hook_proc, GetModuleHandleA( NULL ), 0)))
+ {
+ DestroyWindow(window);
+ win_skip("WH_KEYBOARD_LL is not supported\n");
+ return;
+ }
/* must process all initial messages, otherwise X11DRV_KeymapNotify unsets
* key state set by SendInput(). */
key_status.last_hook_syskey_down = -1;
key_status.last_hook_syskey_up = -1;
key_status.expect_alt = FALSE;
+ key_status.sendinput_broken = FALSE;
}
static void test_unicode_keys(HWND hwnd, HHOOK hook)
inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
reset_key_status();
- SendInput(1, (INPUT*)inputs, sizeof(INPUT));
+ pSendInput(1, (INPUT*)inputs, sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){
TranslateMessage(&msg);
}
DispatchMessageW(&msg);
}
- ok(key_status.last_key_down == VK_PACKET,
- "Last keydown msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_key_down);
- ok(key_status.last_char == 0x3c0,
- "Last char msg wparam should have been 0x3c0 (was: 0x%x)\n", key_status.last_char);
- if(hook)
- ok(key_status.last_hook_down == 0x3c0,
- "Last hookdown msg should have been 0x3c0, was: 0x%x\n", key_status.last_hook_down);
+ if(!key_status.sendinput_broken){
+ ok(key_status.last_key_down == VK_PACKET,
+ "Last keydown msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_key_down);
+ ok(key_status.last_char == 0x3c0,
+ "Last char msg wparam should have been 0x3c0 (was: 0x%x)\n", key_status.last_char);
+ if(hook)
+ ok(key_status.last_hook_down == 0x3c0,
+ "Last hookdown msg should have been 0x3c0, was: 0x%x\n", key_status.last_hook_down);
+ }
inputs[1].u.ki.wVk = 0;
inputs[1].u.ki.wScan = 0x3c0;
inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
reset_key_status();
- SendInput(1, (INPUT*)(inputs+1), sizeof(INPUT));
+ pSendInput(1, (INPUT*)(inputs+1), sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){
TranslateMessage(&msg);
}
DispatchMessageW(&msg);
}
- ok(key_status.last_key_up == VK_PACKET,
- "Last keyup msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_key_up);
- if(hook)
- ok(key_status.last_hook_up == 0x3c0,
- "Last hookup msg should have been 0x3c0, was: 0x%x\n", key_status.last_hook_up);
+ if(!key_status.sendinput_broken){
+ ok(key_status.last_key_up == VK_PACKET,
+ "Last keyup msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_key_up);
+ if(hook)
+ ok(key_status.last_hook_up == 0x3c0,
+ "Last hookup msg should have been 0x3c0, was: 0x%x\n", key_status.last_hook_up);
+ }
/* holding alt, pressing & releasing a unicode character, releasing alt */
inputs[0].u.ki.wVk = VK_LMENU;
reset_key_status();
key_status.expect_alt = TRUE;
- SendInput(2, (INPUT*)inputs, sizeof(INPUT));
+ pSendInput(2, (INPUT*)inputs, sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){
TranslateMessage(&msg);
}
DispatchMessageW(&msg);
}
- ok(key_status.last_syskey_down == VK_PACKET,
- "Last syskeydown msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_syskey_down);
- ok(key_status.last_syschar == 0x3041,
- "Last syschar msg should have been 0x3041 (was: 0x%x)\n", key_status.last_syschar);
- if(hook)
- ok(key_status.last_hook_syskey_down == 0x3041,
- "Last hooksysdown msg should have been 0x3041, was: 0x%x\n", key_status.last_hook_syskey_down);
+ if(!key_status.sendinput_broken){
+ ok(key_status.last_syskey_down == VK_PACKET,
+ "Last syskeydown msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_syskey_down);
+ ok(key_status.last_syschar == 0x3041,
+ "Last syschar msg should have been 0x3041 (was: 0x%x)\n", key_status.last_syschar);
+ if(hook)
+ ok(key_status.last_hook_syskey_down == 0x3041,
+ "Last hooksysdown msg should have been 0x3041, was: 0x%x\n", key_status.last_hook_syskey_down);
+ }
inputs[1].u.ki.wVk = 0;
inputs[1].u.ki.wScan = 0x3041;
reset_key_status();
key_status.expect_alt = TRUE;
- SendInput(2, (INPUT*)inputs, sizeof(INPUT));
+ pSendInput(2, (INPUT*)inputs, sizeof(INPUT));
while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){
if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){
TranslateMessage(&msg);
}
DispatchMessageW(&msg);
}
- ok(key_status.last_key_up == VK_PACKET,
- "Last keyup msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_key_up);
- if(hook)
- ok(key_status.last_hook_up == 0x3041,
- "Last hook up msg should have been 0x3041, was: 0x%x\n", key_status.last_hook_up);
+ if(!key_status.sendinput_broken){
+ ok(key_status.last_key_up == VK_PACKET,
+ "Last keyup msg should have been VK_PACKET[0x%04x] (was: 0x%x)\n", VK_PACKET, key_status.last_key_up);
+ if(hook)
+ ok(key_status.last_hook_up == 0x3041,
+ "Last hook up msg should have been 0x3041, was: 0x%x\n", key_status.last_hook_up);
+ }
}
static LRESULT CALLBACK unicode_wnd_proc( HWND hWnd, UINT msg, WPARAM wParam,
{
if(nCode == HC_ACTION){
LPKBDLLHOOKSTRUCT info = (LPKBDLLHOOKSTRUCT)lParam;
- ok(info->vkCode == VK_PACKET || (key_status.expect_alt && info->vkCode == VK_LMENU), "vkCode should have been VK_PACKET[%04x], was: %04x\n", VK_PACKET, info->vkCode);
- key_status.expect_alt = FALSE;
+ if(!info->vkCode){
+ key_status.sendinput_broken = TRUE;
+ win_skip("SendInput doesn't support unicode on this platform\n");
+ }else{
+ if(key_status.expect_alt){
+ ok(info->vkCode == VK_LMENU, "vkCode should have been VK_LMENU[0x%04x], was: 0x%x\n", VK_LMENU, info->vkCode);
+ key_status.expect_alt = FALSE;
+ }else
+ ok(info->vkCode == VK_PACKET, "vkCode should have been VK_PACKET[0x%04x], was: 0x%x\n", VK_PACKET, info->vkCode);
+ }
switch(wParam){
case WM_KEYDOWN:
key_status.last_hook_down = info->scanCode;