Merge pull request #403 from pjd/fixes

Modify the UnicodeKeyboardEvent callback to also include flags argument and simplify code by using per_read_length() instead of reimplementing it.
This commit is contained in:
Otavio Salvador 2012-02-07 05:00:49 -08:00
commit 2f5ae364dc
6 changed files with 37 additions and 25 deletions

View File

@ -54,7 +54,7 @@ typedef struct rdp_input rdpInput;
typedef void (*pSynchronizeEvent)(rdpInput* input, uint32 flags);
typedef void (*pKeyboardEvent)(rdpInput* input, uint16 flags, uint16 code);
typedef void (*pUnicodeKeyboardEvent)(rdpInput* input, uint16 code);
typedef void (*pUnicodeKeyboardEvent)(rdpInput* input, uint16 flags, uint16 code);
typedef void (*pMouseEvent)(rdpInput* input, uint16 flags, uint16 x, uint16 y);
typedef void (*pExtendedMouseEvent)(rdpInput* input, uint16 flags, uint16 x, uint16 y);

View File

@ -53,7 +53,6 @@ uint16 fastpath_read_header(rdpFastPath* fastpath, STREAM* s)
{
uint8 header;
uint16 length;
uint8 t;
stream_read_uint8(s, header);
@ -63,15 +62,7 @@ uint16 fastpath_read_header(rdpFastPath* fastpath, STREAM* s)
fastpath->numberEvents = (header & 0x3C) >> 2;
}
stream_read_uint8(s, length); /* length1 */
/* If most significant bit is not set, length2 is not presented. */
if ((length & 0x80))
{
length &= 0x7F;
length <<= 8;
stream_read_uint8(s, t);
length += t;
}
per_read_length(s, &length);
return length;
}
@ -394,13 +385,20 @@ static boolean fastpath_recv_input_event_sync(rdpFastPath* fastpath, STREAM* s,
static boolean fastpath_recv_input_event_unicode(rdpFastPath* fastpath, STREAM* s, uint8 eventFlags)
{
uint16 unicodeCode;
uint16 flags;
if (stream_get_left(s) < 2)
return false;
stream_read_uint16(s, unicodeCode); /* unicodeCode (2 bytes) */
IFCALL(fastpath->rdp->input->UnicodeKeyboardEvent, fastpath->rdp->input, unicodeCode);
flags = 0;
if ((eventFlags & FASTPATH_INPUT_KBDFLAGS_RELEASE))
flags |= KBD_FLAGS_RELEASE;
else
flags |= KBD_FLAGS_DOWN;
IFCALL(fastpath->rdp->input->UnicodeKeyboardEvent, fastpath->rdp->input, flags, unicodeCode);
return true;
}

View File

@ -78,20 +78,32 @@ void input_send_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
rdp_send_client_input_pdu(rdp, s);
}
void input_write_unicode_keyboard_event(STREAM* s, uint16 code)
void input_write_unicode_keyboard_event(STREAM* s, uint16 flags, uint16 code)
{
stream_write_uint16(s, 0); /* pad2OctetsA (2 bytes) */
stream_write_uint16(s, flags); /* keyboardFlags (2 bytes) */
stream_write_uint16(s, code); /* unicodeCode (2 bytes) */
stream_write_uint16(s, 0); /* pad2OctetsB (2 bytes) */
stream_write_uint16(s, 0); /* pad2Octets (2 bytes) */
}
void input_send_unicode_keyboard_event(rdpInput* input, uint16 code)
void input_send_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
{
STREAM* s;
uint16 keyboardFlags = 0;
rdpRdp* rdp = input->context->rdp;
/*
* According to the specification, the slow path Unicode Keyboard Event
* (TS_UNICODE_KEYBOARD_EVENT) contains KBD_FLAGS_RELEASE flag when key
* is released, but contains no flags when it is pressed.
* This is different from the slow path Keyboard Event
* (TS_KEYBOARD_EVENT) which does contain KBD_FLAGS_DOWN flag when the
* key is pressed.
* There is no KBD_FLAGS_EXTENDED flag in TS_UNICODE_KEYBOARD_EVENT.
*/
keyboardFlags |= (flags & KBD_FLAGS_RELEASE) ? KBD_FLAGS_RELEASE : 0;
s = rdp_client_input_pdu_init(rdp, INPUT_EVENT_UNICODE);
input_write_unicode_keyboard_event(s, code);
input_write_unicode_keyboard_event(s, flags, code);
rdp_send_client_input_pdu(rdp, s);
}
@ -152,12 +164,14 @@ void input_send_fastpath_keyboard_event(rdpInput* input, uint16 flags, uint16 co
fastpath_send_input_pdu(rdp->fastpath, s);
}
void input_send_fastpath_unicode_keyboard_event(rdpInput* input, uint16 code)
void input_send_fastpath_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
{
STREAM* s;
uint8 eventFlags = 0;
rdpRdp* rdp = input->context->rdp;
s = fastpath_input_pdu_init(rdp->fastpath, 0, FASTPATH_INPUT_EVENT_UNICODE);
eventFlags |= (flags & KBD_FLAGS_RELEASE) ? FASTPATH_INPUT_KBDFLAGS_RELEASE : 0;
s = fastpath_input_pdu_init(rdp->fastpath, eventFlags, FASTPATH_INPUT_EVENT_UNICODE);
stream_write_uint16(s, code); /* unicodeCode (2 bytes) */
fastpath_send_input_pdu(rdp->fastpath, s);
}

View File

@ -39,13 +39,13 @@
void input_send_synchronize_event(rdpInput* input, uint32 flags);
void input_send_keyboard_event(rdpInput* input, uint16 flags, uint16 code);
void input_send_unicode_keyboard_event(rdpInput* input, uint16 code);
void input_send_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code);
void input_send_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y);
void input_send_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y);
void input_send_fastpath_synchronize_event(rdpInput* input, uint32 flags);
void input_send_fastpath_keyboard_event(rdpInput* input, uint16 flags, uint16 code);
void input_send_fastpath_unicode_keyboard_event(rdpInput* input, uint16 code);
void input_send_fastpath_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code);
void input_send_fastpath_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y);
void input_send_fastpath_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y);

View File

@ -54,9 +54,9 @@ void xf_input_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
}
}
void xf_input_unicode_keyboard_event(rdpInput* input, uint16 code)
void xf_input_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
{
printf("Client sent a unicode keyboard event (code:0x%X)\n", code);
printf("Client sent a unicode keyboard event (flags:0x%X code:0x%X)\n", flags, code);
}
void xf_input_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)

View File

@ -493,9 +493,9 @@ void tf_peer_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
}
}
void tf_peer_unicode_keyboard_event(rdpInput* input, uint16 code)
void tf_peer_unicode_keyboard_event(rdpInput* input, uint16 flags, uint16 code)
{
printf("Client sent a unicode keyboard event (code:0x%X)\n", code);
printf("Client sent a unicode keyboard event (flags:0x%X code:0x%X)\n", flags, code);
}
void tf_peer_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y)