From: Zebediah Figura zfigura@codeweavers.com
--- dlls/user32/rawinput.c | 54 +-------------------- dlls/user32/user32.spec | 2 +- dlls/user32/user_main.c | 1 + dlls/user32/user_private.h | 8 +--- dlls/win32u/Makefile.in | 1 + dlls/win32u/gdiobj.c | 1 + dlls/win32u/ntuser_private.h | 7 +++ dlls/win32u/rawinput.c | 91 ++++++++++++++++++++++++++++++++++++ dlls/win32u/win32u.spec | 2 +- dlls/win32u/win32u_private.h | 2 + dlls/win32u/wrappers.c | 6 +++ include/ntuser.h | 1 + 12 files changed, 114 insertions(+), 62 deletions(-) create mode 100644 dlls/win32u/rawinput.c
diff --git a/dlls/user32/rawinput.c b/dlls/user32/rawinput.c index 99e2270b77c..b1c79b4e186 100644 --- a/dlls/user32/rawinput.c +++ b/dlls/user32/rawinput.c @@ -351,7 +351,7 @@ BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage) }
-struct rawinput_thread_data *rawinput_thread_data(void) +struct rawinput_thread_data * WINAPI rawinput_thread_data(void) { struct user_thread_info *thread_info = get_user_thread_info(); struct rawinput_thread_data *data = thread_info->rawinput; @@ -593,58 +593,6 @@ BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(const RAWINPUTDEVICE *devi return ret; }
-/*********************************************************************** - * GetRawInputData (USER32.@) - */ -UINT WINAPI GetRawInputData(HRAWINPUT rawinput, UINT command, void *data, UINT *data_size, UINT header_size) -{ - struct rawinput_thread_data *thread_data = rawinput_thread_data(); - UINT size; - - TRACE("rawinput %p, command %#x, data %p, data_size %p, header_size %u.\n", - rawinput, command, data, data_size, header_size); - - if (!rawinput || thread_data->hw_id != (UINT_PTR)rawinput) - { - SetLastError(ERROR_INVALID_HANDLE); - return ~0U; - } - - if (header_size != sizeof(RAWINPUTHEADER)) - { - WARN("Invalid structure size %u.\n", header_size); - SetLastError(ERROR_INVALID_PARAMETER); - return ~0U; - } - - switch (command) - { - case RID_INPUT: - size = thread_data->buffer->header.dwSize; - break; - case RID_HEADER: - size = sizeof(RAWINPUTHEADER); - break; - default: - SetLastError(ERROR_INVALID_PARAMETER); - return ~0U; - } - - if (!data) - { - *data_size = size; - return 0; - } - - if (*data_size < size) - { - SetLastError(ERROR_INSUFFICIENT_BUFFER); - return ~0U; - } - memcpy(data, thread_data->buffer, size); - return size; -} - #ifdef _WIN64 typedef RAWINPUTHEADER RAWINPUTHEADER64; typedef RAWINPUT RAWINPUT64; diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index d0262a004f1..de20e692157 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -367,7 +367,7 @@ @ stdcall GetPropW(long wstr) @ stdcall GetQueueStatus(long) NtUserGetQueueStatus @ stdcall GetRawInputBuffer(ptr ptr long) -@ stdcall GetRawInputData(ptr long ptr ptr long) +@ stdcall GetRawInputData(ptr long ptr ptr long) NtUserGetRawInputData @ stdcall GetRawInputDeviceInfoA(ptr long ptr ptr) @ stdcall GetRawInputDeviceInfoW(ptr long ptr ptr) @ stdcall GetRawInputDeviceList(ptr ptr long) diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c index 3cb42e15b1e..4901bcf7193 100644 --- a/dlls/user32/user_main.c +++ b/dlls/user32/user_main.c @@ -169,6 +169,7 @@ static const struct user_callbacks user_funcs = register_imm, unregister_imm, try_finally, + rawinput_thread_data, };
static NTSTATUS WINAPI User32CopyImage( const struct copy_image_params *params, ULONG size ) diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index a3a3d28c2d9..a31a2bd8a01 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -51,12 +51,6 @@ struct wm_char_mapping_data /* hold up to 10s of 1kHz mouse rawinput events */ #define RAWINPUT_BUFFER_SIZE (512*1024)
-struct rawinput_thread_data -{ - UINT hw_id; /* current rawinput message id */ - RAWINPUT buffer[1]; /* rawinput message data buffer */ -}; - extern BOOL (WINAPI *imm_register_window)(HWND) DECLSPEC_HIDDEN; extern void (WINAPI *imm_unregister_window)(HWND) DECLSPEC_HIDDEN;
@@ -73,7 +67,7 @@ struct tagWND; struct hardware_msg_data; extern BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data); extern BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage); -extern struct rawinput_thread_data *rawinput_thread_data(void); +extern struct rawinput_thread_data * WINAPI rawinput_thread_data(void); extern void rawinput_update_device_list(void);
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, diff --git a/dlls/win32u/Makefile.in b/dlls/win32u/Makefile.in index d58ed6bb41c..cc429836de3 100644 --- a/dlls/win32u/Makefile.in +++ b/dlls/win32u/Makefile.in @@ -43,6 +43,7 @@ C_SRCS = \ path.c \ pen.c \ printdrv.c \ + rawinput.c \ region.c \ spy.c \ syscall.c \ diff --git a/dlls/win32u/gdiobj.c b/dlls/win32u/gdiobj.c index da2e78be2dd..77c3e16242a 100644 --- a/dlls/win32u/gdiobj.c +++ b/dlls/win32u/gdiobj.c @@ -1183,6 +1183,7 @@ static struct unix_funcs unix_funcs = NtUserGetMessage, NtUserGetPriorityClipboardFormat, NtUserGetQueueStatus, + NtUserGetRawInputData, NtUserGetSystemMenu, NtUserGetUpdateRect, NtUserGetUpdateRgn, diff --git a/dlls/win32u/ntuser_private.h b/dlls/win32u/ntuser_private.h index 075fc714744..babbc8208bc 100644 --- a/dlls/win32u/ntuser_private.h +++ b/dlls/win32u/ntuser_private.h @@ -50,6 +50,7 @@ struct user_callbacks void (WINAPI *unregister_imm)( HWND hwnd ); NTSTATUS (CDECL *try_finally)( NTSTATUS (CDECL *func)( void *), void *arg, void (CALLBACK *finally_func)( BOOL )); + struct rawinput_thread_data *(WINAPI *get_rawinput_thread_data)(void); };
#define WM_SYSTIMER 0x0118 @@ -61,6 +62,12 @@ enum system_timer_id SYSTEM_TIMER_CARET = 0xffff, };
+struct rawinput_thread_data +{ + UINT hw_id; /* current rawinput message id */ + RAWINPUT buffer[1]; /* rawinput message data buffer */ +}; + struct user_object { HANDLE handle; diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c new file mode 100644 index 00000000000..0d2c585c36e --- /dev/null +++ b/dlls/win32u/rawinput.c @@ -0,0 +1,91 @@ +/* + * Raw Input + * + * Copyright 2012 Henri Verbeet + * Copyright 2018 Zebediah Figura for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#if 0 +#pragma makedep unix +#endif + +#include "win32u_private.h" +#include "ntuser_private.h" +#include "wine/server.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(rawinput); + +/********************************************************************** + * NtUserGetRawInputData (win32u.@) + */ +UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, UINT *data_size, UINT header_size ) +{ + struct rawinput_thread_data *thread_data; + UINT size; + + TRACE( "rawinput %p, command %#x, data %p, data_size %p, header_size %u.\n", + rawinput, command, data, data_size, header_size ); + + if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data())) + { + SetLastError( ERROR_OUTOFMEMORY ); + return ~0u; + } + + if (!rawinput || thread_data->hw_id != (UINT_PTR)rawinput) + { + SetLastError( ERROR_INVALID_HANDLE ); + return ~0u; + } + + if (header_size != sizeof(RAWINPUTHEADER)) + { + WARN( "Invalid structure size %u.\n", header_size ); + SetLastError( ERROR_INVALID_PARAMETER ); + return ~0u; + } + + switch (command) + { + case RID_INPUT: + size = thread_data->buffer->header.dwSize; + break; + + case RID_HEADER: + size = sizeof(RAWINPUTHEADER); + break; + + default: + SetLastError( ERROR_INVALID_PARAMETER ); + return ~0u; + } + + if (!data) + { + *data_size = size; + return 0; + } + + if (*data_size < size) + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return ~0u; + } + memcpy( data, thread_data->buffer, size ); + return size; +} diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index 6f9dc0e921b..c984316e7c9 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -984,7 +984,7 @@ @ stdcall NtUserGetQueueStatus(long) @ stub NtUserGetQueueStatusReadonly @ stub NtUserGetRawInputBuffer -@ stub NtUserGetRawInputData +@ stdcall NtUserGetRawInputData(ptr long ptr ptr long) @ stub NtUserGetRawInputDeviceInfo @ stub NtUserGetRawInputDeviceList @ stub NtUserGetRawPointerDeviceData diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h index dc62f6846a5..f431b967c32 100644 --- a/dlls/win32u/win32u_private.h +++ b/dlls/win32u/win32u_private.h @@ -245,6 +245,8 @@ struct unix_funcs BOOL (WINAPI *pNtUserGetMessage)( MSG *msg, HWND hwnd, UINT first, UINT last ); INT (WINAPI *pNtUserGetPriorityClipboardFormat)( UINT *list, INT count ); DWORD (WINAPI *pNtUserGetQueueStatus)( UINT flags ); + UINT (WINAPI *pNtUserGetRawInputData)( HRAWINPUT rawinput, UINT command, + void *data, UINT *data_size, UINT header_size ); HMENU (WINAPI *pNtUserGetSystemMenu)( HWND hwnd, BOOL revert ); BOOL (WINAPI *pNtUserGetUpdateRect)( HWND hwnd, RECT *rect, BOOL erase ); INT (WINAPI *pNtUserGetUpdateRgn)( HWND hwnd, HRGN hrgn, BOOL erase ); diff --git a/dlls/win32u/wrappers.c b/dlls/win32u/wrappers.c index ed4337eae84..56ffef8f478 100644 --- a/dlls/win32u/wrappers.c +++ b/dlls/win32u/wrappers.c @@ -1041,6 +1041,12 @@ DWORD WINAPI NtUserGetQueueStatus( UINT flags ) return unix_funcs->pNtUserGetQueueStatus( flags ); }
+UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, UINT *data_size, UINT header_size ) +{ + if (!unix_funcs) return ~0u; + return unix_funcs->pNtUserGetRawInputData( rawinput, command, data, data_size, header_size ); +} + BOOL WINAPI NtUserGetUpdatedClipboardFormats( UINT *formats, UINT size, UINT *out_size ) { if (!unix_funcs) return FALSE; diff --git a/include/ntuser.h b/include/ntuser.h index 56c920aacdf..269ba3ae490 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -604,6 +604,7 @@ HWINSTA WINAPI NtUserGetProcessWindowStation(void); HANDLE WINAPI NtUserGetProp( HWND hwnd, const WCHAR *str ); ULONG WINAPI NtUserGetProcessDpiAwarenessContext( HANDLE process ); DWORD WINAPI NtUserGetQueueStatus( UINT flags ); +UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, UINT *data_size, UINT header_size ); ULONG WINAPI NtUserGetSystemDpiForProcess( HANDLE process ); HMENU WINAPI NtUserGetSystemMenu( HWND hwnd, BOOL revert ); HDESK WINAPI NtUserGetThreadDesktop( DWORD thread );