From 57ac9a59ebef757e43d5bc51be52ec27abc766d4 Mon Sep 17 00:00:00 2001 From: Vic Lee Date: Tue, 23 Aug 2011 11:50:41 +0800 Subject: [PATCH] server: add input callbacks. --- include/freerdp/input.h | 3 +++ include/freerdp/peer.h | 4 ++++ libfreerdp-core/freerdp.c | 2 ++ libfreerdp-core/input.c | 38 +++++++++++++++++++++--------------- libfreerdp-core/input.h | 2 ++ libfreerdp-core/peer.c | 2 ++ server/test/freerdp_server.c | 34 ++++++++++++++++++++++++++++++++ 7 files changed, 69 insertions(+), 16 deletions(-) diff --git a/include/freerdp/input.h b/include/freerdp/input.h index 469cd1673..393f381b4 100644 --- a/include/freerdp/input.h +++ b/include/freerdp/input.h @@ -59,6 +59,9 @@ typedef void (*pcExtendedMouseEvent)(rdpInput* input, uint16 flags, uint16 x, ui struct rdp_input { void* rdp; + void* param1; + void* param2; + pcSynchronizeEvent SynchronizeEvent; pcKeyboardEvent KeyboardEvent; pcUnicodeKeyboardEvent UnicodeKeyboardEvent; diff --git a/include/freerdp/peer.h b/include/freerdp/peer.h index 9798b966b..c0dbb1481 100644 --- a/include/freerdp/peer.h +++ b/include/freerdp/peer.h @@ -25,6 +25,8 @@ typedef struct rdp_freerdp_peer freerdp_peer; #include #include #include +#include +#include typedef boolean (*psPeerInitialize)(freerdp_peer* client); typedef boolean (*psPeerGetFileDescriptor)(freerdp_peer* client, void** rfds, int* rcount); @@ -40,6 +42,8 @@ struct rdp_freerdp_peer void* param3; void* param4; + rdpInput* input; + rdpUpdate* update; rdpSettings* settings; psPeerInitialize Initialize; diff --git a/libfreerdp-core/freerdp.c b/libfreerdp-core/freerdp.c index 2f9bc7cb6..90969a78a 100644 --- a/libfreerdp-core/freerdp.c +++ b/libfreerdp-core/freerdp.c @@ -88,6 +88,8 @@ freerdp* freerdp_new() instance->GetFileDescriptor = freerdp_get_fds; instance->CheckFileDescriptor = freerdp_check_fds; instance->SendChannelData = freerdp_send_channel_data; + + input_register_client_callbacks(rdp->input); } return instance; diff --git a/libfreerdp-core/input.c b/libfreerdp-core/input.c index fca754f96..777443a83 100644 --- a/libfreerdp-core/input.c +++ b/libfreerdp-core/input.c @@ -175,6 +175,28 @@ void input_send_fastpath_extended_mouse_event(rdpInput* input, uint16 flags, uin rdp_send_client_fastpath_input_pdu(input->rdp, s); } +void input_register_client_callbacks(rdpInput* input) +{ + rdpRdp* rdp = (rdpRdp*)input->rdp; + + if (rdp->settings->fastpath_input) + { + input->SynchronizeEvent = input_send_fastpath_synchronize_event; + input->KeyboardEvent = input_send_fastpath_keyboard_event; + input->UnicodeKeyboardEvent = input_send_fastpath_unicode_keyboard_event; + input->MouseEvent = input_send_fastpath_mouse_event; + input->ExtendedMouseEvent = input_send_fastpath_extended_mouse_event; + } + else + { + input->SynchronizeEvent = input_send_synchronize_event; + input->KeyboardEvent = input_send_keyboard_event; + input->UnicodeKeyboardEvent = input_send_unicode_keyboard_event; + input->MouseEvent = input_send_mouse_event; + input->ExtendedMouseEvent = input_send_extended_mouse_event; + } +} + rdpInput* input_new(rdpRdp* rdp) { rdpInput* input; @@ -184,22 +206,6 @@ rdpInput* input_new(rdpRdp* rdp) if (input != NULL) { input->rdp = rdp; - if (rdp->settings->fastpath_input) - { - input->SynchronizeEvent = input_send_fastpath_synchronize_event; - input->KeyboardEvent = input_send_fastpath_keyboard_event; - input->UnicodeKeyboardEvent = input_send_fastpath_unicode_keyboard_event; - input->MouseEvent = input_send_fastpath_mouse_event; - input->ExtendedMouseEvent = input_send_fastpath_extended_mouse_event; - } - else - { - input->SynchronizeEvent = input_send_synchronize_event; - input->KeyboardEvent = input_send_keyboard_event; - input->UnicodeKeyboardEvent = input_send_unicode_keyboard_event; - input->MouseEvent = input_send_mouse_event; - input->ExtendedMouseEvent = input_send_extended_mouse_event; - } } return input; diff --git a/libfreerdp-core/input.h b/libfreerdp-core/input.h index a61b0683c..a114350bb 100644 --- a/libfreerdp-core/input.h +++ b/libfreerdp-core/input.h @@ -60,6 +60,8 @@ void input_send_fastpath_unicode_keyboard_event(rdpInput* input, 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); +void input_register_client_callbacks(rdpInput* input); + rdpInput* input_new(rdpRdp* rdp); void input_free(rdpInput* input); diff --git a/libfreerdp-core/peer.c b/libfreerdp-core/peer.c index 7593bf581..2cc3c872d 100644 --- a/libfreerdp-core/peer.c +++ b/libfreerdp-core/peer.c @@ -225,6 +225,8 @@ freerdp_peer* freerdp_peer_new(int sockfd) client->peer = (void*)peer; client->settings = peer->rdp->settings; + client->input = peer->rdp->input; + client->update = peer->rdp->update; transport_attach(peer->rdp->transport, sockfd); diff --git a/server/test/freerdp_server.c b/server/test/freerdp_server.c index 899fb894f..3546351b6 100644 --- a/server/test/freerdp_server.c +++ b/server/test/freerdp_server.c @@ -49,6 +49,31 @@ boolean test_peer_post_connect(freerdp_peer* client) return True; } +void test_peer_synchronize_event(rdpInput* input, uint32 flags) +{ + printf("Client sent a synchronize event\n"); +} + +void test_peer_keyboard_event(rdpInput* input, uint16 flags, uint16 code) +{ + printf("Client sent a keyboard event (flags:0x%X code:0x%X)\n", flags, code); +} + +void test_peer_unicode_keyboard_event(rdpInput* input, uint16 code) +{ + printf("Client sent a unicode keyboard event (code:0x%X)\n", code); +} + +void test_peer_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y) +{ + printf("Client sent a mouse event (flags:0x%X pos:%d,%d)\n", flags, x, y); +} + +void test_peer_extended_mouse_event(rdpInput* input, uint16 flags, uint16 x, uint16 y) +{ + printf("Client sent an extended mouse event (flags:0x%X pos:%d,%d)\n", flags, x, y); +} + static void* test_peer_mainloop(void* arg) { freerdp_peer* client = (freerdp_peer*)arg; @@ -63,11 +88,20 @@ static void* test_peer_mainloop(void* arg) printf("We've got a client %s\n", client->settings->hostname); + /* Initialize the real server settings here */ client->settings->cert_file = xstrdup("server.crt"); client->settings->privatekey_file = xstrdup("server.key"); client->settings->nla_security = False; client->PostConnect = test_peer_post_connect; + + client->input->param1 = client; + client->input->SynchronizeEvent = test_peer_synchronize_event; + client->input->KeyboardEvent = test_peer_keyboard_event; + client->input->UnicodeKeyboardEvent = test_peer_unicode_keyboard_event; + client->input->MouseEvent = test_peer_mouse_event; + client->input->ExtendedMouseEvent = test_peer_extended_mouse_event; + client->Initialize(client); while (1)