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

dinput: Avoid entering hook CS for rawinput messages.

parent 76a138c9
...@@ -234,6 +234,8 @@ static void input_thread_update_device_list( struct input_thread_state *state ) ...@@ -234,6 +234,8 @@ static void input_thread_update_device_list( struct input_thread_state *state )
if (device->dwCoopLevel & DISCL_EXCLUSIVE) rawinput_mouse.dwFlags |= RIDEV_NOLEGACY | RIDEV_CAPTUREMOUSE; if (device->dwCoopLevel & DISCL_EXCLUSIVE) rawinput_mouse.dwFlags |= RIDEV_NOLEGACY | RIDEV_CAPTUREMOUSE;
rawinput_mouse.dwFlags &= ~RIDEV_REMOVE; rawinput_mouse.dwFlags &= ~RIDEV_REMOVE;
rawinput_mouse.hwndTarget = di_em_win; rawinput_mouse.hwndTarget = di_em_win;
dinput_device_internal_addref( (state->devices[count] = device) );
if (++count >= INPUT_THREAD_MAX_DEVICES) break;
} }
LIST_FOR_EACH_ENTRY( device, &acquired_mouse_list, struct dinput_device, entry ) LIST_FOR_EACH_ENTRY( device, &acquired_mouse_list, struct dinput_device, entry )
{ {
...@@ -281,10 +283,10 @@ static void input_thread_update_device_list( struct input_thread_state *state ) ...@@ -281,10 +283,10 @@ static void input_thread_update_device_list( struct input_thread_state *state )
static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
{ {
struct dinput_device *impl; struct input_thread_state *state = input_thread_state;
RAWINPUT ri;
UINT size = sizeof(ri);
int rim = GET_RAWINPUT_CODE_WPARAM( wparam ); int rim = GET_RAWINPUT_CODE_WPARAM( wparam );
UINT i, size = sizeof(RAWINPUT);
RAWINPUT ri;
TRACE( "%p %d %Ix %Ix\n", hwnd, msg, wparam, lparam ); TRACE( "%p %d %Ix %Ix\n", hwnd, msg, wparam, lparam );
...@@ -295,17 +297,25 @@ static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR ...@@ -295,17 +297,25 @@ static LRESULT WINAPI di_em_win_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPAR
WARN( "Unable to read raw input data\n" ); WARN( "Unable to read raw input data\n" );
else if (ri.header.dwType == RIM_TYPEMOUSE) else if (ri.header.dwType == RIM_TYPEMOUSE)
{ {
EnterCriticalSection( &dinput_hook_crit ); for (i = state->events_count; i < state->devices_count; ++i)
LIST_FOR_EACH_ENTRY( impl, &acquired_rawmouse_list, struct dinput_device, entry ) {
dinput_mouse_rawinput_hook( &impl->IDirectInputDevice8W_iface, wparam, lparam, &ri ); struct dinput_device *device = state->devices[i];
LeaveCriticalSection( &dinput_hook_crit ); if (!device->use_raw_input) continue;
if (device->instance.dwDevType & DIDEVTYPE_HID) continue;
switch (GET_DIDEVICE_TYPE( device->instance.dwDevType ))
{
case DIDEVTYPE_MOUSE:
case DI8DEVTYPE_MOUSE:
dinput_mouse_rawinput_hook( &device->IDirectInputDevice8W_iface, wparam, lparam, &ri );
break;
default: break;
}
}
} }
} }
if (msg == WM_USER + 0x10) if (msg == WM_USER + 0x10)
{ {
struct input_thread_state *state = input_thread_state;
TRACE( "Processing hook change notification wparam %#Ix, lparam %#Ix.\n", wparam, lparam ); TRACE( "Processing hook change notification wparam %#Ix, lparam %#Ix.\n", wparam, lparam );
if (!wparam) state->running = FALSE; if (!wparam) state->running = FALSE;
...@@ -349,9 +359,8 @@ static DWORD WINAPI dinput_thread_proc( void *params ) ...@@ -349,9 +359,8 @@ static DWORD WINAPI dinput_thread_proc( void *params )
DWORD ret; DWORD ret;
MSG msg; MSG msg;
input_thread_state = &state;
di_em_win = CreateWindowW( L"DIEmWin", L"DIEmWin", 0, 0, 0, 0, 0, HWND_MESSAGE, 0, DINPUT_instance, NULL ); di_em_win = CreateWindowW( L"DIEmWin", L"DIEmWin", 0, 0, 0, 0, 0, HWND_MESSAGE, 0, DINPUT_instance, NULL );
PeekMessageW( &msg, 0, 0, 0, PM_NOREMOVE ); input_thread_state = &state;
SetEvent( start_event ); SetEvent( start_event );
while (state.running && (ret = MsgWaitForMultipleObjectsEx( state.events_count, state.events, INFINITE, QS_ALLINPUT, 0 )) <= state.events_count) while (state.running && (ret = MsgWaitForMultipleObjectsEx( state.events_count, state.events, INFINITE, QS_ALLINPUT, 0 )) <= state.events_count)
......
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