From: R��mi Bernon rbernon@codeweavers.com
--- dlls/win32u/rawinput.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index 34accc3c4a0..b391bca1370 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -196,9 +196,9 @@ static bool rawinput_from_hardware_message( RAWINPUT *rawinput, const struct har
struct device { - WCHAR *path; HANDLE file; HANDLE handle; + WCHAR path[MAX_PATH]; RID_DEVICE_INFO info; struct hid_preparsed_data *data; }; @@ -238,7 +238,7 @@ static bool array_reserve( void **elements, unsigned int *capacity, unsigned int static struct device *add_device( HKEY key, DWORD type ) { static const WCHAR symbolic_linkW[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}; - char value_buffer[4096]; + char value_buffer[offsetof(KEY_VALUE_PARTIAL_INFORMATION, Data[MAX_PATH * sizeof(WCHAR)])]; KEY_VALUE_PARTIAL_INFORMATION *value = (KEY_VALUE_PARTIAL_INFORMATION *)value_buffer; static const RID_DEVICE_INFO_KEYBOARD keyboard_info = {0, 0, 1, 12, 3, 101}; static const RID_DEVICE_INFO_MOUSE mouse_info = {1, 5, 0, FALSE}; @@ -249,27 +249,24 @@ static struct device *add_device( HKEY key, DWORD type ) struct device *device; RID_DEVICE_INFO info; IO_STATUS_BLOCK io; - WCHAR *path, *pos; NTSTATUS status; unsigned int i; UINT32 handle; void *buffer; SIZE_T size; HANDLE file; + WCHAR *path;
- if (!query_reg_value( key, symbolic_linkW, value, sizeof(value_buffer) )) + if (!query_reg_value( key, symbolic_linkW, value, sizeof(value_buffer) - sizeof(WCHAR) )) { ERR( "failed to get symbolic link value\n" ); return NULL; } - - if (!(path = malloc( value->DataLength + sizeof(WCHAR) ))) - return NULL; - memcpy( path, value->Data, value->DataLength ); - path[value->DataLength / sizeof(WCHAR)] = 0; + memset( value->Data + value->DataLength, 0, sizeof(WCHAR) );
/* upper case everything but the GUID */ - for (pos = path; *pos && *pos != '{'; pos++) *pos = towupper( *pos ); + for (path = (WCHAR *)value->Data; *path && *path != '{'; path++) *path = towupper( *path ); + path = (WCHAR *)value->Data;
/* path is in DOS format and begins with \?\ prefix */ path[1] = '?'; @@ -280,7 +277,6 @@ static struct device *add_device( HKEY key, DWORD type ) FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT ))) { ERR( "Failed to open device file %s, status %#x.\n", debugstr_w(path), status ); - free( path ); return NULL; }
@@ -376,7 +372,7 @@ static struct device *add_device( HKEY key, DWORD type ) goto fail; }
- device->path = path; + wcscpy( device->path, path ); device->file = file; device->handle = ULongToHandle(handle); device->info = info; @@ -387,7 +383,6 @@ static struct device *add_device( HKEY key, DWORD type ) fail: free( preparsed ); NtClose( file ); - free( path ); return NULL; }
@@ -466,7 +461,6 @@ static void rawinput_update_device_list(void) { free( rawinput_devices[i].data ); NtClose( rawinput_devices[i].file ); - free( rawinput_devices[i].path ); } rawinput_devices_count = 0;
From: R��mi Bernon rbernon@codeweavers.com
--- dlls/win32u/rawinput.c | 109 ++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 72 deletions(-)
diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index b391bca1370..b2698d5eb3e 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -198,43 +198,15 @@ struct device { HANDLE file; HANDLE handle; + struct list entry; WCHAR path[MAX_PATH]; RID_DEVICE_INFO info; struct hid_preparsed_data *data; };
-static struct device *rawinput_devices; -static unsigned int rawinput_devices_count, rawinput_devices_max; - +static struct list devices = LIST_INIT( devices ); static pthread_mutex_t rawinput_mutex = PTHREAD_MUTEX_INITIALIZER;
-static bool array_reserve( void **elements, unsigned int *capacity, unsigned int count, unsigned int size ) -{ - unsigned int new_capacity, max_capacity; - void *new_elements; - - if (count <= *capacity) - return true; - - max_capacity = ~(unsigned int)0 / size; - if (count > max_capacity) - return false; - - new_capacity = max( 4, *capacity ); - while (new_capacity < count && new_capacity <= max_capacity / 2) - new_capacity *= 2; - if (new_capacity < count) - new_capacity = max_capacity; - - if (!(new_elements = realloc( *elements, new_capacity * size ))) - return false; - - *elements = new_elements; - *capacity = new_capacity; - - return true; -} - static struct device *add_device( HKEY key, DWORD type ) { static const WCHAR symbolic_linkW[] = {'S','y','m','b','o','l','i','c','L','i','n','k',0}; @@ -250,7 +222,6 @@ static struct device *add_device( HKEY key, DWORD type ) RID_DEVICE_INFO info; IO_STATUS_BLOCK io; NTSTATUS status; - unsigned int i; UINT32 handle; void *buffer; SIZE_T size; @@ -290,9 +261,9 @@ static struct device *add_device( HKEY key, DWORD type ) goto fail; }
- for (i = 0; i < rawinput_devices_count; ++i) + LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry ) { - if (rawinput_devices[i].handle == UlongToHandle(handle)) + if (device->handle == UlongToHandle( handle )) { TRACE( "Ignoring already added device %#x / %s.\n", handle, debugstr_w(path) ); goto fail; @@ -360,23 +331,19 @@ static struct device *add_device( HKEY key, DWORD type ) break; }
- if (array_reserve( (void **)&rawinput_devices, &rawinput_devices_max, - rawinput_devices_count + 1, sizeof(*rawinput_devices) )) - { - device = &rawinput_devices[rawinput_devices_count++]; - TRACE( "Adding device %#x / %s.\n", handle, debugstr_w(path) ); - } - else + if (!(device = calloc( 1, sizeof(*device) ))) { ERR( "Failed to allocate memory.\n" ); goto fail; }
+ TRACE( "Adding device %#x / %s.\n", handle, debugstr_w(path) ); wcscpy( device->path, path ); device->file = file; device->handle = ULongToHandle(handle); device->info = info; device->data = preparsed; + list_add_tail( &devices, &device->entry );
return device;
@@ -452,17 +419,17 @@ static void enumerate_devices( DWORD type, const WCHAR *class )
static void rawinput_update_device_list(void) { - unsigned int i; + struct device *device, *next;
TRACE( "\n" );
- /* destroy previous list */ - for (i = 0; i < rawinput_devices_count; ++i) + LIST_FOR_EACH_ENTRY_SAFE( device, next, &devices, struct device, entry ) { - free( rawinput_devices[i].data ); - NtClose( rawinput_devices[i].file ); + list_remove( &device->entry ); + NtClose( device->file ); + free( device->data ); + free( device ); } - rawinput_devices_count = 0;
enumerate_devices( RIM_TYPEMOUSE, guid_devinterface_mouseW ); enumerate_devices( RIM_TYPEKEYBOARD, guid_devinterface_keyboardW ); @@ -471,21 +438,16 @@ static void rawinput_update_device_list(void)
static struct device *find_device_from_handle( HANDLE handle ) { - unsigned int i; + struct device *device;
- for (i = 0; i < rawinput_devices_count; ++i) - { - if (rawinput_devices[i].handle == handle) - return rawinput_devices + i; - } + LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry ) + if (device->handle == handle) return device;
rawinput_update_device_list();
- for (i = 0; i < rawinput_devices_count; ++i) - { - if (rawinput_devices[i].handle == handle) - return rawinput_devices + i; - } + LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry ) + if (device->handle == handle) return device; + return NULL; }
@@ -511,14 +473,15 @@ BOOL rawinput_device_get_usages( HANDLE handle, USAGE *usage_page, USAGE *usage /********************************************************************** * NtUserGetRawInputDeviceList (win32u.@) */ -UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *devices, UINT *device_count, UINT size ) +UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *device_list, UINT *device_count, UINT size ) { + unsigned int count = 0, ticks = NtGetTickCount(); static unsigned int last_check; - unsigned int i, ticks = NtGetTickCount(); + struct device *device;
- TRACE("devices %p, device_count %p, size %u.\n", devices, device_count, size); + TRACE( "device_list %p, device_count %p, size %u.\n", device_list, device_count, size );
- if (size != sizeof(*devices)) + if (size != sizeof(*device_list)) { SetLastError( ERROR_INVALID_PARAMETER ); return ~0u; @@ -538,28 +501,30 @@ UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *devices, UINT *devi rawinput_update_device_list(); }
+ LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry ) + { + if (*device_count < ++count || !device_list) continue; + device_list->hDevice = device->handle; + device_list->dwType = device->info.dwType; + device_list++; + } + pthread_mutex_unlock( &rawinput_mutex );
- if (!devices) + if (!device_list) { - *device_count = rawinput_devices_count; + *device_count = count; return 0; }
- if (*device_count < rawinput_devices_count) + if (*device_count < count) { SetLastError( ERROR_INSUFFICIENT_BUFFER ); - *device_count = rawinput_devices_count; + *device_count = count; return ~0u; }
- for (i = 0; i < rawinput_devices_count; ++i) - { - devices[i].hDevice = rawinput_devices[i].handle; - devices[i].dwType = rawinput_devices[i].info.dwType; - } - - return rawinput_devices_count; + return count; }
/**********************************************************************
From: R��mi Bernon rbernon@codeweavers.com
--- dlls/win32u/rawinput.c | 117 ++++++++++++++++++++++++----------------- server/protocol.def | 7 --- server/queue.c | 21 -------- 3 files changed, 70 insertions(+), 75 deletions(-)
diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index b2698d5eb3e..683641afeaf 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -204,6 +204,8 @@ struct device struct hid_preparsed_data *data; };
+static RAWINPUTDEVICE *registered_devices; +static unsigned int registered_device_count; static struct list devices = LIST_INIT( devices ); static pthread_mutex_t rawinput_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -783,26 +785,59 @@ BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_d return TRUE; }
+static void register_rawinput_device( const RAWINPUTDEVICE *device ) +{ + RAWINPUTDEVICE *pos, *end; + + for (pos = registered_devices, end = pos + registered_device_count; pos != end; pos++) + { + if (pos->usUsagePage < device->usUsagePage) continue; + if (pos->usUsagePage > device->usUsagePage) break; + if (pos->usUsage >= device->usUsage) break; + } + + if (device->dwFlags & RIDEV_REMOVE) + { + if (pos != end && pos->usUsagePage == device->usUsagePage && pos->usUsage == device->usUsage) + { + memmove( pos, pos + 1, (char *)end - (char *)(pos + 1) ); + registered_device_count--; + } + } + else + { + if (pos == end || pos->usUsagePage != device->usUsagePage || pos->usUsage != device->usUsage) + { + memmove( pos + 1, pos, (char *)end - (char *)pos ); + registered_device_count++; + } + *pos = *device; + } +} + /********************************************************************** * NtUserRegisterRawInputDevices (win32u.@) */ -BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT device_count, UINT size ) +BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT device_count, UINT device_size ) { struct rawinput_device *server_devices; + SIZE_T size; BOOL ret; UINT i;
- TRACE( "devices %p, device_count %u, size %u.\n", devices, device_count, size ); + TRACE( "devices %p, device_count %u, device_size %u.\n", devices, device_count, device_size );
- if (size != sizeof(*devices)) + if (device_size != sizeof(RAWINPUTDEVICE)) { - WARN( "Invalid structure size %u.\n", size ); SetLastError( ERROR_INVALID_PARAMETER ); 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_INPUTSINK) && !devices[i].hwndTarget) { SetLastError( ERROR_INVALID_PARAMETER ); @@ -814,17 +849,29 @@ BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT d SetLastError( ERROR_INVALID_PARAMETER ); return FALSE; } + + if (devices[i].dwFlags & ~(RIDEV_REMOVE|RIDEV_NOLEGACY|RIDEV_INPUTSINK|RIDEV_DEVNOTIFY)) + FIXME( "Unhandled flags %#x for device %u.\n", devices[i].dwFlags, i ); + } + + pthread_mutex_lock( &rawinput_mutex ); + + size = (SIZE_T)device_size * (registered_device_count + device_count); + registered_devices = realloc( registered_devices, size ); + if (registered_devices) for (i = 0; i < device_count; ++i) register_rawinput_device( devices + i ); + + pthread_mutex_unlock( &rawinput_mutex ); + + if (!registered_devices) + { + SetLastError( ERROR_OUTOFMEMORY ); + 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; @@ -844,61 +891,37 @@ BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT d return ret; }
-static int compare_raw_input_devices( const void *ap, const void *bp ) -{ - const RAWINPUTDEVICE a = *(const RAWINPUTDEVICE *)ap; - const RAWINPUTDEVICE b = *(const RAWINPUTDEVICE *)bp; - - if (a.usUsagePage != b.usUsagePage) return a.usUsagePage - b.usUsagePage; - if (a.usUsage != b.usUsage) return a.usUsage - b.usUsage; - return 0; -} - /********************************************************************** * NtUserGetRegisteredRawInputDevices (win32u.@) */ -UINT WINAPI NtUserGetRegisteredRawInputDevices( RAWINPUTDEVICE *devices, UINT *device_count, UINT size ) +UINT WINAPI NtUserGetRegisteredRawInputDevices( RAWINPUTDEVICE *devices, UINT *device_count, UINT device_size ) { - struct rawinput_device *buffer = NULL; - unsigned int i, status, buffer_size; + SIZE_T size, capacity;
- TRACE("devices %p, device_count %p, size %u\n", devices, device_count, size); + TRACE( "devices %p, device_count %p, device_size %u\n", devices, device_count, device_size );
- if (size != sizeof(RAWINPUTDEVICE) || !device_count || (devices && !*device_count)) + if (device_size != sizeof(RAWINPUTDEVICE) || !device_count || (devices && !*device_count)) { SetLastError( ERROR_INVALID_PARAMETER ); return ~0u; }
- buffer_size = *device_count * sizeof(*buffer); - if (devices && !(buffer = malloc( buffer_size ))) - return ~0u; + pthread_mutex_lock( &rawinput_mutex );
- SERVER_START_REQ(get_rawinput_devices) - { - if (buffer) wine_server_set_reply( req, buffer, buffer_size ); - status = wine_server_call_err(req); - *device_count = reply->device_count; - } - SERVER_END_REQ; - if (status) - { - free( buffer ); - return ~0u; - } + capacity = *device_count * device_size; + *device_count = registered_device_count; + size = (SIZE_T)device_size * *device_count; + if (devices && capacity >= size) memcpy( devices, registered_devices, size ); + + pthread_mutex_unlock( &rawinput_mutex );
if (!devices) return 0;
- for (i = 0; i < *device_count; ++i) + if (capacity < size) { - devices[i].usUsagePage = buffer[i].usage_page; - devices[i].usUsage = buffer[i].usage; - devices[i].dwFlags = buffer[i].flags; - devices[i].hwndTarget = wine_server_ptr_handle(buffer[i].target); + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return ~0u; }
- qsort( devices, *device_count, sizeof(*devices), compare_raw_input_devices ); - - free( buffer ); return *device_count; } diff --git a/server/protocol.def b/server/protocol.def index a8044582ef8..d828d41d1f7 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -3676,13 +3676,6 @@ struct handle_info VARARG(devices,rawinput_devices); @END
-/* Retrieve the list of registered rawinput devices */ -@REQ(get_rawinput_devices) -@REPLY - unsigned int device_count; - VARARG(devices,rawinput_devices); -@END - /* Create a new job object */ @REQ(create_job) unsigned int access; /* wanted access rights */ diff --git a/server/queue.c b/server/queue.c index 934cf358059..09636b762dd 100644 --- a/server/queue.c +++ b/server/queue.c @@ -3412,24 +3412,3 @@ DECL_HANDLER(update_rawinput_devices) e = find_rawinput_device( current->process, 1, 6 ); current->process->rawinput_kbd = e ? &e->device : NULL; } - -DECL_HANDLER(get_rawinput_devices) -{ - struct rawinput_device_entry *e; - struct rawinput_device *devices; - unsigned int i = 0, device_count = list_count( ¤t->process->rawinput_devices ); - unsigned int size = device_count * sizeof(*devices); - - reply->device_count = device_count; - - /* no buffer provided, nothing else to do */ - if (!get_reply_max_size()) return; - - if (size > get_reply_max_size()) - set_error( STATUS_BUFFER_TOO_SMALL ); - else if ((devices = set_reply_data_size( size ))) - { - LIST_FOR_EACH_ENTRY( e, ¤t->process->rawinput_devices, struct rawinput_device_entry, entry ) - devices[i++] = e->device; - } -}
From: R��mi Bernon rbernon@codeweavers.com
--- dlls/win32u/rawinput.c | 24 +++++++++--------- server/process.c | 12 +++------ server/process.h | 9 ++----- server/queue.c | 56 ++++++++++++++---------------------------- 4 files changed, 34 insertions(+), 67 deletions(-)
diff --git a/dlls/win32u/rawinput.c b/dlls/win32u/rawinput.c index 683641afeaf..8e3f3ace15a 100644 --- a/dlls/win32u/rawinput.c +++ b/dlls/win32u/rawinput.c @@ -860,29 +860,27 @@ BOOL WINAPI NtUserRegisterRawInputDevices( const RAWINPUTDEVICE *devices, UINT d registered_devices = realloc( registered_devices, size ); if (registered_devices) for (i = 0; i < device_count; ++i) register_rawinput_device( devices + i );
- pthread_mutex_unlock( &rawinput_mutex ); - - if (!registered_devices) + server_devices = malloc( registered_device_count * sizeof(*server_devices) ); + if (server_devices) for (i = 0; i < registered_device_count; ++i) { - SetLastError( ERROR_OUTOFMEMORY ); - return FALSE; + server_devices[i].usage_page = registered_devices[i].usUsagePage; + server_devices[i].usage = registered_devices[i].usUsage; + server_devices[i].flags = registered_devices[i].dwFlags; + server_devices[i].target = wine_server_user_handle( registered_devices[i].hwndTarget ); }
- if (!(server_devices = malloc( device_count * sizeof(*server_devices) ))) return FALSE; + pthread_mutex_unlock( &rawinput_mutex );
- for (i = 0; i < device_count; ++i) + if (!registered_devices || !server_devices) { - - 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 ); + SetLastError( ERROR_OUTOFMEMORY ); + return FALSE; }
SERVER_START_REQ( update_rawinput_devices ) { wine_server_add_data( req, server_devices, device_count * sizeof(*server_devices) ); - ret = !wine_server_call( req ); + ret = !wine_server_call_err( req ); } SERVER_END_REQ;
diff --git a/server/process.c b/server/process.c index d1407204718..9bde05dc942 100644 --- a/server/process.c +++ b/server/process.c @@ -678,6 +678,8 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla process->desktop = 0; process->token = NULL; process->trace_data = 0; + process->rawinput_devices = NULL; + process->rawinput_device_count = 0; process->rawinput_mouse = NULL; process->rawinput_kbd = NULL; memset( &process->image_info, 0, sizeof(process->image_info) ); @@ -687,7 +689,6 @@ struct process *create_process( int fd, struct process *parent, unsigned int fla list_init( &process->asyncs ); list_init( &process->classes ); list_init( &process->views ); - list_init( &process->rawinput_devices );
process->end_time = 0;
@@ -782,6 +783,7 @@ static void process_destroy( struct object *obj ) if (process->idle_event) release_object( process->idle_event ); if (process->id) free_ptid( process->id ); if (process->token) release_object( process->token ); + free( process->rawinput_devices ); free( process->dir_cache ); free( process->image ); } @@ -959,8 +961,6 @@ void kill_console_processes( struct thread *renderer, int exit_code ) /* a process has been killed (i.e. its last thread died) */ static void process_killed( struct process *process ) { - struct list *ptr; - assert( list_empty( &process->thread_list )); process->end_time = current_time; close_process_desktop( process ); @@ -972,12 +972,6 @@ static void process_killed( struct process *process ) process->idle_event = NULL; assert( !process->console );
- while ((ptr = list_head( &process->rawinput_devices ))) - { - struct rawinput_device_entry *entry = LIST_ENTRY( ptr, struct rawinput_device_entry, entry ); - list_remove( &entry->entry ); - free( entry ); - } destroy_process_classes( process ); free_mapped_views( process ); free_process_user_handles( process ); diff --git a/server/process.h b/server/process.h index 632faf9c4bf..97e0d455ece 100644 --- a/server/process.h +++ b/server/process.h @@ -33,12 +33,6 @@ enum startup_state { STARTUP_IN_PROGRESS, STARTUP_DONE, STARTUP_ABORTED };
/* process structures */
-struct rawinput_device_entry -{ - struct list entry; - struct rawinput_device device; -}; - struct process { struct object obj; /* object header */ @@ -85,7 +79,8 @@ struct process client_ptr_t ldt_copy; /* pointer to LDT copy in client addr space */ struct dir_cache *dir_cache; /* map of client-side directory cache */ unsigned int trace_data; /* opaque data used by the process tracing mechanism */ - struct list rawinput_devices;/* list of registered rawinput devices */ + struct rawinput_device *rawinput_devices; /* list of registered rawinput devices */ + unsigned int rawinput_device_count; /* number of registered rawinput devices */ const struct rawinput_device *rawinput_mouse; /* rawinput mouse device, if any */ const struct rawinput_device *rawinput_kbd; /* rawinput keyboard device, if any */ struct list kernel_object; /* list of kernel object pointers */ diff --git a/server/queue.c b/server/queue.c index 09636b762dd..d98d645065f 100644 --- a/server/queue.c +++ b/server/queue.c @@ -1532,40 +1532,19 @@ static user_handle_t find_hardware_message_window( struct desktop *desktop, stru return win; }
-static struct rawinput_device_entry *find_rawinput_device( struct process *process, unsigned short usage_page, unsigned short usage ) +static struct rawinput_device *find_rawinput_device( struct process *process, unsigned short usage_page, unsigned short usage ) { - struct rawinput_device_entry *e; + struct rawinput_device *device, *end;
- LIST_FOR_EACH_ENTRY( e, &process->rawinput_devices, struct rawinput_device_entry, entry ) + for (device = process->rawinput_devices, end = device + process->rawinput_device_count; device != end; device++) { - if (e->device.usage_page != usage_page || e->device.usage != usage) continue; - return e; + if (device->usage_page != usage_page || device->usage != usage) continue; + return device; }
return NULL; }
-static void update_rawinput_device(const struct rawinput_device *device) -{ - struct rawinput_device_entry *e; - - if (!(e = find_rawinput_device( current->process, device->usage_page, device->usage ))) - { - if (!(e = mem_alloc( sizeof(*e) ))) return; - list_add_tail( ¤t->process->rawinput_devices, &e->entry ); - } - - if (device->flags & RIDEV_REMOVE) - { - list_remove( &e->entry ); - free( e ); - return; - } - - e->device = *device; - e->device.target = get_user_full_handle( e->device.target ); -} - static void prepend_cursor_history( int x, int y, unsigned int time, lparam_t info ) { cursor_pos_t *pos = &cursor_history[--cursor_history_latest % ARRAY_SIZE(cursor_history)]; @@ -1714,7 +1693,6 @@ struct rawinput_message static int queue_rawinput_message( struct process* process, void *arg ) { const struct rawinput_message* raw_msg = arg; - const struct rawinput_device_entry *entry; const struct rawinput_device *device = NULL; struct desktop *target_desktop = NULL, *desktop = NULL; struct thread *target_thread = NULL, *foreground = NULL; @@ -1726,8 +1704,8 @@ static int queue_rawinput_message( struct process* process, void *arg ) device = process->rawinput_mouse; else if (raw_msg->data.rawinput.type == RIM_TYPEKEYBOARD) device = process->rawinput_kbd; - else if ((entry = find_rawinput_device( process, raw_msg->data.rawinput.hid.usage_page, raw_msg->data.rawinput.hid.usage ))) - device = &entry->device; + else + device = find_rawinput_device( process, raw_msg->data.rawinput.hid.usage_page, raw_msg->data.rawinput.hid.usage ); if (!device) return 0;
if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && !(device->flags & RIDEV_DEVNOTIFY)) return 0; @@ -3397,18 +3375,20 @@ DECL_HANDLER(get_rawinput_buffer)
DECL_HANDLER(update_rawinput_devices) { - const struct rawinput_device *devices = get_req_data(); + const struct rawinput_device *tmp, *devices = get_req_data(); unsigned int device_count = get_req_data_size() / sizeof (*devices); - const struct rawinput_device_entry *e; - unsigned int i; + size_t size = device_count * sizeof(*devices); + struct process *process = current->process;
- for (i = 0; i < device_count; ++i) + if (!(tmp = realloc( process->rawinput_devices, size ))) { - update_rawinput_device(&devices[i]); + set_error( STATUS_NO_MEMORY ); + return; } + process->rawinput_devices = (struct rawinput_device *)tmp; + process->rawinput_device_count = device_count; + memcpy( process->rawinput_devices, devices, size );
- e = find_rawinput_device( current->process, 1, 2 ); - current->process->rawinput_mouse = e ? &e->device : NULL; - e = find_rawinput_device( current->process, 1, 6 ); - current->process->rawinput_kbd = e ? &e->device : NULL; + process->rawinput_mouse = find_rawinput_device( process, 1, 2 ); + process->rawinput_kbd = find_rawinput_device( process, 1, 6 ); }
From: R��mi Bernon rbernon@codeweavers.com
--- MAINTAINERS | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/MAINTAINERS b/MAINTAINERS index ec871697dbf..5e853e939a9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -160,8 +160,8 @@ M: Zebediah Figura z.figura12@gmail.com F: dlls/winegstreamer/
HID support -M: Aric Stewart aric@codeweavers.com -P: R��mi Bernon rbernon@codeweavers.com +M: R��mi Bernon rbernon@codeweavers.com +P: Aric Stewart aric@codeweavers.com F: dlls/hid/ F: dlls/hidclass.sys/ F: dlls/hidparse.sys/ @@ -173,9 +173,10 @@ F: dlls/httpapi/ F: dlls/http.sys/
Input events -P: R��mi Bernon rbernon@codeweavers.com +M: R��mi Bernon rbernon@codeweavers.com F: dlls/user32/input.c -F: dlls/user32/rawinput.c +F: dlls/win32u/input.c +F: dlls/win32u/rawinput.c F: server/queue.c
Input methods @@ -193,6 +194,7 @@ F: dlls/windows.gaming.input/ F: dlls/winebus.sys/ F: dlls/winexinput.sys/ F: dlls/xinput*/ +F: dlls/winmm/joystick.c
Media format conversion P: Andrew Eikum coldpie@fastmail.com