server: add input callbacks.
authorVic Lee <llyzs@163.com>
Tue, 23 Aug 2011 03:50:41 +0000 (11:50 +0800)
committerVic Lee <llyzs@163.com>
Tue, 23 Aug 2011 03:52:35 +0000 (11:52 +0800)
include/freerdp/input.h
include/freerdp/peer.h
libfreerdp-core/freerdp.c
libfreerdp-core/input.c
libfreerdp-core/input.h
libfreerdp-core/peer.c
server/test/freerdp_server.c

index 469cd16..393f381 100644 (file)
@@ -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;
index 9798b96..c0dbb14 100644 (file)
@@ -25,6 +25,8 @@ typedef struct rdp_freerdp_peer freerdp_peer;
 #include <freerdp/api.h>
 #include <freerdp/types.h>
 #include <freerdp/settings.h>
+#include <freerdp/input.h>
+#include <freerdp/update.h>
 
 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;
index 2f9bc7c..90969a7 100644 (file)
@@ -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;
index fca754f..777443a 100644 (file)
@@ -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;
index a61b068..a114350 100644 (file)
@@ -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);
 
index 7593bf5..2cc3c87 100644 (file)
@@ -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);
 
index 899fb89..3546351 100644 (file)
@@ -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)