[PATCH 3/3] user32: Introduce WINEINPUT type for internal SendInput.
Rémi Bernon
rbernon at codeweavers.com
Tue Mar 9 07:58:23 CST 2021
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/user32/input.c | 16 ++++++++++------
include/winuser.h | 10 ++++++++++
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index dfb6bf7f646..e510b2669fc 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -179,11 +179,13 @@ static void update_mouse_coords( INPUT *input )
*/
UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
{
+ WINEINPUT tmp;
NTSTATUS status = STATUS_SUCCESS;
- INPUT tmp;
+ BOOL internal;
UINT i;
- if (size != sizeof(INPUT))
+ internal = count && inputs && inputs[0].type & INPUT_WINE;
+ if (size != (internal ? sizeof(WINEINPUT) : sizeof(INPUT)))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
@@ -203,16 +205,18 @@ UINT WINAPI SendInput( UINT count, LPINPUT inputs, int size )
for (i = 0; i < count; i++)
{
- tmp = inputs[i];
+ memcpy( &tmp, (char *)inputs + i * size, size );
+ if (!(tmp.input.type & INPUT_WINE)) tmp.hwnd = 0;
+ tmp.input.type &= ~INPUT_WINE;
- switch (tmp.type)
+ switch (tmp.input.type)
{
case INPUT_MOUSE:
/* we need to update the coordinates to what the server expects */
- update_mouse_coords( &tmp );
+ update_mouse_coords( &tmp.input );
/* fallthrough */
case INPUT_KEYBOARD:
- status = send_hardware_message( 0, &tmp, SEND_HWMSG_INJECTED );
+ status = send_hardware_message( tmp.hwnd, &tmp.input, internal ? 0 : SEND_HWMSG_INJECTED );
break;
case INPUT_HARDWARE:
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
diff --git a/include/winuser.h b/include/winuser.h
index 53661f6c788..2072f047165 100644
--- a/include/winuser.h
+++ b/include/winuser.h
@@ -477,6 +477,16 @@ typedef struct tagINPUT
} DUMMYUNIONNAME;
} INPUT, *PINPUT, *LPINPUT;
+#ifdef __WINESRC__
+/* extension to send hardware input from drivers */
+#define INPUT_WINE 0x80000000
+typedef struct
+{
+ INPUT input;
+ HWND hwnd;
+} WINEINPUT;
+#endif /* __WINESRC__ */
+
DECLARE_HANDLE(HRAWINPUT);
typedef struct tagRAWINPUTDEVICELIST
--
2.30.0
More information about the wine-devel
mailing list