2012-07-31 05:32:44 +04:00
|
|
|
/**
|
2012-10-09 07:02:04 +04:00
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
2012-07-31 05:32:44 +04:00
|
|
|
* FreeRDP Windows Server
|
|
|
|
*
|
|
|
|
* Copyright 2012 Marc-Andre Moreau <marcandre.moreau@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-02-16 13:20:38 +03:00
|
|
|
#include <freerdp/config.h>
|
2012-08-15 01:20:53 +04:00
|
|
|
|
2012-07-31 05:32:44 +04:00
|
|
|
#include <winpr/windows.h>
|
|
|
|
|
|
|
|
#include "wf_input.h"
|
2012-11-01 06:10:27 +04:00
|
|
|
#include "wf_info.h"
|
2012-07-31 05:32:44 +04:00
|
|
|
|
2022-04-13 10:34:05 +03:00
|
|
|
BOOL wf_peer_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
|
2012-07-31 05:32:44 +04:00
|
|
|
{
|
|
|
|
INPUT keyboard_event;
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
2012-07-31 05:32:44 +04:00
|
|
|
keyboard_event.type = INPUT_KEYBOARD;
|
|
|
|
keyboard_event.ki.wVk = 0;
|
|
|
|
keyboard_event.ki.wScan = code;
|
|
|
|
keyboard_event.ki.dwFlags = KEYEVENTF_SCANCODE;
|
|
|
|
keyboard_event.ki.dwExtraInfo = 0;
|
|
|
|
keyboard_event.ki.time = 0;
|
|
|
|
|
|
|
|
if (flags & KBD_FLAGS_RELEASE)
|
|
|
|
keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
|
|
|
|
|
|
|
|
if (flags & KBD_FLAGS_EXTENDED)
|
|
|
|
keyboard_event.ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
|
|
|
|
|
|
|
SendInput(1, &keyboard_event, sizeof(INPUT));
|
2018-11-28 15:12:28 +03:00
|
|
|
return TRUE;
|
2012-07-31 05:32:44 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
BOOL wf_peer_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
|
2012-07-31 05:32:44 +04:00
|
|
|
{
|
|
|
|
INPUT keyboard_event;
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
2012-07-31 05:32:44 +04:00
|
|
|
keyboard_event.type = INPUT_KEYBOARD;
|
|
|
|
keyboard_event.ki.wVk = 0;
|
|
|
|
keyboard_event.ki.wScan = code;
|
|
|
|
keyboard_event.ki.dwFlags = KEYEVENTF_UNICODE;
|
|
|
|
keyboard_event.ki.dwExtraInfo = 0;
|
|
|
|
keyboard_event.ki.time = 0;
|
|
|
|
|
|
|
|
if (flags & KBD_FLAGS_RELEASE)
|
|
|
|
keyboard_event.ki.dwFlags |= KEYEVENTF_KEYUP;
|
|
|
|
|
|
|
|
SendInput(1, &keyboard_event, sizeof(INPUT));
|
2018-11-28 15:12:28 +03:00
|
|
|
return TRUE;
|
2012-07-31 05:32:44 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
BOOL wf_peer_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
2012-07-31 05:32:44 +04:00
|
|
|
{
|
2022-10-13 17:25:36 +03:00
|
|
|
INPUT mouse_event = { 0 };
|
2012-09-08 01:22:23 +04:00
|
|
|
float width, height;
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
2022-10-13 17:25:36 +03:00
|
|
|
|
|
|
|
WINPR_ASSERT(input);
|
2012-07-31 05:32:44 +04:00
|
|
|
mouse_event.type = INPUT_MOUSE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_WHEEL)
|
|
|
|
{
|
|
|
|
mouse_event.mi.dwFlags = MOUSEEVENTF_WHEEL;
|
|
|
|
mouse_event.mi.mouseData = flags & WheelRotationMask;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_WHEEL_NEGATIVE)
|
|
|
|
mouse_event.mi.mouseData *= -1;
|
|
|
|
|
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-28 15:12:28 +03:00
|
|
|
wfInfo* wfi;
|
2012-11-01 06:10:27 +04:00
|
|
|
wfi = wf_info_get_instance();
|
2018-11-28 15:12:28 +03:00
|
|
|
|
2015-04-03 17:21:01 +03:00
|
|
|
if (!wfi)
|
2018-11-28 15:12:28 +03:00
|
|
|
return FALSE;
|
2012-11-01 06:10:27 +04:00
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// width and height of primary screen (even in multimon setups
|
|
|
|
width = (float)GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
height = (float)GetSystemMetrics(SM_CYSCREEN);
|
2012-11-01 06:10:27 +04:00
|
|
|
x += wfi->servscreen_xoffset;
|
|
|
|
y += wfi->servscreen_yoffset;
|
2019-11-06 17:24:51 +03:00
|
|
|
mouse_event.mi.dx = (LONG)((float)x * (65535.0f / width));
|
|
|
|
mouse_event.mi.dy = (LONG)((float)y * (65535.0f / height));
|
2012-09-08 01:22:23 +04:00
|
|
|
mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
|
|
|
|
|
2012-07-31 05:32:44 +04:00
|
|
|
if (flags & PTR_FLAGS_MOVE)
|
|
|
|
{
|
2012-09-08 01:22:23 +04:00
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_MOVE;
|
2012-07-31 05:32:44 +04:00
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_BUTTON1)
|
|
|
|
{
|
|
|
|
if (flags & PTR_FLAGS_DOWN)
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_LEFTDOWN;
|
|
|
|
else
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_LEFTUP;
|
|
|
|
|
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else if (flags & PTR_FLAGS_BUTTON2)
|
|
|
|
{
|
|
|
|
if (flags & PTR_FLAGS_DOWN)
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_RIGHTDOWN;
|
|
|
|
else
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_RIGHTUP;
|
|
|
|
|
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else if (flags & PTR_FLAGS_BUTTON3)
|
|
|
|
{
|
|
|
|
if (flags & PTR_FLAGS_DOWN)
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_MIDDLEDOWN;
|
|
|
|
else
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_MIDDLEUP;
|
|
|
|
|
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
}
|
2018-11-28 15:12:28 +03:00
|
|
|
|
|
|
|
return TRUE;
|
2012-07-31 05:32:44 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
BOOL wf_peer_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
2012-07-31 05:32:44 +04:00
|
|
|
{
|
|
|
|
if ((flags & PTR_XFLAGS_BUTTON1) || (flags & PTR_XFLAGS_BUTTON2))
|
|
|
|
{
|
2022-10-13 17:25:36 +03:00
|
|
|
INPUT mouse_event = { 0 };
|
2012-07-31 05:32:44 +04:00
|
|
|
mouse_event.type = INPUT_MOUSE;
|
|
|
|
|
|
|
|
if (flags & PTR_FLAGS_MOVE)
|
|
|
|
{
|
2012-11-01 06:10:27 +04:00
|
|
|
float width, height;
|
2018-11-28 15:12:28 +03:00
|
|
|
wfInfo* wfi;
|
2012-11-01 06:10:27 +04:00
|
|
|
wfi = wf_info_get_instance();
|
2018-11-28 15:12:28 +03:00
|
|
|
|
2015-04-03 17:21:01 +03:00
|
|
|
if (!wfi)
|
2018-11-28 15:12:28 +03:00
|
|
|
return FALSE;
|
|
|
|
|
2019-11-06 17:24:51 +03:00
|
|
|
// width and height of primary screen (even in multimon setups
|
|
|
|
width = (float)GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
height = (float)GetSystemMetrics(SM_CYSCREEN);
|
2012-11-01 06:10:27 +04:00
|
|
|
x += wfi->servscreen_xoffset;
|
|
|
|
y += wfi->servscreen_yoffset;
|
2019-11-06 17:24:51 +03:00
|
|
|
mouse_event.mi.dx = (LONG)((float)x * (65535.0f / width));
|
|
|
|
mouse_event.mi.dy = (LONG)((float)y * (65535.0f / height));
|
2012-07-31 05:32:44 +04:00
|
|
|
mouse_event.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
|
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
|
|
|
|
mouse_event.mi.dx = mouse_event.mi.dy = mouse_event.mi.dwFlags = 0;
|
|
|
|
|
|
|
|
if (flags & PTR_XFLAGS_DOWN)
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_XDOWN;
|
|
|
|
else
|
|
|
|
mouse_event.mi.dwFlags |= MOUSEEVENTF_XUP;
|
|
|
|
|
|
|
|
if (flags & PTR_XFLAGS_BUTTON1)
|
|
|
|
mouse_event.mi.mouseData = XBUTTON1;
|
|
|
|
else if (flags & PTR_XFLAGS_BUTTON2)
|
|
|
|
mouse_event.mi.mouseData = XBUTTON2;
|
|
|
|
|
|
|
|
SendInput(1, &mouse_event, sizeof(INPUT));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wf_peer_mouse_event(input, flags, x, y);
|
|
|
|
}
|
2012-10-05 23:25:30 +04:00
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
return TRUE;
|
|
|
|
}
|
2012-10-05 23:25:30 +04:00
|
|
|
|
2022-04-13 10:34:05 +03:00
|
|
|
BOOL wf_peer_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT8 code)
|
2012-10-05 23:25:30 +04:00
|
|
|
{
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
WINPR_UNUSED(code);
|
|
|
|
return TRUE;
|
2012-10-05 23:25:30 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
BOOL wf_peer_unicode_keyboard_event_dummy(rdpInput* input, UINT16 flags, UINT16 code)
|
2012-10-05 23:25:30 +04:00
|
|
|
{
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
WINPR_UNUSED(code);
|
|
|
|
return TRUE;
|
2012-10-05 23:25:30 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
BOOL wf_peer_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
2012-10-05 23:25:30 +04:00
|
|
|
{
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
WINPR_UNUSED(x);
|
|
|
|
WINPR_UNUSED(y);
|
|
|
|
return TRUE;
|
2012-10-05 23:25:30 +04:00
|
|
|
}
|
|
|
|
|
2018-11-28 15:12:28 +03:00
|
|
|
BOOL wf_peer_extended_mouse_event_dummy(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
|
2012-10-05 23:25:30 +04:00
|
|
|
{
|
2018-11-28 15:12:28 +03:00
|
|
|
WINPR_UNUSED(input);
|
|
|
|
WINPR_UNUSED(flags);
|
|
|
|
WINPR_UNUSED(x);
|
|
|
|
WINPR_UNUSED(y);
|
|
|
|
return TRUE;
|
2012-10-05 23:25:30 +04:00
|
|
|
}
|