Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/Remmina/Remmina.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorheadkaze <headkaze@gmail.com>2021-12-17 15:05:02 +0300
committerheadkaze <headkaze@gmail.com>2021-12-17 15:05:02 +0300
commit2143beac690d085506a02fd6038d5dae8e16e724 (patch)
tree61de674281f1a41aa5d5d8e472a5210753b1400d
parentf26ff86d520cd384c1dfa7a1b099225cd9c1b321 (diff)
Add Keyboard mapping per client RDP
-rw-r--r--plugins/rdp/rdp_plugin.c46
-rw-r--r--src/remmina_pref.c2
-rw-r--r--src/remmina_pref.h1
3 files changed, 46 insertions, 3 deletions
diff --git a/plugins/rdp/rdp_plugin.c b/plugins/rdp/rdp_plugin.c
index ff9de75b5..6d33531ac 100644
--- a/plugins/rdp/rdp_plugin.c
+++ b/plugins/rdp/rdp_plugin.c
@@ -80,6 +80,9 @@
#include <pthread_np.h>
#endif
+#include "../remmina_pref.h"
+#include <freerdp/locale/keyboard.h>
+
#define REMMINA_RDP_FEATURE_TOOL_REFRESH 1
#define REMMINA_RDP_FEATURE_SCALE 2
#define REMMINA_RDP_FEATURE_UNFOCUS 3
@@ -1288,6 +1291,36 @@ static gboolean remmina_rdp_set_connection_type(rdpSettings *settings, guint32 t
return TRUE;
}
+static gchar *remmina_get_rdp_kbd_remap(const gchar *keymap)
+{
+ TRACE_CALL(__func__);
+ guint *table;
+ gchar keys[20];
+ gchar *rdp_kbd_remap = NULL;
+ gint i;
+ Display *display;
+
+ if (!keymap || keymap[0] == '\0')
+ return rdp_kbd_remap;
+
+ table = (guint *)g_hash_table_lookup(remmina_keymap_table, keymap);
+ if (!table)
+ return rdp_kbd_remap;
+ rdp_kbd_remap = g_malloc0(512);
+ display = XOpenDisplay(0);
+ for (i = 0; table[i] > 0; i += 2) {
+ g_snprintf(keys, sizeof(keys), "0x%02x=0x%02x", freerdp_keyboard_get_rdp_scancode_from_x11_keycode(XKeysymToKeycode(display, table[i])), freerdp_keyboard_get_rdp_scancode_from_x11_keycode(XKeysymToKeycode(display, table[i + 1])));
+
+ if (i > 0)
+ g_strlcat(rdp_kbd_remap, ",", 512);
+
+ g_strlcat(rdp_kbd_remap, keys, 512);
+ }
+ XCloseDisplay(display);
+
+ return rdp_kbd_remap;
+}
+
static gboolean remmina_rdp_main(RemminaProtocolWidget *gp)
{
TRACE_CALL(__func__);
@@ -1302,6 +1335,7 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget *gp)
gint gateway_port;
gchar *datapath = NULL;
gboolean status = TRUE;
+ gchar *rdp_kbd_remap;
gint i;
gint desktopOrientation, desktopScaleFactor, deviceScaleFactor;
@@ -1642,8 +1676,16 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget *gp)
freerdp_performance_flags_split(rfi->settings);
#if FREERDP_CHECK_VERSION(2, 3, 0)
- freerdp_settings_set_string(rfi->settings, FreeRDP_KeyboardRemappingList, remmina_plugin_service->pref_get_value("rdp_kbd_remap"));
- REMMINA_PLUGIN_DEBUG("rdp_keyboard_remapping_list: %s", rfi->settings->KeyboardRemappingList);
+ rdp_kbd_remap = remmina_get_rdp_kbd_remap(remmina_plugin_service->file_get_string(remminafile, "keymap"));
+ if (rdp_kbd_remap != NULL) {
+ freerdp_settings_set_string(rfi->settings, FreeRDP_KeyboardRemappingList, rdp_kbd_remap);
+ REMMINA_PLUGIN_DEBUG("rdp_keyboard_remapping_list: %s", rfi->settings->KeyboardRemappingList);
+ g_free(rdp_kbd_remap);
+ }
+ else {
+ freerdp_settings_set_string(rfi->settings, FreeRDP_KeyboardRemappingList, remmina_plugin_service->pref_get_value("rdp_kbd_remap"));
+ REMMINA_PLUGIN_DEBUG("rdp_keyboard_remapping_list: %s", rfi->settings->KeyboardRemappingList);
+ }
#endif
freerdp_settings_set_uint32(rfi->settings, FreeRDP_KeyboardLayout, remmina_rdp_settings_get_keyboard_layout());
diff --git a/src/remmina_pref.c b/src/remmina_pref.c
index 680ea7a98..4ef129e4c 100644
--- a/src/remmina_pref.c
+++ b/src/remmina_pref.c
@@ -57,7 +57,7 @@ const gchar *default_resolutions = "640x480,800x600,1024x768,1152x864,1280x960,1
const gchar *default_keystrokes = "Send hello world§hello world\\n";
gchar *remmina_keymap_file;
-static GHashTable *remmina_keymap_table = NULL;
+GHashTable *remmina_keymap_table = NULL;
/* We could customize this further if there are more requirements */
static const gchar *default_keymap_data = "# Please check gdk/gdkkeysyms.h for a full list of all key names or hex key values\n"
diff --git a/src/remmina_pref.h b/src/remmina_pref.h
index 10a37c060..fbb95f003 100644
--- a/src/remmina_pref.h
+++ b/src/remmina_pref.h
@@ -229,6 +229,7 @@ typedef struct _RemminaPref {
#define SSH_SOCKET_TCP_KEEPCNT 3
#define SSH_SOCKET_TCP_USER_TIMEOUT 60000 // 60 seconds
+extern GHashTable *remmina_keymap_table;
extern const gchar *default_resolutions;
extern gchar *remmina_pref_file;
extern gchar *remmina_colors_file;