Commit 464ce9a0 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

win32u: Move rawinput device cache ticks check to rawinput_update_device_list.

parent f333f4cd
...@@ -282,12 +282,17 @@ static void enumerate_devices( DWORD type, const WCHAR *class ) ...@@ -282,12 +282,17 @@ static void enumerate_devices( DWORD type, const WCHAR *class )
NtClose( class_key ); NtClose( class_key );
} }
static void rawinput_update_device_list(void) static void rawinput_update_device_list( BOOL force )
{ {
unsigned int ticks = NtGetTickCount();
static unsigned int last_check;
struct device *device, *next; struct device *device, *next;
TRACE( "\n" ); TRACE( "\n" );
if (ticks - last_check <= 2000 && !force) return;
last_check = ticks;
LIST_FOR_EACH_ENTRY_SAFE( device, next, &devices, struct device, entry ) LIST_FOR_EACH_ENTRY_SAFE( device, next, &devices, struct device, entry )
{ {
list_remove( &device->entry ); list_remove( &device->entry );
...@@ -309,7 +314,7 @@ static struct device *find_device_from_handle( HANDLE handle, BOOL refresh ) ...@@ -309,7 +314,7 @@ static struct device *find_device_from_handle( HANDLE handle, BOOL refresh )
if (device->handle == handle) return device; if (device->handle == handle) return device;
if (!refresh) return NULL; if (!refresh) return NULL;
rawinput_update_device_list(); rawinput_update_device_list( TRUE );
LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry ) LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry )
if (device->handle == handle) return device; if (device->handle == handle) return device;
...@@ -322,8 +327,7 @@ static struct device *find_device_from_handle( HANDLE handle, BOOL refresh ) ...@@ -322,8 +327,7 @@ static struct device *find_device_from_handle( HANDLE handle, BOOL refresh )
*/ */
UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *device_list, UINT *device_count, UINT size ) UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *device_list, UINT *device_count, UINT size )
{ {
unsigned int count = 0, ticks = NtGetTickCount(); unsigned int count = 0;
static unsigned int last_check;
struct device *device; struct device *device;
TRACE( "device_list %p, device_count %p, size %u.\n", device_list, device_count, size ); TRACE( "device_list %p, device_count %p, size %u.\n", device_list, device_count, size );
...@@ -342,11 +346,7 @@ UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *device_list, UINT * ...@@ -342,11 +346,7 @@ UINT WINAPI NtUserGetRawInputDeviceList( RAWINPUTDEVICELIST *device_list, UINT *
pthread_mutex_lock( &rawinput_mutex ); pthread_mutex_lock( &rawinput_mutex );
if (ticks - last_check > 2000) rawinput_update_device_list( FALSE );
{
last_check = ticks;
rawinput_update_device_list();
}
LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry ) LIST_FOR_EACH_ENTRY( device, &devices, struct device, entry )
{ {
......
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