From 9bf924929c78cc76f534494c2f0b0a72db27ad7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Thu, 2 May 2013 01:34:54 -0400 Subject: [PATCH] xfreerdp-server: use libwinpr-input for keyboard mapping --- server/X11/CMakeLists.txt | 4 +++- server/X11/xf_cursor.c | 35 ++++++++++++++++++++++++++++++++++ server/X11/xf_cursor.h | 28 +++++++++++++++++++++++++++ server/X11/xf_input.c | 12 ++++++++++-- winpr/include/winpr/input.h | 1 + winpr/libwinpr/input/keycode.c | 31 ++++++++++++++++++++++++++++++ 6 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 server/X11/xf_cursor.c create mode 100644 server/X11/xf_cursor.h diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index 34381ae85..261576500 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -30,6 +30,8 @@ set(${MODULE_PREFIX}_SRCS xf_encode.h xf_update.c xf_update.h + xf_cursor.c + xf_cursor.h xf_monitors.c xf_monitors.h xf_interface.c @@ -137,7 +139,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS MONOLITHIC ${MONOLITHIC_BUILD} MODULE winpr - MODULES winpr-sspi) + MODULES winpr-sspi winpr-crt winpr-utils winpr-input winpr-sysinfo) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr-makecert-tool) diff --git a/server/X11/xf_cursor.c b/server/X11/xf_cursor.c new file mode 100644 index 000000000..ca5917a02 --- /dev/null +++ b/server/X11/xf_cursor.c @@ -0,0 +1,35 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Cursor + * + * Copyright 2013 Marc-Andre Moreau + * + * 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. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include + +#ifdef WITH_XCURSOR +#include +#endif + +#include + +#include "xf_cursor.h" + + diff --git a/server/X11/xf_cursor.h b/server/X11/xf_cursor.h new file mode 100644 index 000000000..1c8c19652 --- /dev/null +++ b/server/X11/xf_cursor.h @@ -0,0 +1,28 @@ +/** + * FreeRDP: A Remote Desktop Protocol Implementation + * X11 Server Cursor + * + * Copyright 2013 Marc-Andre Moreau + * + * 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. + */ + +#ifndef XFREERDP_SERVER_CURSOR_H +#define XFREERDP_SERVER_CURSOR_H + +#include "xfreerdp.h" + + + +#endif /* XFREERDP_SERVER_CURSOR_H */ + diff --git a/server/X11/xf_input.c b/server/X11/xf_input.c index feac6ebf5..14d55fca7 100644 --- a/server/X11/xf_input.c +++ b/server/X11/xf_input.c @@ -25,6 +25,9 @@ #include +#include +#include + #include "xf_peer.h" #include "xf_input.h" @@ -37,7 +40,8 @@ void xf_input_synchronize_event(rdpInput* input, UINT32 flags) void xf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) { #ifdef WITH_XTEST - unsigned int keycode; + DWORD vkcode; + DWORD keycode; BOOL extended = FALSE; xfPeerContext* xfp = (xfPeerContext*) input->context; xfInfo* xfi = xfp->info; @@ -45,7 +49,11 @@ void xf_input_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code) if (flags & KBD_FLAGS_EXTENDED) extended = TRUE; - keycode = freerdp_keyboard_get_x11_keycode_from_rdp_scancode(code, extended); + if (extended) + code |= KBDEXT; + + vkcode = GetVirtualKeyCodeFromVirtualScanCode(code, 4); + keycode = GetKeycodeFromVirtualKeyCode(vkcode, KEYCODE_TYPE_EVDEV); if (keycode != 0) { diff --git a/winpr/include/winpr/input.h b/winpr/include/winpr/input.h index 6ca12d302..6779f30fa 100644 --- a/winpr/include/winpr/input.h +++ b/winpr/include/winpr/input.h @@ -874,6 +874,7 @@ WINPR_API DWORD GetVirtualScanCodeFromVirtualKeyCode(DWORD vkcode, DWORD dwKeybo #define KEYCODE_TYPE_EVDEV 0x00000002 WINPR_API DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags); +WINPR_API DWORD GetKeycodeFromVirtualKeyCode(DWORD keycode, DWORD dwFlags); #ifdef __cplusplus } diff --git a/winpr/libwinpr/input/keycode.c b/winpr/libwinpr/input/keycode.c index 63960a152..295fe3b1b 100644 --- a/winpr/libwinpr/input/keycode.c +++ b/winpr/libwinpr/input/keycode.c @@ -584,3 +584,34 @@ DWORD GetVirtualKeyCodeFromKeycode(DWORD keycode, DWORD dwFlags) return vkcode; } + +DWORD GetKeycodeFromVirtualKeyCode(DWORD vkcode, DWORD dwFlags) +{ + int index; + DWORD keycode = 0; + + if (dwFlags & KEYCODE_TYPE_APPLE) + { + for (index = 0; index < 256; index++) + { + if (vkcode == KEYCODE_TO_VKCODE_APPLE[index]) + { + keycode = index; + break; + } + } + } + else if (dwFlags & KEYCODE_TYPE_EVDEV) + { + for (index = 0; index < 256; index++) + { + if (vkcode == KEYCODE_TO_VKCODE_EVDEV[index]) + { + keycode = index; + break; + } + } + } + + return keycode; +}