Commit e2d3fc7c authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

win32u: Move process_rawinput_message() from user32.

parent 28a22120
...@@ -558,25 +558,6 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam ...@@ -558,25 +558,6 @@ BOOL unpack_dde_message( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam
return TRUE; return TRUE;
} }
BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data )
{
struct rawinput_thread_data *thread_data = rawinput_thread_data();
if (msg->message == WM_INPUT_DEVICE_CHANGE)
rawinput_update_device_list();
else
{
thread_data->buffer->header.dwSize = RAWINPUT_BUFFER_SIZE;
if (!rawinput_from_hardware_message( thread_data->buffer, msg_data )) return FALSE;
thread_data->hw_id = hw_id;
msg->lParam = (LPARAM)hw_id;
}
msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt );
return TRUE;
}
/*********************************************************************** /***********************************************************************
* SendMessageTimeoutW (USER32.@) * SendMessageTimeoutW (USER32.@)
*/ */
......
...@@ -297,7 +297,7 @@ static void enumerate_devices( DWORD type, const WCHAR *class ) ...@@ -297,7 +297,7 @@ static void enumerate_devices( DWORD type, const WCHAR *class )
NtClose( class_key ); NtClose( class_key );
} }
void rawinput_update_device_list(void) void CDECL rawinput_update_device_list(void)
{ {
DWORD idx; DWORD idx;
...@@ -362,124 +362,6 @@ struct rawinput_thread_data * WINAPI rawinput_thread_data(void) ...@@ -362,124 +362,6 @@ struct rawinput_thread_data * WINAPI rawinput_thread_data(void)
} }
BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data)
{
SIZE_T size;
rawinput->header.dwType = msg_data->rawinput.type;
if (msg_data->rawinput.type == RIM_TYPEMOUSE)
{
static const unsigned int button_flags[] =
{
0, /* MOUSEEVENTF_MOVE */
RI_MOUSE_LEFT_BUTTON_DOWN, /* MOUSEEVENTF_LEFTDOWN */
RI_MOUSE_LEFT_BUTTON_UP, /* MOUSEEVENTF_LEFTUP */
RI_MOUSE_RIGHT_BUTTON_DOWN, /* MOUSEEVENTF_RIGHTDOWN */
RI_MOUSE_RIGHT_BUTTON_UP, /* MOUSEEVENTF_RIGHTUP */
RI_MOUSE_MIDDLE_BUTTON_DOWN, /* MOUSEEVENTF_MIDDLEDOWN */
RI_MOUSE_MIDDLE_BUTTON_UP, /* MOUSEEVENTF_MIDDLEUP */
};
unsigned int i;
rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data) + sizeof(RAWMOUSE);
rawinput->header.hDevice = WINE_MOUSE_HANDLE;
rawinput->header.wParam = 0;
rawinput->data.mouse.usFlags = MOUSE_MOVE_RELATIVE;
rawinput->data.mouse.usButtonFlags = 0;
rawinput->data.mouse.usButtonData = 0;
for (i = 1; i < ARRAY_SIZE(button_flags); ++i)
{
if (msg_data->flags & (1 << i))
rawinput->data.mouse.usButtonFlags |= button_flags[i];
}
if (msg_data->flags & MOUSEEVENTF_WHEEL)
{
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_WHEEL;
rawinput->data.mouse.usButtonData = msg_data->rawinput.mouse.data;
}
if (msg_data->flags & MOUSEEVENTF_HWHEEL)
{
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_HORIZONTAL_WHEEL;
rawinput->data.mouse.usButtonData = msg_data->rawinput.mouse.data;
}
if (msg_data->flags & MOUSEEVENTF_XDOWN)
{
if (msg_data->rawinput.mouse.data == XBUTTON1)
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_DOWN;
else if (msg_data->rawinput.mouse.data == XBUTTON2)
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_DOWN;
}
if (msg_data->flags & MOUSEEVENTF_XUP)
{
if (msg_data->rawinput.mouse.data == XBUTTON1)
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_UP;
else if (msg_data->rawinput.mouse.data == XBUTTON2)
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_5_UP;
}
rawinput->data.mouse.ulRawButtons = 0;
rawinput->data.mouse.lLastX = msg_data->rawinput.mouse.x;
rawinput->data.mouse.lLastY = msg_data->rawinput.mouse.y;
rawinput->data.mouse.ulExtraInformation = msg_data->info;
}
else if (msg_data->rawinput.type == RIM_TYPEKEYBOARD)
{
rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data) + sizeof(RAWKEYBOARD);
rawinput->header.hDevice = WINE_KEYBOARD_HANDLE;
rawinput->header.wParam = 0;
rawinput->data.keyboard.MakeCode = msg_data->rawinput.kbd.scan;
rawinput->data.keyboard.Flags = msg_data->flags & KEYEVENTF_KEYUP ? RI_KEY_BREAK : RI_KEY_MAKE;
if (msg_data->flags & KEYEVENTF_EXTENDEDKEY) rawinput->data.keyboard.Flags |= RI_KEY_E0;
rawinput->data.keyboard.Reserved = 0;
switch (msg_data->rawinput.kbd.vkey)
{
case VK_LSHIFT:
case VK_RSHIFT:
rawinput->data.keyboard.VKey = VK_SHIFT;
rawinput->data.keyboard.Flags &= ~RI_KEY_E0;
break;
case VK_LCONTROL:
case VK_RCONTROL:
rawinput->data.keyboard.VKey = VK_CONTROL;
break;
case VK_LMENU:
case VK_RMENU:
rawinput->data.keyboard.VKey = VK_MENU;
break;
default:
rawinput->data.keyboard.VKey = msg_data->rawinput.kbd.vkey;
break;
}
rawinput->data.keyboard.Message = msg_data->rawinput.kbd.message;
rawinput->data.keyboard.ExtraInformation = msg_data->info;
}
else if (msg_data->rawinput.type == RIM_TYPEHID)
{
size = msg_data->size - sizeof(*msg_data);
if (size > rawinput->header.dwSize - sizeof(*rawinput)) return FALSE;
rawinput->header.dwSize = FIELD_OFFSET( RAWINPUT, data.hid.bRawData ) + size;
rawinput->header.hDevice = ULongToHandle( msg_data->rawinput.hid.device );
rawinput->header.wParam = 0;
rawinput->data.hid.dwCount = msg_data->rawinput.hid.count;
rawinput->data.hid.dwSizeHid = msg_data->rawinput.hid.length;
memcpy( rawinput->data.hid.bRawData, msg_data + 1, size );
}
else
{
FIXME("Unhandled rawinput type %#x.\n", msg_data->rawinput.type);
return FALSE;
}
return TRUE;
}
/*********************************************************************** /***********************************************************************
* GetRawInputDeviceList (USER32.@) * GetRawInputDeviceList (USER32.@)
*/ */
......
...@@ -724,7 +724,7 @@ POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) ...@@ -724,7 +724,7 @@ POINT point_win_to_phys_dpi( HWND hwnd, POINT pt )
/********************************************************************** /**********************************************************************
* point_phys_to_win_dpi * point_phys_to_win_dpi
*/ */
POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) static POINT point_phys_to_win_dpi( HWND hwnd, POINT pt )
{ {
return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd )); return map_dpi_point( pt, get_win_monitor_dpi( hwnd ), GetDpiForWindow( hwnd ));
} }
......
...@@ -162,7 +162,7 @@ static const struct user_callbacks user_funcs = ...@@ -162,7 +162,7 @@ static const struct user_callbacks user_funcs =
MENU_GetSysMenu, MENU_GetSysMenu,
notify_ime, notify_ime,
post_dde_message, post_dde_message,
process_rawinput_message, rawinput_update_device_list,
rawinput_device_get_usages, rawinput_device_get_usages,
SCROLL_SetStandardScrollPainted, SCROLL_SetStandardScrollPainted,
unpack_dde_message, unpack_dde_message,
......
...@@ -61,10 +61,9 @@ struct dce; ...@@ -61,10 +61,9 @@ struct dce;
struct tagWND; struct tagWND;
struct hardware_msg_data; 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 BOOL rawinput_device_get_usages(HANDLE handle, USAGE *usage_page, USAGE *usage);
extern struct rawinput_thread_data * WINAPI rawinput_thread_data(void); extern struct rawinput_thread_data * WINAPI rawinput_thread_data(void);
extern void rawinput_update_device_list(void); extern void CDECL rawinput_update_device_list(void);
extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, extern BOOL post_dde_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
DWORD type ) DECLSPEC_HIDDEN; DWORD type ) DECLSPEC_HIDDEN;
......
...@@ -61,7 +61,6 @@ extern UINT get_win_monitor_dpi( HWND hwnd ) DECLSPEC_HIDDEN; ...@@ -61,7 +61,6 @@ extern UINT get_win_monitor_dpi( HWND hwnd ) DECLSPEC_HIDDEN;
extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN; extern UINT get_thread_dpi(void) DECLSPEC_HIDDEN;
extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern POINT map_dpi_point( POINT pt, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN;
extern POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern POINT point_win_to_phys_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
extern POINT point_phys_to_win_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
extern POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN; extern POINT point_win_to_thread_dpi( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN; extern RECT map_dpi_rect( RECT rect, UINT dpi_from, UINT dpi_to ) DECLSPEC_HIDDEN;
extern RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN; extern RECT rect_win_to_thread_dpi( HWND hwnd, RECT rect ) DECLSPEC_HIDDEN;
......
...@@ -1602,7 +1602,7 @@ static BOOL process_hardware_message( MSG *msg, UINT hw_id, const struct hardwar ...@@ -1602,7 +1602,7 @@ static BOOL process_hardware_message( MSG *msg, UINT hw_id, const struct hardwar
context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE );
if (msg->message == WM_INPUT || msg->message == WM_INPUT_DEVICE_CHANGE) if (msg->message == WM_INPUT || msg->message == WM_INPUT_DEVICE_CHANGE)
ret = user_callbacks && user_callbacks->process_rawinput_message( msg, hw_id, msg_data ); ret = process_rawinput_message( msg, hw_id, msg_data );
else if (is_keyboard_message( msg->message )) else if (is_keyboard_message( msg->message ))
ret = process_keyboard_message( msg, hw_id, hwnd_filter, first, last, remove ); ret = process_keyboard_message( msg, hw_id, hwnd_filter, first, last, remove );
else if (is_mouse_message( msg->message )) else if (is_mouse_message( msg->message ))
......
...@@ -41,7 +41,7 @@ struct user_callbacks ...@@ -41,7 +41,7 @@ struct user_callbacks
void (CDECL *notify_ime)( HWND hwnd, UINT param ); void (CDECL *notify_ime)( HWND hwnd, UINT param );
BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid, BOOL (CDECL *post_dde_message)( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, DWORD dest_tid,
DWORD type ); DWORD type );
BOOL (CDECL *process_rawinput_message)( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data ); void (CDECL *rawinput_update_device_list)(void);
BOOL (CDECL *rawinput_device_get_usages)(HANDLE handle, USHORT *usage_page, USHORT *usage); BOOL (CDECL *rawinput_device_get_usages)(HANDLE handle, USHORT *usage_page, USHORT *usage);
void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible ); void (WINAPI *set_standard_scroll_painted)( HWND hwnd, INT bar, BOOL visible );
BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam, BOOL (CDECL *unpack_dde_message)( HWND hwnd, UINT message, WPARAM *wparam, LPARAM *lparam,
......
...@@ -334,3 +334,26 @@ UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data, ...@@ -334,3 +334,26 @@ UINT WINAPI NtUserGetRawInputData( HRAWINPUT rawinput, UINT command, void *data,
memcpy( data, thread_data->buffer, size ); memcpy( data, thread_data->buffer, size );
return size; return size;
} }
BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data )
{
struct rawinput_thread_data *thread_data;
if (!user_callbacks || !(thread_data = user_callbacks->get_rawinput_thread_data()))
return FALSE;
if (msg->message == WM_INPUT_DEVICE_CHANGE)
{
if (user_callbacks) user_callbacks->rawinput_update_device_list();
}
else
{
thread_data->buffer->header.dwSize = RAWINPUT_BUFFER_SIZE;
if (!rawinput_from_hardware_message( thread_data->buffer, msg_data )) return FALSE;
thread_data->hw_id = hw_id;
msg->lParam = (LPARAM)hw_id;
}
msg->pt = point_phys_to_win_dpi( msg->hwnd, msg->pt );
return TRUE;
}
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "wine/gdi_driver.h" #include "wine/gdi_driver.h"
#include "wine/unixlib.h" #include "wine/unixlib.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/server.h"
extern const struct user_callbacks *user_callbacks DECLSPEC_HIDDEN; extern const struct user_callbacks *user_callbacks DECLSPEC_HIDDEN;
...@@ -437,6 +438,9 @@ extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) ...@@ -437,6 +438,9 @@ extern LRESULT send_message( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam )
extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, extern LRESULT send_message_timeout( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
UINT flags, UINT timeout, PDWORD_PTR res_ptr, BOOL ansi ); UINT flags, UINT timeout, PDWORD_PTR res_ptr, BOOL ansi );
/* rawinput.c */
extern BOOL process_rawinput_message( MSG *msg, UINT hw_id, const struct hardware_msg_data *msg_data ) DECLSPEC_HIDDEN;
/* sysparams.c */ /* sysparams.c */
extern BOOL enable_thunk_lock DECLSPEC_HIDDEN; extern BOOL enable_thunk_lock DECLSPEC_HIDDEN;
extern DWORD process_layout DECLSPEC_HIDDEN; extern DWORD process_layout DECLSPEC_HIDDEN;
......
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