Merge pull request #4066 from akallabeth/input_event_fixes

Fixed capability checks for mouse and unicode input.
This commit is contained in:
David Fort 2017-08-02 11:25:08 +02:00 committed by GitHub
commit b29658a859
6 changed files with 69 additions and 59 deletions

View File

@ -1238,7 +1238,8 @@ struct rdp_settings
ALIGN64 BOOL MultiTouchGestures; /* 2632 */
ALIGN64 UINT32 KeyboardHook; /* 2633 */
ALIGN64 BOOL HasHorizontalWheel; /* 2634 */
UINT64 padding2688[2688 - 2635]; /* 2635 */
ALIGN64 BOOL HasExtendedMouseEvent; /* 2635 */
UINT64 padding2688[2688 - 2636]; /* 2636 */
/* Brush Capabilities */
ALIGN64 UINT32 BrushSupportLevel; /* 2688 */

View File

@ -1280,9 +1280,13 @@ static BOOL rdp_read_input_capability_set(wStream* s, UINT16 length,
}
if (inputFlags & TS_INPUT_FLAG_MOUSE_HWHEEL)
{
settings->HasHorizontalWheel = TRUE;
}
if (inputFlags & INPUT_FLAG_UNICODE)
settings->UnicodeInput = TRUE;
if (inputFlags & INPUT_FLAG_MOUSEX)
settings->HasExtendedMouseEvent = TRUE;
}
return TRUE;

View File

