Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/input.c | 20 ++++++++++++++------ dlls/user32/tests/input.c | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index e9a74f177b9..dfb6bf7f646 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -179,8 +179,9 @@ static void update_mouse_coords( INPUT *input ) */ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size ) { + NTSTATUS status = STATUS_SUCCESS; + INPUT tmp; UINT i; - NTSTATUS status;
if (size != sizeof(INPUT)) { @@ -202,14 +203,21 @@ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
for (i = 0; i < count; i++) { - if (inputs[i].type == INPUT_MOUSE) + tmp = inputs[i]; + + switch (tmp.type) { + case INPUT_MOUSE: /* we need to update the coordinates to what the server expects */ - INPUT input = inputs[i]; - update_mouse_coords( &input ); - status = send_hardware_message( 0, &input, SEND_HWMSG_INJECTED ); + update_mouse_coords( &tmp ); + /* fallthrough */ + case INPUT_KEYBOARD: + status = send_hardware_message( 0, &tmp, SEND_HWMSG_INJECTED ); + break; + case INPUT_HARDWARE: + SetLastError( ERROR_CALL_NOT_IMPLEMENTED ); + return 0; } - else status = send_hardware_message( 0, &inputs[i], SEND_HWMSG_INJECTED );
if (status) { diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index 57bae6cdcad..514bf2765c6 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -4123,6 +4123,7 @@ static void test_SendInput(void) INPUT input[16]; UINT res, i; HWND hwnd; + MSG msg;
hwnd = CreateWindowW( L"static", L"test", WS_OVERLAPPED, 0, 0, 100, 100, 0, 0, 0, 0 ); ok(hwnd != 0, "CreateWindowW failed\n"); @@ -4176,6 +4177,27 @@ static void test_SendInput(void) ok(res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError()); empty_message_queue();
+ for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE; + SetLastError(0xdeadbeef); + res = SendInput(16, input, offsetof(INPUT, hi) + sizeof(HARDWAREINPUT)); + ok(res == 0 && GetLastError() == ERROR_INVALID_PARAMETER, "SendInput returned %u, error %#x\n", res, GetLastError()); + SetLastError(0xdeadbeef); + res = SendInput(16, input, sizeof(*input)); + ok(res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "SendInput returned %u, error %#x\n", res, GetLastError()); + while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) ok(0, "SendInput triggered unexpected message %#x\n", msg.message); + + memset(input, 0, sizeof(input)); + input[0].type = INPUT_HARDWARE; + SetLastError(0xdeadbeef); + res = SendInput(16, input, sizeof(*input)); + ok(res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED, "SendInput returned %u, error %#x\n", res, GetLastError()); + + for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE + 1; + SetLastError(0xdeadbeef); + res = SendInput(16, input, sizeof(*input)); + ok(res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError()); + while (PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) ok(0, "SendInput triggered unexpected message %#x\n", msg.message); + trace("done\n"); DestroyWindow(hwnd); }