Commit 0ce4ed67 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

win32u: Move NtUserRegisterRawInputDevices from user32.

parent e06a6204
......@@ -402,69 +402,6 @@ UINT WINAPI GetRawInputDeviceList(RAWINPUTDEVICELIST *devices, UINT *device_coun
}
/***********************************************************************
* RegisterRawInputDevices (USER32.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH RegisterRawInputDevices(const RAWINPUTDEVICE *devices, UINT device_count, UINT size)
{
struct rawinput_device *d;
BOOL ret;
UINT i;
TRACE("devices %p, device_count %u, size %u.\n", devices, device_count, size);
if (size != sizeof(*devices))
{
WARN("Invalid structure size %u.\n", size);
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
for (i = 0; i < device_count; ++i)
{
if ((devices[i].dwFlags & RIDEV_INPUTSINK) &&
(devices[i].hwndTarget == NULL))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
if ((devices[i].dwFlags & RIDEV_REMOVE) &&
(devices[i].hwndTarget != NULL))
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
}
if (!(d = HeapAlloc( GetProcessHeap(), 0, device_count * sizeof(*d) ))) return FALSE;
for (i = 0; i < device_count; ++i)
{
TRACE("device %u: page %#x, usage %#x, flags %#lx, target %p.\n",
i, devices[i].usUsagePage, devices[i].usUsage,
devices[i].dwFlags, devices[i].hwndTarget);
if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY|RIDEV_INPUTSINK|RIDEV_DEVNOTIFY))
FIXME("Unhandled flags %#lx for device %u.\n", devices[i].dwFlags, i);
d[i].usage_page = devices[i].usUsagePage;
d[i].usage = devices[i].usUsage;
d[i].flags = devices[i].dwFlags;
d[i].target = wine_server_user_handle( devices[i].hwndTarget );
}
SERVER_START_REQ( update_rawinput_devices )
{
wine_server_add_data( req, d, device_count * sizeof(*d) );
ret = !wine_server_call( req );
}
SERVER_END_REQ;
HeapFree( GetProcessHeap(), 0, d );
return ret;
}
/***********************************************************************
* GetRawInputDeviceInfoA (USER32.@)
*/
UINT WINAPI GetRawInputDeviceInfoA(HANDLE device, UINT command, void *data, UINT *data_size)
......
......@@ -605,7 +605,7 @@
@ stub RegisterNetworkCapabilities
@ stdcall RegisterPointerDeviceNotifications(long long)
@ stdcall RegisterPowerSettingNotification(long ptr long)
@ stdcall RegisterRawInputDevices(ptr long long)
@ stdcall RegisterRawInputDevices(ptr long long) NtUserRegisterRawInputDevices
@ stdcall RegisterServicesProcess(long)
@ stdcall RegisterShellHookWindow (long)
@ stdcall RegisterSuspendResumeNotification(long long)
......
......@@ -366,3 +366,64 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d
msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt );
return TRUE;
}
/**********************************************************************
* NtUserRegisterRawInputDevices (win32u.@)
*/
BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT device_count, UINT size )
{
struct rawinput_device *server_devices;
BOOL ret;
UINT i;
TRACE( "devices %p, device_count %u, size %u.\n", devices, device_count, size );
if (size != sizeof(*devices))
{
WARN( "Invalid structure size %u.\n", size );
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
for (i = 0; i < device_count; ++i)
{
if ((devices[i].dwFlags & RIDEV_INPUTSINK) && !devices[i].hwndTarget)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if ((devices[i].dwFlags & RIDEV_REMOVE) && devices[i].hwndTarget)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
}
if (!(server_devices = malloc( device_count * sizeof(*server_devices) ))) return FALSE;
for (i = 0; i < device_count; ++i)
{
TRACE( "device %u: page %#x, usage %#x, flags %#x, target %p.\n",
i, devices[i].usUsagePage, devices[i].usUsage,
devices[i].dwFlags, devices[i].hwndTarget );
if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY|RIDEV_INPUTSINK|RIDEV_DEVNOTIFY))
FIXME( "Unhandled flags %#x for device %u.\n", devices[i].dwFlags, i );
server_devices[i].usage_page = devices[i].usUsagePage;
server_devices[i].usage = devices[i].usUsage;
server_devices[i].flags = devices[i].dwFlags;
server_devices[i].target = wine_server_user_handle( devices[i].hwndTarget );
}
SERVER_START_REQ( update_rawinput_devices )
{
wine_server_add_data( req, server_devices, device_count * sizeof(*server_devices) );
ret = !wine_server_call( req );
}
SERVER_END_REQ;
free( server_devices );
return ret;
}
......@@ -160,6 +160,7 @@ static void * const syscalls[] =
NtUserOpenDesktop,
NtUserOpenInputDesktop,
NtUserOpenWindowStation,
NtUserRegisterRawInputDevices,
NtUserRemoveClipboardFormatListener,
NtUserRemoveMenu,
NtUserRemoveProp,
......
......@@ -1130,7 +1130,7 @@
@ stub NtUserRegisterManipulationThread
@ stub NtUserRegisterPointerDeviceNotifications
@ stub NtUserRegisterPointerInputTarget
@ stub NtUserRegisterRawInputDevices
@ stdcall -syscall NtUserRegisterRawInputDevices(ptr long long)
@ stub NtUserRegisterServicesProcess
@ stub NtUserRegisterSessionPort
@ stub NtUserRegisterShellPTPListener
......
......@@ -147,6 +147,7 @@
SYSCALL_ENTRY( NtUserOpenDesktop ) \
SYSCALL_ENTRY( NtUserOpenInputDesktop ) \
SYSCALL_ENTRY( NtUserOpenWindowStation ) \
SYSCALL_ENTRY( NtUserRegisterRawInputDevices ) \
SYSCALL_ENTRY( NtUserRemoveClipboardFormatListener ) \
SYSCALL_ENTRY( NtUserRemoveMenu ) \
SYSCALL_ENTRY( NtUserRemoveProp ) \
......
......@@ -64,6 +64,14 @@ typedef struct
UINT32 wParam;
} RAWINPUTHEADER32;
typedef struct
{
USHORT usUsagePage;
USHORT usUsage;
DWORD dwFlags;
UINT32 hwndTarget;
} RAWINPUTDEVICE32;
static MSG *msg_32to64( MSG *msg, MSG32 *msg32 )
{
if (!msg32) return NULL;
......@@ -975,3 +983,35 @@ NTSTATUS WINAPI wow64_NtUserGetRawInputBuffer( UINT *args )
* whether it's operating under WoW64 or not. */
return NtUserGetRawInputBuffer( data, data_size, sizeof(RAWINPUTHEADER) );
}
NTSTATUS WINAPI wow64_NtUserRegisterRawInputDevices( UINT *args )
{
const RAWINPUTDEVICE32 *devices32 = get_ptr( &args );
UINT count = get_ulong( &args );
UINT size = get_ulong( &args );
RAWINPUTDEVICE *devices64;
unsigned int i;
if (size != sizeof(RAWINPUTDEVICE32))
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if (!(devices64 = Wow64AllocateTemp( count * sizeof(*devices64) )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
}
for (i = 0; i < count; ++i)
{
devices64[i].usUsagePage = devices32[i].usUsagePage;
devices64[i].usUsage = devices32[i].usUsage;
devices64[i].dwFlags = devices32[i].dwFlags;
devices64[i].hwndTarget = UlongToPtr( devices32[i].hwndTarget );
}
return NtUserRegisterRawInputDevices( devices64, count, sizeof(*devices64) );
}
......@@ -663,6 +663,7 @@ ATOM WINAPI NtUserRegisterClassExWOW( const WNDCLASSEXW *wc, UNICODE_STRING *
struct client_menu_name *client_menu_name, DWORD fnid, DWORD flags,
DWORD *wow );
BOOL WINAPI NtUserRegisterHotKey( HWND hwnd, INT id, UINT modifiers, UINT vk );
BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT device_count, UINT size );
INT WINAPI NtUserReleaseDC( HWND hwnd, HDC hdc );
BOOL WINAPI NtUserRemoveClipboardFormatListener( HWND hwnd );
BOOL WINAPI NtUserRemoveMenu( HMENU menu, UINT id, UINT flags );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment