From f3952a3e21aa73585fab40cc40ace54333117c76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Sun, 22 Jan 2023 14:00:45 +0100 Subject: [PATCH] dinput: Move di_em_win_wndproc function around. --- dlls/dinput/dinput_main.c | 92 +++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/dlls/dinput/dinput_main.c b/dlls/dinput/dinput_main.c index f609faffc5d..491db22861f 100644 --- a/dlls/dinput/dinput_main.c +++ b/dlls/dinput/dinput_main.c @@ -127,52 +127,6 @@ static void dinput_device_internal_unacquire( IDirectInputDevice8W *iface, DWORD LeaveCriticalSection( &impl->crit ); } -static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -{ - struct dinput_device *impl; - RAWINPUT ri; - UINT size = sizeof(ri); - int rim = GET_RAWINPUT_CODE_WPARAM( wparam ); - - TRACE( "%p %d %Ix %Ix\n", hwnd, msg, wparam, lparam ); - - if (msg == WM_INPUT && (rim == RIM_INPUT || rim == RIM_INPUTSINK)) - { - size = GetRawInputData( (HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER) ); - if (size == (UINT)-1 || size < sizeof(RAWINPUTHEADER)) - WARN( "Unable to read raw input data\n" ); - else if (ri.header.dwType == RIM_TYPEMOUSE) - { - EnterCriticalSection( &dinput_hook_crit ); - LIST_FOR_EACH_ENTRY( impl, &acquired_rawmouse_list, struct dinput_device, entry ) - dinput_mouse_rawinput_hook( &impl->IDirectInputDevice8W_iface, wparam, lparam, &ri ); - LeaveCriticalSection( &dinput_hook_crit ); - } - } - - return DefWindowProcW( hwnd, msg, wparam, lparam ); -} - -static void register_di_em_win_class(void) -{ - WNDCLASSEXW class; - - memset(&class, 0, sizeof(class)); - class.cbSize = sizeof(class); - class.lpfnWndProc = di_em_win_wndproc; - class.hInstance = DINPUT_instance; - class.lpszClassName = L"DIEmWin"; - - if (!RegisterClassExW( &class ) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) - WARN( "Unable to register message window class\n" ); -} - -static void unregister_di_em_win_class(void) -{ - if (!UnregisterClassW( L"DIEmWin", NULL ) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST) - WARN( "Unable to unregister message window class\n" ); -} - static LRESULT CALLBACK input_thread_ll_hook_proc( int code, WPARAM wparam, LPARAM lparam ) { struct dinput_device *impl; @@ -321,6 +275,52 @@ static void input_thread_update_device_list( struct input_thread_state *state ) state->rawinput_devices[0] = rawinput_mouse; } +static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) +{ + struct dinput_device *impl; + RAWINPUT ri; + UINT size = sizeof(ri); + int rim = GET_RAWINPUT_CODE_WPARAM( wparam ); + + TRACE( "%p %d %Ix %Ix\n", hwnd, msg, wparam, lparam ); + + if (msg == WM_INPUT && (rim == RIM_INPUT || rim == RIM_INPUTSINK)) + { + size = GetRawInputData( (HRAWINPUT)lparam, RID_INPUT, &ri, &size, sizeof(RAWINPUTHEADER) ); + if (size == (UINT)-1 || size < sizeof(RAWINPUTHEADER)) + WARN( "Unable to read raw input data\n" ); + else if (ri.header.dwType == RIM_TYPEMOUSE) + { + EnterCriticalSection( &dinput_hook_crit ); + LIST_FOR_EACH_ENTRY( impl, &acquired_rawmouse_list, struct dinput_device, entry ) + dinput_mouse_rawinput_hook( &impl->IDirectInputDevice8W_iface, wparam, lparam, &ri ); + LeaveCriticalSection( &dinput_hook_crit ); + } + } + + return DefWindowProcW( hwnd, msg, wparam, lparam ); +} + +static void register_di_em_win_class(void) +{ + WNDCLASSEXW class; + + memset(&class, 0, sizeof(class)); + class.cbSize = sizeof(class); + class.lpfnWndProc = di_em_win_wndproc; + class.hInstance = DINPUT_instance; + class.lpszClassName = L"DIEmWin"; + + if (!RegisterClassExW( &class ) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) + WARN( "Unable to register message window class\n" ); +} + +static void unregister_di_em_win_class(void) +{ + if (!UnregisterClassW( L"DIEmWin", NULL ) && GetLastError() != ERROR_CLASS_DOES_NOT_EXIST) + WARN( "Unable to unregister message window class\n" ); +} + static DWORD WINAPI dinput_thread_proc( void *params ) { struct input_thread_state state = {0};