Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/tests/input.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 4a9be550bd..78d1e54588 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -76,7 +76,6 @@ static struct { BOOL sendinput_broken; } key_status;
-static UINT (WINAPI *pSendInput) (UINT, INPUT*, size_t); static BOOL (WINAPI *pGetCurrentInputMessageSource)( INPUT_MESSAGE_SOURCE *source ); static BOOL (WINAPI *pGetPointerType)(UINT32, POINTER_INPUT_TYPE*); static int (WINAPI *pGetMouseMovePointsEx) (UINT, LPMOUSEMOVEPOINT, LPMOUSEMOVEPOINT, int, DWORD); @@ -163,7 +162,6 @@ static void init_function_pointers(void) if (!(p ## func = (void*)GetProcAddress(hdll, #func))) \ trace("GetProcAddress(%s) failed\n", #func)
- GET_PROC(SendInput); GET_PROC(GetCurrentInputMessageSource); GET_PROC(GetMouseMovePointsEx); GET_PROC(GetPointerType); @@ -249,7 +247,7 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++) ; ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" ); - if( evtctr != pSendInput(evtctr, &inputs[0], sizeof(INPUT))) + if( evtctr != SendInput(evtctr, &inputs[0], sizeof(INPUT))) ok (FALSE, "SendInput failed to send some events\n"); i = 0; if (winetest_debug > 1) @@ -954,7 +952,7 @@ static void test_Input_blackbox(void) i.u.ki.wScan = ii+1 /* useful for debugging */; i.u.ki.dwFlags = sendinput_test[ii].dwFlags; i.u.ki.wVk = sendinput_test[ii].wVk; - pSendInput(1, (INPUT*)&i, sizeof(TEST_INPUT)); + SendInput(1, (INPUT*)&i, sizeof(TEST_INPUT)); empty_message_queue(); GetKeyboardState(ks2); compare_and_check(ii, ks1, ks2, &sendinput_test[ii], foreground); @@ -997,7 +995,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook) inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
reset_key_status(); - pSendInput(1, (INPUT*)inputs, sizeof(INPUT)); + SendInput(1, (INPUT*)inputs, sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){ TranslateMessage(&msg); @@ -1019,7 +1017,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook) inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
reset_key_status(); - pSendInput(1, (INPUT*)(inputs+1), sizeof(INPUT)); + SendInput(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); @@ -1045,7 +1043,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
reset_key_status(); key_status.expect_alt = TRUE; - pSendInput(2, (INPUT*)inputs, sizeof(INPUT)); + SendInput(2, (INPUT*)inputs, sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){ TranslateMessage(&msg); @@ -1072,7 +1070,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
reset_key_status(); key_status.expect_alt = TRUE; - pSendInput(2, (INPUT*)inputs, sizeof(INPUT)); + SendInput(2, (INPUT*)inputs, sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ if(msg.message == WM_SYSKEYDOWN && msg.wParam == VK_PACKET){ TranslateMessage(&msg); @@ -2758,7 +2756,7 @@ static void test_input_message_source(void) SendMessageA( hwnd, WM_KEYDOWN, 0, 0 ); SendMessageA( hwnd, WM_MOUSEMOVE, 0, 0 );
- pSendInput( 2, (INPUT *)inputs, sizeof(INPUT) ); + SendInput( 2, (INPUT *)inputs, sizeof(INPUT) ); while (PeekMessageW( &msg, hwnd, 0, 0, PM_REMOVE )) { expect_src.deviceType = IMDT_KEYBOARD; @@ -2834,15 +2832,10 @@ START_TEST(input) init_function_pointers(); GetCursorPos( &pos );
- if (pSendInput) - { - test_Input_blackbox(); - test_Input_whitebox(); - test_Input_unicode(); - test_Input_mouse(); - } - else win_skip("SendInput is not available\n"); - + test_Input_blackbox(); + test_Input_whitebox(); + test_Input_unicode(); + test_Input_mouse(); test_keynames(); test_mouse_ll_hook(); test_key_map();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/tests/input.c | 72 +++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 21 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 78d1e54588..f7e351bfd1 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -72,6 +72,7 @@ static struct { LONG last_hook_up; LONG last_hook_syskey_down; LONG last_hook_syskey_up; + WORD vk; BOOL expect_alt; BOOL sendinput_broken; } key_status; @@ -115,15 +116,6 @@ typedef struct } u; } TEST_INPUT;
-#define ADDTOINPUTS(kev) \ -inputs[evtctr].type = INPUT_KEYBOARD; \ - ((TEST_INPUT*)inputs)[evtctr].u.ki.wVk = GETVKEY[ kev]; \ - ((TEST_INPUT*)inputs)[evtctr].u.ki.wScan = GETSCAN[ kev]; \ - ((TEST_INPUT*)inputs)[evtctr].u.ki.dwFlags = GETFLAGS[ kev]; \ - ((TEST_INPUT*)inputs)[evtctr].u.ki.dwExtraInfo = 0; \ - ((TEST_INPUT*)inputs)[evtctr].u.ki.time = ++timetag; \ - if( kev) evtctr++; - typedef struct { UINT message; WPARAM wParam; @@ -227,17 +219,25 @@ static int KbdMessage( KEV kev, WPARAM *pwParam, LPARAM *plParam ) */ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) { - INPUT inputs[MAXKEYEVENTS]; + TEST_INPUT inputs[MAXKEYEVENTS]; KMSG expmsg[MAXKEYEVENTS]; MSG msg; char buf[100]; - UINT evtctr=0; + UINT evtctr=0, ret; int kmctr, i;
buf[0]='\0'; TrackSysKey=0; /* see input.c */ - for( i = 0; i < MAXKEYEVENTS; i++) { - ADDTOINPUTS(td[i]) + for (i = 0; i < MAXKEYEVENTS; i++) + { + inputs[evtctr].type = INPUT_KEYBOARD; + inputs[evtctr].u.ki.wVk = GETVKEY[td[i]]; + inputs[evtctr].u.ki.wScan = GETSCAN[td[i]]; + inputs[evtctr].u.ki.dwFlags = GETFLAGS[td[i]]; + inputs[evtctr].u.ki.dwExtraInfo = 0; + inputs[evtctr].u.ki.time = ++timetag; + if (td[i]) evtctr++; + strcat(buf, getdesc[td[i]]); if(td[i]) expmsg[i].message = KbdMessage(td[i], &(expmsg[i].wParam), &(expmsg[i].lParam)); @@ -247,8 +247,8 @@ static BOOL do_test( HWND hwnd, int seqnr, const KEV td[] ) for( kmctr = 0; kmctr < MAXKEYEVENTS && expmsg[kmctr].message; kmctr++) ; ok( evtctr <= MAXKEYEVENTS, "evtctr is above MAXKEYEVENTS\n" ); - if( evtctr != SendInput(evtctr, &inputs[0], sizeof(INPUT))) - ok (FALSE, "SendInput failed to send some events\n"); + ret = SendInput(evtctr, (INPUT *)inputs, sizeof(INPUT)); + ok(ret == evtctr, "SendInput failed to send some events\n"); i = 0; if (winetest_debug > 1) trace("======== key stroke sequence #%d: %s =============\n", @@ -963,7 +963,7 @@ static void test_Input_blackbox(void) UnhookWindowsHookEx(hook); }
-static void reset_key_status(void) +static void reset_key_status(WORD vk) { key_status.last_key_down = -1; key_status.last_key_up = -1; @@ -975,6 +975,7 @@ static void reset_key_status(void) key_status.last_hook_up = -1; key_status.last_hook_syskey_down = -1; key_status.last_hook_syskey_up = -1; + key_status.vk = vk; key_status.expect_alt = FALSE; key_status.sendinput_broken = FALSE; } @@ -994,7 +995,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook) inputs[0].u.ki.wScan = 0x3c0; inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE;
- reset_key_status(); + reset_key_status(VK_PACKET); SendInput(1, (INPUT*)inputs, sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){ @@ -1016,7 +1017,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook) inputs[1].u.ki.wScan = 0x3c0; inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP;
- reset_key_status(); + reset_key_status(VK_PACKET); SendInput(1, (INPUT*)(inputs+1), sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ if(msg.message == WM_KEYDOWN && msg.wParam == VK_PACKET){ @@ -1041,7 +1042,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook) inputs[1].u.ki.wScan = 0x3041; inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE;
- reset_key_status(); + reset_key_status(VK_PACKET); key_status.expect_alt = TRUE; SendInput(2, (INPUT*)inputs, sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ @@ -1068,7 +1069,7 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook) inputs[0].u.ki.wScan = 0; inputs[0].u.ki.dwFlags = KEYEVENTF_KEYUP;
- reset_key_status(); + reset_key_status(VK_PACKET); key_status.expect_alt = TRUE; SendInput(2, (INPUT*)inputs, sizeof(INPUT)); while(PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)){ @@ -1084,6 +1085,34 @@ static void test_unicode_keys(HWND hwnd, HHOOK 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); } + + /* Press and release, non-zero key code. */ + inputs[0].u.ki.wVk = 0x51; + inputs[0].u.ki.wScan = 0x123; + inputs[0].u.ki.dwFlags = KEYEVENTF_UNICODE; + + inputs[1].u.ki.wVk = 0x51; + inputs[1].u.ki.wScan = 0x123; + inputs[1].u.ki.dwFlags = KEYEVENTF_UNICODE | KEYEVENTF_KEYUP; + + reset_key_status(inputs[0].u.ki.wVk); + SendInput(2, (INPUT*)inputs, sizeof(INPUT)); + while (PeekMessageW(&msg, hwnd, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + + if (!key_status.sendinput_broken) + { + todo_wine { + ok(key_status.last_key_down == 0x51, "Unexpected key down %#x.\n", key_status.last_key_down); + ok(key_status.last_key_up == 0x51, "Unexpected key up %#x.\n", key_status.last_key_up); + } + if (hook) + todo_wine + ok(key_status.last_hook_up == 0x23, "Unexpected hook message %#x.\n", key_status.last_hook_up); + } }
static LRESULT CALLBACK unicode_wnd_proc( HWND hWnd, UINT msg, WPARAM wParam, @@ -1124,7 +1153,8 @@ static LRESULT CALLBACK llkbd_unicode_hook(int nCode, WPARAM wParam, LPARAM lPar 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); + todo_wine_if(key_status.vk != VK_PACKET) + ok(info->vkCode == key_status.vk, "Unexpected vkCode %#x, expected %#x.\n", info->vkCode, key_status.vk); } switch(wParam){ case WM_KEYDOWN:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/tests/input.c | 2 -- server/queue.c | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index f7e351bfd1..168b055773 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -1105,10 +1105,8 @@ static void test_unicode_keys(HWND hwnd, HHOOK hook)
if (!key_status.sendinput_broken) { - todo_wine { ok(key_status.last_key_down == 0x51, "Unexpected key down %#x.\n", key_status.last_key_down); ok(key_status.last_key_up == 0x51, "Unexpected key up %#x.\n", key_status.last_key_up); - } if (hook) todo_wine ok(key_status.last_hook_up == 0x23, "Unexpected hook message %#x.\n", key_status.last_hook_up); diff --git a/server/queue.c b/server/queue.c index 24239916af..96587d11d1 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1803,7 +1803,7 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c msg->lparam = (input->kbd.scan << 16) | 1u; /* repeat count */ if (origin == IMO_INJECTED) msg_data->flags = LLKHF_INJECTED;
- if (input->kbd.flags & KEYEVENTF_UNICODE) + if (input->kbd.flags & KEYEVENTF_UNICODE && !vkey) { msg->wparam = VK_PACKET; }