20 #include <freerdp/config.h>
22 #include <winpr/windows.h>
27 BOOL wf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
31 keyboard_event.type = INPUT_KEYBOARD;
32 keyboard_event.ki.wVk = 0;
33 keyboard_event.ki.wScan = code;
34 keyboard_event.ki.dwFlags = KEYEVENTF_SCANCODE;
35 keyboard_event.ki.dwExtraInfo = 0;
36 keyboard_event.ki.time = 0;
38 if (flags & KBD_FLAGS_RELEASE)
39 keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
41 if (flags & KBD_FLAGS_EXTENDED)
42 keyboard_event.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
44 SendInput(1, &keyboard_event,
sizeof(INPUT));
48 BOOL wf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
52 keyboard_event.type = INPUT_KEYBOARD;
53 keyboard_event.ki.wVk = 0;
54 keyboard_event.ki.wScan = code;
55 keyboard_event.ki.dwFlags = KEYEVENTF_UNICODE;
56 keyboard_event.ki.dwExtraInfo = 0;
57 keyboard_event.ki.time = 0;
59 if (flags & KBD_FLAGS_RELEASE)
60 keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
62 SendInput(1, &keyboard_event,
sizeof(INPUT));
66 BOOL wf_peer_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
68 INPUT mouse_event = { 0 };
73 mouse_event.type = INPUT_MOUSE;
75 if (flags & PTR_FLAGS_WHEEL)
77 mouse_event.mi.dwFlags = MOUSEEVENTF_WHEEL;
78 mouse_event.mi.mouseData = flags & WheelRotationMask;
80 if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
81 mouse_event.mi.mouseData *= -1;
83 SendInput(1, &mouse_event,
sizeof(INPUT));
88 wfi = wf_info_get_instance();
94 width = (float)GetSystemMetrics(SM_CXSCREEN);
95 height = (float)GetSystemMetrics(SM_CYSCREEN);
96 x += wfi->servscreen_xoffset;
97 y += wfi->servscreen_yoffset;
98 mouse_event.mi.dx = (LONG)((
float)x * (65535.0f / width));
99 mouse_event.mi.dy = (LONG)((
float)y * (65535.0f / height));
100 mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
102 if (flags & PTR_FLAGS_MOVE)
104 mouse_event.mi.dwFlags |= MOUSEEVENTF_MOVE;
105 SendInput(1, &mouse_event,
sizeof(INPUT));
108 mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
110 if (flags & PTR_FLAGS_BUTTON1)
112 if (flags & PTR_FLAGS_DOWN)
113 mouse_event.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
115 mouse_event.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
117 SendInput(1, &mouse_event,
sizeof(INPUT));
119 else if (flags & PTR_FLAGS_BUTTON2)
121 if (flags & PTR_FLAGS_DOWN)
122 mouse_event.mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
124 mouse_event.mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
126 SendInput(1, &mouse_event,
sizeof(INPUT));
128 else if (flags & PTR_FLAGS_BUTTON3)
130 if (flags & PTR_FLAGS_DOWN)
131 mouse_event.mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
133 mouse_event.mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
135 SendInput(1, &mouse_event,
sizeof(INPUT));
142 BOOL wf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
144 if ((flags & PTR_XFLAGS_BUTTON1) || (flags & PTR_XFLAGS_BUTTON2))
146 INPUT mouse_event = { 0 };
147 mouse_event.type = INPUT_MOUSE;
149 if (flags & PTR_FLAGS_MOVE)
153 wfi = wf_info_get_instance();
159 width = (float)GetSystemMetrics(SM_CXSCREEN);
160 height = (float)GetSystemMetrics(SM_CYSCREEN);
161 x += wfi->servscreen_xoffset;
162 y += wfi->servscreen_yoffset;
163 mouse_event.mi.dx = (LONG)((
float)x * (65535.0f / width));
164 mouse_event.mi.dy = (LONG)((
float)y * (65535.0f / height));
165 mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
166 SendInput(1, &mouse_event,
sizeof(INPUT));
169 mouse_event.mi.dx = mouse_event.mi.dy = mouse_event.mi.dwFlags = 0;
171 if (flags & PTR_XFLAGS_DOWN)
172 mouse_event.mi.dwFlags |= MOUSEEVENTF_XDOWN;
174 mouse_event.mi.dwFlags |= MOUSEEVENTF_XUP;
176 if (flags & PTR_XFLAGS_BUTTON1)
177 mouse_event.mi.mouseData = XBUTTON1;
178 else if (flags & PTR_XFLAGS_BUTTON2)
179 mouse_event.mi.mouseData = XBUTTON2;
181 SendInput(1, &mouse_event,
sizeof(INPUT));
185 wf_peer_mouse_event(input, flags, x, y);
191 BOOL wf_peer_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT8 code)
199 BOOL wf_peer_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
207 BOOL wf_peer_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
216 BOOL wf_peer_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)