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

server: Move rawinput message conversion from win32u.

Appending the entire RAWMOUSE / RAWKEYBOARD / RAWHID + report structs after the hardware message data, instead of using a custom intermediate structure.
parent 9a0e244d
...@@ -1915,7 +1915,6 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara ...@@ -1915,7 +1915,6 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
size = sizeof(buffer); size = sizeof(buffer);
memset( buffer, 0, sizeof(buffer) ); memset( buffer, 0, sizeof(buffer) );
todo_wine_if(is_wow64 && iteration == 1)
ok_ret( 3, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER)) ); ok_ret( 3, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER)) );
ok_eq( sizeof(buffer), size, UINT, "%u" ); ok_eq( sizeof(buffer), size, UINT, "%u" );
...@@ -1958,9 +1957,8 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara ...@@ -1958,9 +1957,8 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
* it needs one more byte to return success */ * it needs one more byte to return success */
size = sizeof(rawinput) + 1; size = sizeof(rawinput) + 1;
memset( buffer, 0, sizeof(buffer) ); memset( buffer, 0, sizeof(buffer) );
todo_wine_if(is_wow64)
ok_ret( 1, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) ); ok_ret( 1, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) );
if (is_wow64) todo_wine ok_eq( 5, rawbuffer64->data.keyboard.MakeCode, WPARAM, "%Iu" ); if (is_wow64) ok_eq( 5, rawbuffer64->data.keyboard.MakeCode, WPARAM, "%Iu" );
else ok_eq( 5, rawbuffer->data.keyboard.MakeCode, WPARAM, "%Iu" ); else ok_eq( 5, rawbuffer->data.keyboard.MakeCode, WPARAM, "%Iu" );
/* peek the messages now, they should still arrive in the correct order */ /* peek the messages now, they should still arrive in the correct order */
...@@ -2013,7 +2011,6 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara ...@@ -2013,7 +2011,6 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
size = sizeof(rawinput); size = sizeof(rawinput);
ok_ret( rawinput_size, GetRawInputData( handle, RID_INPUT, &rawinput, &size, sizeof(RAWINPUTHEADER) ) ); ok_ret( rawinput_size, GetRawInputData( handle, RID_INPUT, &rawinput, &size, sizeof(RAWINPUTHEADER) ) );
todo_wine_if(is_wow64)
ok_eq( 6, rawinput.data.keyboard.MakeCode, UINT, "%u" ); ok_eq( 6, rawinput.data.keyboard.MakeCode, UINT, "%u" );
SetLastError( 0xdeadbeef ); SetLastError( 0xdeadbeef );
...@@ -2027,7 +2024,6 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara ...@@ -2027,7 +2024,6 @@ static LRESULT CALLBACK rawinputbuffer_wndproc(HWND hwnd, UINT msg, WPARAM wpara
{ {
todo_wine todo_wine
ok_ret( rawinput_size, GetRawInputData( handle, RID_INPUT, &rawinput, &size, sizeof(RAWINPUTHEADER64) ) ); ok_ret( rawinput_size, GetRawInputData( handle, RID_INPUT, &rawinput, &size, sizeof(RAWINPUTHEADER64) ) );
todo_wine
ok_eq( 6, rawinput.data.keyboard.MakeCode, UINT, "%u" ); ok_eq( 6, rawinput.data.keyboard.MakeCode, UINT, "%u" );
todo_wine todo_wine
ok_ret( 0xdeadbeef, GetLastError() ); ok_ret( 0xdeadbeef, GetLastError() );
...@@ -2184,7 +2180,6 @@ static void test_GetRawInputBuffer(void) ...@@ -2184,7 +2180,6 @@ static void test_GetRawInputBuffer(void)
size = 0; size = 0;
ok_ret( 0, GetRawInputBuffer( NULL, &size, sizeof(RAWINPUTHEADER) ) ); ok_ret( 0, GetRawInputBuffer( NULL, &size, sizeof(RAWINPUTHEADER) ) );
todo_wine
ok_eq( rawinput_size, size, UINT, "%u" ); ok_eq( rawinput_size, size, UINT, "%u" );
size = sizeof(buffer); size = sizeof(buffer);
...@@ -2226,9 +2221,7 @@ static void test_GetRawInputBuffer(void) ...@@ -2226,9 +2221,7 @@ static void test_GetRawInputBuffer(void)
/* rawinput buffer survives registered device changes */ /* rawinput buffer survives registered device changes */
size = rawinput_size + 1; size = rawinput_size + 1;
todo_wine
ok_ret( 1, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) ); ok_ret( 1, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) );
todo_wine
ok_eq( rawinput_size + 1, size, UINT, "%u" ); ok_eq( rawinput_size + 1, size, UINT, "%u" );
raw_devices[0].usUsagePage = HID_USAGE_PAGE_GENERIC; raw_devices[0].usUsagePage = HID_USAGE_PAGE_GENERIC;
...@@ -2244,9 +2237,7 @@ static void test_GetRawInputBuffer(void) ...@@ -2244,9 +2237,7 @@ static void test_GetRawInputBuffer(void)
ok_ret( 1, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) ); ok_ret( 1, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) );
ok_eq( rawinput_size + 1, size, UINT, "%u" ); ok_eq( rawinput_size + 1, size, UINT, "%u" );
size = sizeof(buffer); size = sizeof(buffer);
todo_wine
ok_ret( 0, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) ); ok_ret( 0, GetRawInputBuffer( rawbuffer, &size, sizeof(RAWINPUTHEADER) ) );
todo_wine
ok_eq( 0, size, UINT, "%u" ); ok_eq( 0, size, UINT, "%u" );
raw_devices[0].dwFlags = RIDEV_REMOVE; raw_devices[0].dwFlags = RIDEV_REMOVE;
......
...@@ -73,125 +73,40 @@ static struct rawinput_thread_data *get_rawinput_thread_data(void) ...@@ -73,125 +73,40 @@ static struct rawinput_thread_data *get_rawinput_thread_data(void)
return data; return data;
} }
static bool rawinput_from_hardware_message( RAWINPUT *rawinput, const struct hardware_msg_data *msg_data ) static BOOL rawinput_from_hardware_message( RAWINPUT *rawinput, const struct hardware_msg_data *msg_data )
{ {
SIZE_T size; SIZE_T size = msg_data->size - sizeof(*msg_data);
if (sizeof(RAWINPUTHEADER) + size > rawinput->header.dwSize) return FALSE;
rawinput->header.dwType = msg_data->rawinput.type; rawinput->header.dwType = msg_data->rawinput.type;
if (msg_data->rawinput.type == RIM_TYPEMOUSE) rawinput->header.dwSize = sizeof(RAWINPUTHEADER) + size;
{ rawinput->header.hDevice = UlongToHandle( msg_data->rawinput.device );
static const unsigned int button_flags[] = rawinput->header.wParam = msg_data->rawinput.wparam;
{
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; if (msg_data->rawinput.type == RIM_TYPEMOUSE)
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) if (size != sizeof(RAWMOUSE)) return FALSE;
rawinput->data.mouse.usButtonFlags |= RI_MOUSE_BUTTON_4_UP; rawinput->data.mouse = *(RAWMOUSE *)(msg_data + 1);
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) else if (msg_data->rawinput.type == RIM_TYPEKEYBOARD)
{ {
rawinput->header.dwSize = FIELD_OFFSET(RAWINPUT, data) + sizeof(RAWKEYBOARD); if (size != sizeof(RAWKEYBOARD)) return FALSE;
rawinput->header.hDevice = WINE_KEYBOARD_HANDLE; rawinput->data.keyboard = *(RAWKEYBOARD *)(msg_data + 1);
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) else if (msg_data->rawinput.type == RIM_TYPEHID)
{ {
size = msg_data->size - sizeof(*msg_data); RAWHID *hid = (RAWHID *)(msg_data + 1);
if (size > rawinput->header.dwSize - sizeof(*rawinput)) return false; if (size < offsetof(RAWHID, bRawData[0])) return FALSE;
if (size != offsetof(RAWHID, bRawData[hid->dwCount * hid->dwSizeHid])) return FALSE;
rawinput->header.dwSize = FIELD_OFFSET( RAWINPUT, data.hid.bRawData ) + size; memcpy( &rawinput->data.hid, msg_data + 1, 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 else
{ {
FIXME( "Unhandled rawinput type %#x.\n", msg_data->rawinput.type ); FIXME( "Unhandled rawinput type %#x.\n", msg_data->rawinput.type );
return false; return FALSE;
} }
return true; return TRUE;
} }
struct device struct device
...@@ -621,10 +536,10 @@ UINT WINAPI NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT heade ...@@ -621,10 +536,10 @@ UINT WINAPI NtUserGetRawInputBuffer( RAWINPUT *data, UINT *data_size, UINT heade
int i; int i;
if (NtCurrentTeb()->WowTebOffset) if (NtCurrentTeb()->WowTebOffset)
rawinput_size = sizeof(RAWINPUT64); rawinput_size = sizeof(RAWINPUTHEADER64);
else else
rawinput_size = sizeof(RAWINPUT); rawinput_size = sizeof(RAWINPUTHEADER);
overhead = rawinput_size - sizeof(RAWINPUT); overhead = rawinput_size - sizeof(RAWINPUTHEADER);
if (header_size != sizeof(RAWINPUTHEADER)) if (header_size != sizeof(RAWINPUTHEADER))
{ {
......
...@@ -263,32 +263,12 @@ struct hw_msg_source ...@@ -263,32 +263,12 @@ struct hw_msg_source
unsigned int origin; unsigned int origin;
}; };
union rawinput struct rawinput
{ {
int type; int type;
struct
{
int type;
unsigned int message;
unsigned short vkey;
unsigned short scan;
} kbd;
struct
{
int type;
int x;
int y;
unsigned int data;
} mouse;
struct
{
int type;
unsigned int device; unsigned int device;
unsigned int wparam; unsigned int wparam;
unsigned int usage; unsigned int usage;
unsigned int count;
unsigned int length;
} hid;
}; };
struct hardware_msg_data struct hardware_msg_data
...@@ -299,7 +279,7 @@ struct hardware_msg_data ...@@ -299,7 +279,7 @@ struct hardware_msg_data
unsigned int hw_id; unsigned int hw_id;
unsigned int flags; unsigned int flags;
struct hw_msg_source source; struct hw_msg_source source;
union rawinput rawinput; struct rawinput rawinput;
}; };
struct callback_msg_data struct callback_msg_data
...@@ -6512,7 +6492,7 @@ union generic_reply ...@@ -6512,7 +6492,7 @@ union generic_reply
/* ### protocol_version begin ### */ /* ### protocol_version begin ### */
#define SERVER_PROTOCOL_VERSION 791 #define SERVER_PROTOCOL_VERSION 792
/* ### protocol_version end ### */ /* ### protocol_version end ### */
......
...@@ -279,32 +279,12 @@ struct hw_msg_source ...@@ -279,32 +279,12 @@ struct hw_msg_source
unsigned int origin; /* source origin (IMO_* values) */ unsigned int origin; /* source origin (IMO_* values) */
}; };
union rawinput struct rawinput
{ {
int type; int type; /* rawinput data type (RIM_* values) */
struct unsigned int device; /* rawinput device pseudo-handle */
{ unsigned int wparam; /* wparam of the WM_INPUT* message */
int type; /* RIM_TYPEKEYBOARD */
unsigned int message; /* message generated by this rawinput event */
unsigned short vkey; /* virtual key code */
unsigned short scan; /* scan code */
} kbd;
struct
{
int type; /* RIM_TYPEMOUSE */
int x; /* x coordinate */
int y; /* y coordinate */
unsigned int data; /* mouse data */
} mouse;
struct
{
int type; /* RIM_TYPEHID */
unsigned int device; /* rawinput device index */
unsigned int wparam; /* rawinput message wparam */
unsigned int usage; /* HID device usage */ unsigned int usage; /* HID device usage */
unsigned int count; /* HID report count */
unsigned int length; /* HID report length */
} hid;
}; };
struct hardware_msg_data struct hardware_msg_data
...@@ -315,7 +295,7 @@ struct hardware_msg_data ...@@ -315,7 +295,7 @@ struct hardware_msg_data
unsigned int hw_id; /* unique id */ unsigned int hw_id; /* unique id */
unsigned int flags; /* hook flags */ unsigned int flags; /* hook flags */
struct hw_msg_source source; /* message source */ struct hw_msg_source source; /* message source */
union rawinput rawinput; /* rawinput message data */ struct rawinput rawinput; /* rawinput message data */
}; };
struct callback_msg_data struct callback_msg_data
......
...@@ -1782,6 +1782,116 @@ static struct thread *get_foreground_thread( struct desktop *desktop, user_handl ...@@ -1782,6 +1782,116 @@ static struct thread *get_foreground_thread( struct desktop *desktop, user_handl
return NULL; return NULL;
} }
/* user32 reserves 1 & 2 for winemouse and winekeyboard,
* keep this in sync with user_private.h */
#define WINE_MOUSE_HANDLE 1
#define WINE_KEYBOARD_HANDLE 2
static void rawmouse_init( struct rawinput *header, RAWMOUSE *rawmouse, int x, int y, unsigned int flags,
unsigned int buttons, lparam_t info )
{
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;
header->type = RIM_TYPEMOUSE;
header->device = WINE_MOUSE_HANDLE;
header->wparam = 0;
header->usage = MAKELONG(HID_USAGE_GENERIC_MOUSE, HID_USAGE_PAGE_GENERIC);
rawmouse->usFlags = MOUSE_MOVE_RELATIVE;
rawmouse->usButtonFlags = 0;
rawmouse->usButtonData = 0;
for (i = 1; i < ARRAY_SIZE(button_flags); ++i)
{
if (flags & (1 << i)) rawmouse->usButtonFlags |= button_flags[i];
}
if (flags & MOUSEEVENTF_WHEEL)
{
rawmouse->usButtonFlags |= RI_MOUSE_WHEEL;
rawmouse->usButtonData = buttons;
}
if (flags & MOUSEEVENTF_HWHEEL)
{
rawmouse->usButtonFlags |= RI_MOUSE_HORIZONTAL_WHEEL;
rawmouse->usButtonData = buttons;
}
if (flags & MOUSEEVENTF_XDOWN)
{
if (buttons == XBUTTON1) rawmouse->usButtonFlags |= RI_MOUSE_BUTTON_4_DOWN;
if (buttons == XBUTTON2) rawmouse->usButtonFlags |= RI_MOUSE_BUTTON_5_DOWN;
}
if (flags & MOUSEEVENTF_XUP)
{
if (buttons == XBUTTON1) rawmouse->usButtonFlags |= RI_MOUSE_BUTTON_4_UP;
if (buttons == XBUTTON2) rawmouse->usButtonFlags |= RI_MOUSE_BUTTON_5_UP;
}
rawmouse->ulRawButtons = 0;
rawmouse->lLastX = x;
rawmouse->lLastY = y;
rawmouse->ulExtraInformation = info;
}
static void rawkeyboard_init( struct rawinput *rawinput, RAWKEYBOARD *keyboard, unsigned short scan, unsigned short vkey,
unsigned int flags, unsigned int message, lparam_t info )
{
rawinput->type = RIM_TYPEKEYBOARD;
rawinput->device = WINE_KEYBOARD_HANDLE;
rawinput->wparam = 0;
rawinput->usage = MAKELONG(HID_USAGE_GENERIC_KEYBOARD, HID_USAGE_PAGE_GENERIC);
keyboard->MakeCode = scan;
keyboard->Flags = (flags & KEYEVENTF_KEYUP) ? RI_KEY_BREAK : RI_KEY_MAKE;
if (flags & KEYEVENTF_EXTENDEDKEY) keyboard->Flags |= RI_KEY_E0;
keyboard->Reserved = 0;
switch (vkey)
{
case VK_LSHIFT:
case VK_RSHIFT:
keyboard->VKey = VK_SHIFT;
keyboard->Flags &= ~RI_KEY_E0;
break;
case VK_LCONTROL:
case VK_RCONTROL:
keyboard->VKey = VK_CONTROL;
break;
case VK_LMENU:
case VK_RMENU:
keyboard->VKey = VK_MENU;
break;
default:
keyboard->VKey = vkey;
break;
}
keyboard->Message = message;
keyboard->ExtraInformation = info;
}
static void rawhid_init( struct rawinput *rawinput, RAWHID *hid, const hw_input_t *input )
{
rawinput->type = RIM_TYPEHID;
rawinput->device = input->hw.hid.device;
rawinput->wparam = input->hw.wparam;
rawinput->usage = input->hw.hid.usage;
hid->dwCount = input->hw.hid.count;
hid->dwSizeHid = input->hw.hid.length;
}
struct rawinput_message struct rawinput_message
{ {
struct thread *foreground; struct thread *foreground;
...@@ -1789,30 +1899,48 @@ struct rawinput_message ...@@ -1789,30 +1899,48 @@ struct rawinput_message
struct hw_msg_source source; struct hw_msg_source source;
unsigned int time; unsigned int time;
unsigned int message; unsigned int message;
lparam_t info;
unsigned int flags; unsigned int flags;
union rawinput rawinput; struct rawinput rawinput;
union
{
RAWKEYBOARD keyboard;
RAWMOUSE mouse;
RAWHID hid;
} data;
const void *hid_report; const void *hid_report;
}; };
/* check if process is supposed to receive a WM_INPUT message and eventually queue it */ /* check if process is supposed to receive a WM_INPUT message and eventually queue it */
static int queue_rawinput_message( struct process* process, void *arg ) static int queue_rawinput_message( struct process* process, void *arg )
{ {
const struct rawinput_message* raw_msg = arg; const struct rawinput_message *raw_msg = arg;
const struct rawinput_device *device = NULL; const struct rawinput_device *device = NULL;
struct desktop *target_desktop = NULL, *desktop = NULL; struct desktop *target_desktop = NULL, *desktop = NULL;
struct thread *target_thread = NULL, *foreground = NULL; struct thread *target_thread = NULL, *foreground = NULL;
struct hardware_msg_data *msg_data; struct hardware_msg_data *msg_data;
struct message *msg; struct message *msg;
data_size_t report_size; data_size_t report_size = 0, data_size = 0;
int wparam = RIM_INPUT; int wparam = RIM_INPUT;
lparam_t info = 0;
if (raw_msg->rawinput.type == RIM_TYPEMOUSE) if (raw_msg->rawinput.type == RIM_TYPEMOUSE)
{
device = process->rawinput_mouse; device = process->rawinput_mouse;
data_size = sizeof(raw_msg->data.mouse);
info = raw_msg->data.mouse.ulExtraInformation;
}
else if (raw_msg->rawinput.type == RIM_TYPEKEYBOARD) else if (raw_msg->rawinput.type == RIM_TYPEKEYBOARD)
{
device = process->rawinput_kbd; device = process->rawinput_kbd;
data_size = sizeof(raw_msg->data.keyboard);
info = raw_msg->data.keyboard.ExtraInformation;
}
else else
device = find_rawinput_device( process, raw_msg->rawinput.hid.usage ); {
device = find_rawinput_device( process, raw_msg->rawinput.usage );
data_size = offsetof(RAWHID, bRawData[0]);
report_size = raw_msg->data.hid.dwCount * raw_msg->data.hid.dwSizeHid;
}
if (!device) return 0; if (!device) return 0;
if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && !(device->flags & RIDEV_DEVNOTIFY)) return 0; if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && !(device->flags & RIDEV_DEVNOTIFY)) return 0;
...@@ -1832,10 +1960,7 @@ static int queue_rawinput_message( struct process* process, void *arg ) ...@@ -1832,10 +1960,7 @@ static int queue_rawinput_message( struct process* process, void *arg )
wparam = RIM_INPUTSINK; wparam = RIM_INPUTSINK;
} }
if (raw_msg->rawinput.type != RIM_TYPEHID || !raw_msg->hid_report) report_size = 0; if (!(msg = alloc_hardware_message( info, raw_msg->source, raw_msg->time, data_size + report_size ))) goto done;
else report_size = raw_msg->rawinput.hid.count * raw_msg->rawinput.hid.length;
if (!(msg = alloc_hardware_message( raw_msg->info, raw_msg->source, raw_msg->time, report_size ))) goto done;
msg->win = device->target; msg->win = device->target;
msg->msg = raw_msg->message; msg->msg = raw_msg->message;
msg->wparam = wparam; msg->wparam = wparam;
...@@ -1844,12 +1969,13 @@ static int queue_rawinput_message( struct process* process, void *arg ) ...@@ -1844,12 +1969,13 @@ static int queue_rawinput_message( struct process* process, void *arg )
msg_data = msg->data; msg_data = msg->data;
msg_data->flags = raw_msg->flags; msg_data->flags = raw_msg->flags;
msg_data->rawinput = raw_msg->rawinput; msg_data->rawinput = raw_msg->rawinput;
if (report_size) memcpy( msg_data + 1, raw_msg->hid_report, report_size ); memcpy( msg_data + 1, &raw_msg->data, data_size );
if (report_size) memcpy( (char *)(msg_data + 1) + data_size, raw_msg->hid_report, report_size );
if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && raw_msg->rawinput.type == RIM_TYPEHID) if (raw_msg->message == WM_INPUT_DEVICE_CHANGE && raw_msg->rawinput.type == RIM_TYPEHID)
{ {
msg->wparam = raw_msg->rawinput.hid.wparam; msg->wparam = raw_msg->rawinput.wparam;
msg->lparam = raw_msg->rawinput.hid.device; msg->lparam = raw_msg->rawinput.device;
} }
queue_hardware_message( desktop, msg, 1 ); queue_hardware_message( desktop, msg, 1 );
...@@ -1927,13 +2053,9 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons ...@@ -1927,13 +2053,9 @@ static int queue_mouse_message( struct desktop *desktop, user_handle_t win, cons
raw_msg.source = source; raw_msg.source = source;
raw_msg.time = time; raw_msg.time = time;
raw_msg.message = WM_INPUT; raw_msg.message = WM_INPUT;
raw_msg.info = input->mouse.info;
raw_msg.flags = flags; raw_msg.flags = flags;
raw_msg.rawinput.type = RIM_TYPEMOUSE; rawmouse_init( &raw_msg.rawinput, &raw_msg.data.mouse, x - desktop->cursor.x, y - desktop->cursor.y,
raw_msg.rawinput.mouse.x = x - desktop->cursor.x; raw_msg.flags, input->mouse.data, input->mouse.info );
raw_msg.rawinput.mouse.y = y - desktop->cursor.y;
raw_msg.rawinput.mouse.data = input->mouse.data;
enum_processes( queue_rawinput_message, &raw_msg ); enum_processes( queue_rawinput_message, &raw_msg );
release_object( foreground ); release_object( foreground );
...@@ -2063,13 +2185,9 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c ...@@ -2063,13 +2185,9 @@ static int queue_keyboard_message( struct desktop *desktop, user_handle_t win, c
raw_msg.source = source; raw_msg.source = source;
raw_msg.time = time; raw_msg.time = time;
raw_msg.message = WM_INPUT; raw_msg.message = WM_INPUT;
raw_msg.info = input->kbd.info;
raw_msg.flags = input->kbd.flags; raw_msg.flags = input->kbd.flags;
raw_msg.rawinput.type = RIM_TYPEKEYBOARD; rawkeyboard_init( &raw_msg.rawinput, &raw_msg.data.keyboard, input->kbd.scan, vkey,
raw_msg.rawinput.kbd.message = message_code; raw_msg.flags, message_code, input->kbd.info );
raw_msg.rawinput.kbd.vkey = vkey;
raw_msg.rawinput.kbd.scan = input->kbd.scan;
enum_processes( queue_rawinput_message, &raw_msg ); enum_processes( queue_rawinput_message, &raw_msg );
release_object( foreground ); release_object( foreground );
...@@ -2134,13 +2252,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_ ...@@ -2134,13 +2252,7 @@ static void queue_custom_hardware_message( struct desktop *desktop, user_handle_
set_error( STATUS_INVALID_PARAMETER ); set_error( STATUS_INVALID_PARAMETER );
return; return;
} }
rawhid_init( &raw_msg.rawinput, &raw_msg.data.hid, input );
raw_msg.rawinput.hid.type = RIM_TYPEHID;
raw_msg.rawinput.hid.device = input->hw.hid.device;
raw_msg.rawinput.hid.wparam = input->hw.wparam;
raw_msg.rawinput.hid.usage = input->hw.hid.usage;
raw_msg.rawinput.hid.count = input->hw.hid.count;
raw_msg.rawinput.hid.length = input->hw.hid.length;
enum_processes( queue_rawinput_message, &raw_msg ); enum_processes( queue_rawinput_message, &raw_msg );
return; return;
......
...@@ -716,7 +716,7 @@ C_ASSERT( sizeof(ioctl_code_t) == 4 ); ...@@ -716,7 +716,7 @@ C_ASSERT( sizeof(ioctl_code_t) == 4 );
C_ASSERT( sizeof(irp_params_t) == 32 ); C_ASSERT( sizeof(irp_params_t) == 32 );
C_ASSERT( sizeof(lparam_t) == 8 ); C_ASSERT( sizeof(lparam_t) == 8 );
C_ASSERT( sizeof(mem_size_t) == 8 ); C_ASSERT( sizeof(mem_size_t) == 8 );
C_ASSERT( sizeof(message_data_t) == 56 ); C_ASSERT( sizeof(message_data_t) == 48 );
C_ASSERT( sizeof(mod_handle_t) == 8 ); C_ASSERT( sizeof(mod_handle_t) == 8 );
C_ASSERT( sizeof(obj_handle_t) == 4 ); C_ASSERT( sizeof(obj_handle_t) == 4 );
C_ASSERT( sizeof(pe_image_info_t) == 88 ); C_ASSERT( sizeof(pe_image_info_t) == 88 );
......
...@@ -57,7 +57,7 @@ my %formats = ...@@ -57,7 +57,7 @@ my %formats =
"context_t" => [ 1720, 8 ], "context_t" => [ 1720, 8 ],
"cursor_pos_t" => [ 24, 8 ], "cursor_pos_t" => [ 24, 8 ],
"debug_event_t" => [ 160, 8 ], "debug_event_t" => [ 160, 8 ],
"message_data_t" => [ 56, 8 ], "message_data_t" => [ 48, 8 ],
"pe_image_info_t" => [ 88, 8 ], "pe_image_info_t" => [ 88, 8 ],
"property_data_t" => [ 16, 8 ], "property_data_t" => [ 16, 8 ],
"select_op_t" => [ 264, 8 ], "select_op_t" => [ 264, 8 ],
......
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