From: Rémi Bernon <rbernon(a)codeweavers.com> --- dlls/user32/input.c | 19 ++++++++++++++++++- dlls/win32u/rawinput.c | 17 +++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 8f37ae6a50f..b39daa2a3c5 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -26,6 +26,10 @@ #include "user_private.h" #include "dbt.h" + +#include "initguid.h" +#include "ddk/hidclass.h" + #include "wine/server.h" #include "wine/debug.h" @@ -894,7 +898,13 @@ HWND WINAPI GetTaskmanWindow(void) static DWORD CALLBACK rawinput_thread( void *arg ) { - HWND hwnd = 0; + DEV_BROADCAST_DEVICEINTERFACE_W filter = + { + .dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE_W), + .dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE, + .dbcc_classguid = GUID_DEVINTERFACE_HID, + }; + HWND hwnd; TRACE_(rawinput)( "Starting rawinput thread\n" ); @@ -903,6 +913,13 @@ static DWORD CALLBACK rawinput_thread( void *arg ) /* wait for the desktop thread to fully initialize */ SendMessageW( GetDesktopWindow(), WM_NULL, 0, 0 ); + ImmDisableIME( 0 ); + hwnd = CreateWindowW( L"Message", NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL ); + NtUserDestroyInputContext( ImmGetContext( hwnd ) ); + + if (!RegisterDeviceNotificationW( hwnd, &filter, DEVICE_NOTIFY_WINDOW_HANDLE )) + WARN( "Failed to register for rawinput devices notifications\n" ); + return NtUserCallHwndParam( hwnd, 0, NtUserCallHwndParam_RawInputThread ); } diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index 466814cce2d..013a55bcc2a 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -472,11 +472,28 @@ BOOL rawinput_device_get_usages( HANDLE handle, USAGE *usage_page, USAGE *usage return *usage_page || *usage; } +static LRESULT CALLBACK rawinput_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + TRACE( "hwnd %p, msg %#x, wparam %#zx, lparam %#zx\n", hwnd, msg, (size_t)wparam, (size_t)lparam ); + + return NtUserMessageCall( hwnd, msg, wparam, lparam, 0, NtUserDefWindowProc, FALSE ); +} + DWORD rawinput_thread( HWND hwnd, DWORD_PTR param ) { + NtUserSetWindowLongPtr( hwnd, GWLP_WNDPROC, (LONG_PTR)rawinput_window_proc, FALSE ); + for (;;) { + MSG msg; + NtUserMsgWaitForMultipleObjectsEx( 0, NULL, INFINITE, QS_ALLINPUT, 0 ); + + while (NtUserPeekMessage( &msg, 0, 0, 0, PM_REMOVE )) + { + NtUserTranslateMessage( &msg, 0 ); + NtUserDispatchMessage( &msg ); + } } return 0; -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/3024