@ -32,6 +32,15 @@
#define TAG FREERDP_TAG("core")
/* Input Events */
#define INPUT_EVENT_SYNC 0x0000
#define INPUT_EVENT_SCANCODE 0x0004
#define INPUT_EVENT_UNICODE 0x0005
#define INPUT_EVENT_MOUSE 0x8001
#define INPUT_EVENT_MOUSEX 0x8002
#define RDP_CLIENT_INPUT_PDU_HEADER_LENGTH 4
static void rdp_write_client_input_pdu_header(wStream* s, UINT16 number)
{
Stream_Write_UINT16(s, 1); /* numberEvents (2 bytes) */
@ -44,7 +53,7 @@ static void rdp_write_input_event_header(wStream* s, UINT32 time, UINT16 type)
Stream_Write_UINT16(s, type); /* messageType (2 bytes) */
}
wStream* rdp_client_input_pdu_init(rdpRdp* rdp, UINT16 type)
static wStream* rdp_client_input_pdu_init(rdpRdp* rdp, UINT16 type)
{
wStream* s;
s = rdp_data_pdu_init(rdp);
@ -57,7 +66,7 @@ wStream* rdp_client_input_pdu_init(rdpRdp* rdp, UINT16 type)
return s;
}
BOOL rdp_send_client_input_pdu(rdpRdp* rdp, wStream* s)
static BOOL rdp_send_client_input_pdu(rdpRdp* rdp, wStream* s)
{
return rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_INPUT, rdp->mcs->userId);
}
@ -68,7 +77,7 @@ static void input_write_synchronize_event(wStream* s, UINT32 flags)
Stream_Write_UINT32(s, flags); /* toggleFlags (4 bytes) */
}
BOOL input_send_synchronize_event(rdpInput* input, UINT32 flags)
static BOOL input_send_synchronize_event(rdpInput* input, UINT32 flags)
{
wStream* s;
rdpRdp* rdp;
@ -93,7 +102,7 @@ static void input_write_keyboard_event(wStream* s, UINT16 flags, UINT16 code)
Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */
}
BOOL input_send_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
static BOOL input_send_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
wStream* s;
rdpRdp* rdp;
@ -118,7 +127,7 @@ static void input_write_unicode_keyboard_event(wStream* s, UINT16 flags, UINT16
Stream_Write_UINT16(s, 0); /* pad2Octets (2 bytes) */
}
BOOL input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
static BOOL input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
wStream* s;
UINT16 keyboardFlags = 0;
@ -127,6 +136,12 @@ BOOL input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 cod
if (!input || !input->context)
return FALSE;
if (!input->context->settings->UnicodeInput)
{
WLog_WARN(TAG, "Unicode input not supported by server.");
return FALSE;
}
rdp = input->context->rdp;
/*
* According to the specification, the slow path Unicode Keyboard Event
@ -147,14 +162,14 @@ BOOL input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 cod
return rdp_send_client_input_pdu(rdp, s);
}
void input_write_mouse_event(wStream* s, UINT16 flags, UINT16 x, UINT16 y)
static void input_write_mouse_event(wStream* s, UINT16 flags, UINT16 x, UINT16 y)
{
Stream_Write_UINT16(s, flags); /* pointerFlags (2 bytes) */
Stream_Write_UINT16(s, x); /* xPos (2 bytes) */
Stream_Write_UINT16(s, y); /* yPos (2 bytes) */
}
BOOL input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
static BOOL input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
{
wStream* s;
rdpRdp* rdp;
@ -190,7 +205,8 @@ static void input_write_extended_mouse_event(wStream* s, UINT16 flags, UINT16 x,
Stream_Write_UINT16(s, y); /* yPos (2 bytes) */
}
BOOL input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
static BOOL input_send_extended_mouse_event(rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y)
{
wStream* s;
rdpRdp* rdp;
@ -198,6 +214,13 @@ BOOL input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UI
if (!input || !input->context)
return FALSE;
if (!input->context->settings->HasExtendedMouseEvent)
{
WLog_WARN(TAG, "skip extended mouse event %"PRIu16"x%"PRIu16" flags=0x%04"PRIX16", no extended mouse events supported",
x, y, flags);
return TRUE;
}
rdp = input->context->rdp;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_MOUSEX);
@ -208,7 +231,7 @@ BOOL input_send_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UI
return rdp_send_client_input_pdu(rdp, s);
}
BOOL input_send_focus_in_event(rdpInput* input, UINT16 toggleStates)
static BOOL input_send_focus_in_event(rdpInput* input, UINT16 toggleStates)
{
/* send a tab up like mstsc.exe */
if (!input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f))
@ -222,7 +245,7 @@ BOOL input_send_focus_in_event(rdpInput* input, UINT16 toggleStates)
return input_send_keyboard_event(input, KBD_FLAGS_RELEASE, 0x0f);
}
BOOL input_send_keyboard_pause_event(rdpInput* input)
static BOOL input_send_keyboard_pause_event(rdpInput* input)
{
/* In ancient days, pause-down without control sent E1 1D 45 E1 9D C5,
* and pause-up sent nothing. However, reverse engineering mstsc shows
@ -249,7 +272,7 @@ BOOL input_send_keyboard_pause_event(rdpInput* input)
RDP_SCANCODE_CODE(RDP_SCANCODE_NUMLOCK));
}
BOOL input_send_fastpath_synchronize_event(rdpInput* input, UINT32 flags)
static BOOL input_send_fastpath_synchronize_event(rdpInput* input, UINT32 flags)
{
wStream* s;
rdpRdp* rdp;
@ -267,7 +290,7 @@ BOOL input_send_fastpath_synchronize_event(rdpInput* input, UINT32 flags)
return fastpath_send_input_pdu(rdp->fastpath, s);
}
BOOL input_send_fastpath_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
static BOOL input_send_fastpath_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
wStream* s;
BYTE eventFlags = 0;
@ -288,7 +311,7 @@ BOOL input_send_fastpath_keyboard_event(rdpInput* input, UINT16 flags, UINT16 co
return fastpath_send_input_pdu(rdp->fastpath, s);
}
BOOL input_send_fastpath_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
static BOOL input_send_fastpath_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
{
wStream* s;
BYTE eventFlags = 0;
@ -297,6 +320,12 @@ BOOL input_send_fastpath_unicode_keyboard_event(rdpInput* input, UINT16 flags, U
if (!input || !input->context)
return FALSE;
if (!input->context->settings->UnicodeInput)
{
WLog_WARN(TAG, "Unicode input not supported by server.");
return FALSE;
}
rdp = input->context->rdp;
eventFlags |= (flags & KBD_FLAGS_RELEASE) ? FASTPATH_INPUT_KBDFLAGS_RELEASE : 0;
s = fastpath_input_pdu_init(rdp->fastpath, eventFlags, FASTPATH_INPUT_EVENT_UNICODE);
@ -308,7 +337,8 @@ BOOL input_send_fastpath_unicode_keyboard_event(rdpInput* input, UINT16 flags, U
return fastpath_send_input_pdu(rdp->fastpath, s);
}
BOOL input_send_fastpath_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
static BOOL input_send_fastpath_mouse_event(rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y)
{
wStream* s;
rdpRdp* rdp;
@ -337,7 +367,8 @@ BOOL input_send_fastpath_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UI
return fastpath_send_input_pdu(rdp->fastpath, s);
}
BOOL input_send_fastpath_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
static BOOL input_send_fastpath_extended_mouse_event(rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y)
{
wStream* s;
rdpRdp* rdp;
@ -345,6 +376,13 @@ BOOL input_send_fastpath_extended_mouse_event(rdpInput* input, UINT16 flags, UIN
if (!input || !input->context)
return FALSE;
if (!input->context->settings->HasExtendedMouseEvent)
{
WLog_WARN(TAG, "skip extended mouse event %"PRIu16"x%"PRIu16" flags=0x%04"PRIX16", no extended mouse events supported",
x, y, flags);
return TRUE;
}
rdp = input->context->rdp;
s = fastpath_input_pdu_init(rdp->fastpath, 0, FASTPATH_INPUT_EVENT_MOUSEX);
@ -355,7 +393,7 @@ BOOL input_send_fastpath_extended_mouse_event(rdpInput* input, UINT16 flags, UIN
return fastpath_send_input_pdu(rdp->fastpath, s);
}
BOOL input_send_fastpath_focus_in_event(rdpInput* input, UINT16 toggleStates)
static BOOL input_send_fastpath_focus_in_event(rdpInput* input, UINT16 toggleStates)
{
wStream* s;
BYTE eventFlags = 0;
@ -384,7 +422,7 @@ BOOL input_send_fastpath_focus_in_event(rdpInput* input, UINT16 toggleStates)
return fastpath_send_multiple_input_pdu(rdp->fastpath, s, 3);
}
BOOL input_send_fastpath_keyboard_pause_event(rdpInput* input)
static BOOL input_send_fastpath_keyboard_pause_event(rdpInput* input)
{
/* In ancient days, pause-down without control sent E1 1D 45 E1 9D C5,
* and pause-up sent nothing. However, reverse engineering mstsc shows

View File

@ -30,36 +30,6 @@
#include <winpr/stream.h>
/* Input Events */
#define INPUT_EVENT_SYNC 0x0000
#define INPUT_EVENT_SCANCODE 0x0004
#define INPUT_EVENT_UNICODE 0x0005
#define INPUT_EVENT_MOUSE 0x8001
#define INPUT_EVENT_MOUSEX 0x8002
#define RDP_CLIENT_INPUT_PDU_HEADER_LENGTH 4
FREERDP_LOCAL BOOL input_send_synchronize_event(rdpInput* input, UINT32 flags);
FREERDP_LOCAL BOOL input_send_keyboard_event(rdpInput* input, UINT16 flags,
UINT16 code);
FREERDP_LOCAL BOOL input_send_unicode_keyboard_event(rdpInput* input,
UINT16 flags, UINT16 code);
FREERDP_LOCAL BOOL input_send_mouse_event(rdpInput* input, UINT16 flags,
UINT16 x, UINT16 y);
FREERDP_LOCAL BOOL input_send_extended_mouse_event(rdpInput* input,
UINT16 flags, UINT16 x, UINT16 y);
FREERDP_LOCAL BOOL input_send_fastpath_synchronize_event(rdpInput* input,
UINT32 flags);
FREERDP_LOCAL BOOL input_send_fastpath_keyboard_event(rdpInput* input,
UINT16 flags, UINT16 code);
FREERDP_LOCAL BOOL input_send_fastpath_unicode_keyboard_event(rdpInput* input,
UINT16 flags, UINT16 code);
FREERDP_LOCAL BOOL input_send_fastpath_mouse_event(rdpInput* input,
UINT16 flags, UINT16 x, UINT16 y);
FREERDP_LOCAL BOOL input_send_fastpath_extended_mouse_event(rdpInput* input,
UINT16 flags, UINT16 x, UINT16 y);
FREERDP_LOCAL BOOL input_recv(rdpInput* input, wStream* s);
FREERDP_LOCAL int input_process_events(rdpInput* input);

View File

@ -42,7 +42,7 @@
#define TAG FREERDP_TAG("core.update")
const char* const UPDATE_TYPE_STRINGS[] =
static const char* const UPDATE_TYPE_STRINGS[] =
{
"Orders",
"Bitmap",
@ -50,7 +50,7 @@ const char* const UPDATE_TYPE_STRINGS[] =
"Synchronize"
};
BOOL update_recv_orders(rdpUpdate* update, wStream* s)
static BOOL update_recv_orders(rdpUpdate* update, wStream* s)
{
UINT16 numberOrders;
@ -121,7 +121,7 @@ static BOOL update_read_bitmap_data(rdpUpdate* update, wStream* s,
return TRUE;
}
BOOL update_write_bitmap_data(rdpUpdate* update, wStream* s,
static BOOL update_write_bitmap_data(rdpUpdate* update, wStream* s,
BITMAP_DATA* bitmapData)
{
if (!Stream_EnsureRemainingCapacity(s, 64 + bitmapData->bitmapLength))
@ -262,7 +262,7 @@ BOOL update_read_palette(rdpUpdate* update, wStream* s,
return TRUE;
}
void update_read_synchronize(rdpUpdate* update, wStream* s)
static void update_read_synchronize(rdpUpdate* update, wStream* s)
{
Stream_Seek_UINT16(s); /* pad2Octets (2 bytes) */
/**
@ -271,7 +271,7 @@ void update_read_synchronize(rdpUpdate* update, wStream* s)
*/
}
BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound)
static BOOL update_read_play_sound(wStream* s, PLAY_SOUND_UPDATE* play_sound)
{
if (Stream_GetRemainingLength(s) < 8)
return FALSE;
@ -301,7 +301,7 @@ BOOL update_read_pointer_position(wStream* s,
return TRUE;
}
BOOL update_read_pointer_system(wStream* s,
static BOOL update_read_pointer_system(wStream* s,
POINTER_SYSTEM_UPDATE* pointer_system)
{
if (Stream_GetRemainingLength(s) < 4)

View File

@ -40,7 +40,6 @@
FREERDP_LOCAL rdpUpdate* update_new(rdpRdp* rdp);
FREERDP_LOCAL void update_free(rdpUpdate* update);
FREERDP_LOCAL void update_free_bitmap(BITMAP_UPDATE* bitmap_update);
FREERDP_LOCAL void update_reset_state(rdpUpdate* update);
FREERDP_LOCAL BOOL update_post_connect(rdpUpdate* update);
FREERDP_LOCAL void update_post_disconnect(rdpUpdate* update);
@ -53,8 +52,6 @@ FREERDP_LOCAL BOOL update_recv_pointer(rdpUpdate* update, wStream* s);
FREERDP_LOCAL BOOL update_recv(rdpUpdate* update, wStream* s);
FREERDP_LOCAL BOOL update_read_pointer_position(wStream* s,
POINTER_POSITION_UPDATE* pointer_position);
FREERDP_LOCAL BOOL update_read_pointer_system(wStream* s,
POINTER_SYSTEM_UPDATE* pointer_system);
FREERDP_LOCAL BOOL update_read_pointer_color(wStream* s,
POINTER_COLOR_UPDATE* pointer_color, int xorBpp);
FREERDP_LOCAL BOOL update_read_pointer_new(wStream* s,