user32: Implement SendInput INPUT_HARDWARE check.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50506
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2021-04-09 13:11:32 +02:00 committed by Alexandre Julliard
parent 2f8da3c12a
commit 092c7a09a5
2 changed files with 14 additions and 10 deletions

View File

@ -180,7 +180,7 @@ static void update_mouse_coords( INPUT *input )
UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size ) UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
{ {
UINT i; UINT i;
NTSTATUS status; NTSTATUS status = STATUS_SUCCESS;
if (size != sizeof(INPUT)) if (size != sizeof(INPUT))
{ {
@ -202,14 +202,20 @@ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
if (inputs[i].type == INPUT_MOUSE)
{
/* we need to update the coordinates to what the server expects */
INPUT input = inputs[i]; INPUT input = inputs[i];
switch (input.type)
{
case INPUT_MOUSE:
/* we need to update the coordinates to what the server expects */
update_mouse_coords( &input ); update_mouse_coords( &input );
/* fallthrough */
case INPUT_KEYBOARD:
status = send_hardware_message( 0, &input, SEND_HWMSG_INJECTED ); status = send_hardware_message( 0, &input, 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) if (status)
{ {

View File

@ -4285,12 +4285,11 @@ static void test_SendInput(void)
input[1].hi.wParamH = 'A' | 0xc000; input[1].hi.wParamH = 'A' | 0xc000;
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
res = SendInput( 16, input, sizeof(*input) ); res = SendInput( 16, input, sizeof(*input) );
todo_wine
ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) ||
broken(res == 16 && GetLastError() == 0xdeadbeef) /* 32bit */, broken(res == 16 && GetLastError() == 0xdeadbeef) /* 32bit */,
"SendInput returned %u, error %#x\n", res, GetLastError() ); "SendInput returned %u, error %#x\n", res, GetLastError() );
while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg); while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg);
todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); ok( !res, "SendInput triggered unexpected message %#x\n", msg.message );
empty_message_queue(); empty_message_queue();
memset( input, 0, sizeof(input) ); memset( input, 0, sizeof(input) );
@ -4303,21 +4302,20 @@ static void test_SendInput(void)
input[2].ki.dwFlags = KEYEVENTF_KEYUP; input[2].ki.dwFlags = KEYEVENTF_KEYUP;
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
res = SendInput( 16, input, sizeof(*input) ); res = SendInput( 16, input, sizeof(*input) );
todo_wine
ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) || ok( (res == 0 && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) ||
broken(res == 16 && GetLastError() == 0xdeadbeef), broken(res == 16 && GetLastError() == 0xdeadbeef),
"SendInput returned %u, error %#x\n", res, GetLastError() ); "SendInput returned %u, error %#x\n", res, GetLastError() );
while ((res = wait_for_message(&msg)) && (msg.message == WM_TIMER || broken(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP))) while ((res = wait_for_message(&msg)) && (msg.message == WM_TIMER || broken(msg.message == WM_KEYDOWN || msg.message == WM_KEYUP)))
DispatchMessageA(&msg); DispatchMessageA(&msg);
todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); ok( !res, "SendInput triggered unexpected message %#x\n", msg.message );
empty_message_queue(); empty_message_queue();
for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE + 1; for (i = 0; i < ARRAY_SIZE(input); ++i) input[i].type = INPUT_HARDWARE + 1;
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
res = SendInput( 16, input, sizeof(*input) ); res = SendInput( 16, input, sizeof(*input) );
todo_wine ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() ); ok( res == 16 && GetLastError() == 0xdeadbeef, "SendInput returned %u, error %#x\n", res, GetLastError() );
while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg); while ((res = wait_for_message(&msg)) && msg.message == WM_TIMER) DispatchMessageA(&msg);
todo_wine ok( !res, "SendInput triggered unexpected message %#x\n", msg.message ); ok( !res, "SendInput triggered unexpected message %#x\n", msg.message );
empty_message_queue(); empty_message_queue();
trace( "done\n" ); trace( "done\n" );