#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) */
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);
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);
}
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;
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;
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;
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
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;
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;
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);
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))
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
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;
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;
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;
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);
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;
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;
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);
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;
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
#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);