1 /**
2  * FreeRDP: A Remote Desktop Protocol Implementation
3  * Input Interface API
4  *
5  * Copyright 2011 Marc-Andre Moreau <marcandre.moreau@gmail.com>
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *     http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 
20 #ifndef FREERDP_INPUT_H
21 #define FREERDP_INPUT_H
22 
23 typedef struct rdp_input rdpInput;
24 
25 #include <freerdp/api.h>
26 #include <freerdp/freerdp.h>
27 #include <freerdp/scancode.h>
28 
29 #include <winpr/crt.h>
30 #include <winpr/collections.h>
31 
32 /* keyboard Flags */
33 #define KBD_FLAGS_EXTENDED 0x0100
34 #define KBD_FLAGS_EXTENDED1 0x0200
35 #define KBD_FLAGS_DOWN 0x4000
36 #define KBD_FLAGS_RELEASE 0x8000
37 
38 /* Pointer Flags */
39 #define PTR_FLAGS_HWHEEL 0x0400
40 #define PTR_FLAGS_WHEEL 0x0200
41 #define PTR_FLAGS_WHEEL_NEGATIVE 0x0100
42 #define PTR_FLAGS_MOVE 0x0800
43 #define PTR_FLAGS_DOWN 0x8000
44 #define PTR_FLAGS_BUTTON1 0x1000 /* left */
45 #define PTR_FLAGS_BUTTON2 0x2000 /* right */
46 #define PTR_FLAGS_BUTTON3 0x4000 /* middle */
47 #define WheelRotationMask 0x01FF
48 
49 /* Extended Pointer Flags */
50 #define PTR_XFLAGS_DOWN 0x8000
51 #define PTR_XFLAGS_BUTTON1 0x0001
52 #define PTR_XFLAGS_BUTTON2 0x0002
53 
54 /* Keyboard Toggle Flags */
55 #define KBD_SYNC_SCROLL_LOCK 0x00000001
56 #define KBD_SYNC_NUM_LOCK 0x00000002
57 #define KBD_SYNC_CAPS_LOCK 0x00000004
58 #define KBD_SYNC_KANA_LOCK 0x00000008
59 
60 #define RDP_CLIENT_INPUT_PDU_HEADER_LENGTH 4
61 
62 /* defined inside libfreerdp-core */
63 typedef struct rdp_input_proxy rdpInputProxy;
64 
65 /* Input Interface */
66 
67 typedef BOOL (*pSynchronizeEvent)(rdpInput* input, UINT32 flags);
68 typedef BOOL (*pKeyboardEvent)(rdpInput* input, UINT16 flags, UINT16 code);
69 typedef BOOL (*pUnicodeKeyboardEvent)(rdpInput* input, UINT16 flags, UINT16 code);
70 typedef BOOL (*pMouseEvent)(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
71 typedef BOOL (*pExtendedMouseEvent)(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y);
72 typedef BOOL (*pFocusInEvent)(rdpInput* input, UINT16 toggleStates);
73 typedef BOOL (*pKeyboardPauseEvent)(rdpInput* input);
74 
75 struct rdp_input
76 {
77 	rdpContext* context;     /* 0 */
78 	void* param1;            /* 1 */
79 	UINT32 paddingA[16 - 2]; /* 2 */
80 
81 	pSynchronizeEvent SynchronizeEvent;         /* 16 */
82 	pKeyboardEvent KeyboardEvent;               /* 17 */
83 	pUnicodeKeyboardEvent UnicodeKeyboardEvent; /* 18 */
84 	pMouseEvent MouseEvent;                     /* 19 */
85 	pExtendedMouseEvent ExtendedMouseEvent;     /* 20 */
86 	pFocusInEvent FocusInEvent;                 /*21 */
87 	pKeyboardPauseEvent KeyboardPauseEvent;     /* 22 */
88 
89 	UINT32 paddingB[32 - 23]; /* 23 */
90 
91 	/* Internal */
92 
93 	BOOL asynchronous;
94 	rdpInputProxy* proxy;
95 	wMessageQueue* queue;
96 };
97 
98 #ifdef __cplusplus
99 extern "C"
100 {
101 #endif
102 
103 	FREERDP_API BOOL freerdp_input_send_synchronize_event(rdpInput* input, UINT32 flags);
104 	FREERDP_API BOOL freerdp_input_send_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code);
105 	FREERDP_API BOOL freerdp_input_send_keyboard_event_ex(rdpInput* input, BOOL down,
106 	                                                      UINT32 rdp_scancode);
107 	FREERDP_API BOOL freerdp_input_send_keyboard_pause_event(rdpInput* input);
108 	FREERDP_API BOOL freerdp_input_send_unicode_keyboard_event(rdpInput* input, UINT16 flags,
109 	                                                           UINT16 code);
110 	FREERDP_API BOOL freerdp_input_send_mouse_event(rdpInput* input, UINT16 flags, UINT16 x,
111 	                                                UINT16 y);
112 	FREERDP_API BOOL freerdp_input_send_extended_mouse_event(rdpInput* input, UINT16 flags,
113 	                                                         UINT16 x, UINT16 y);
114 	FREERDP_API BOOL freerdp_input_send_focus_in_event(rdpInput* input, UINT16 toggleStates);
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* FREERDP_INPUT_H */
121