Merge pull request #2587 from metalefty/keymap_load
[refactoring] xrdp: enable loading any keymap files
This commit is contained in:
commit
7bf95fc1d2
51
xrdp/lang.c
51
xrdp/lang.c
@ -231,7 +231,6 @@ km_read_section(int fd, const char *section_name, struct xrdp_key_info *keymap)
|
||||
int
|
||||
get_keymaps(int keylayout, struct xrdp_keymap *keymap)
|
||||
{
|
||||
int fd;
|
||||
int basic_key_layout = keylayout & 0x0000ffff;
|
||||
char *filename;
|
||||
struct xrdp_keymap *lkeymap;
|
||||
@ -258,16 +257,41 @@ get_keymaps(int keylayout, struct xrdp_keymap *keymap)
|
||||
|
||||
if (g_file_exist(filename))
|
||||
{
|
||||
fd = g_file_open(filename);
|
||||
LOG(LOG_LEVEL_INFO, "Loading keymap file %s", filename);
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
lkeymap = (struct xrdp_keymap *)g_malloc(sizeof(struct xrdp_keymap), 0);
|
||||
/* make a copy of the built-in keymap */
|
||||
g_memcpy(lkeymap, keymap, sizeof(struct xrdp_keymap));
|
||||
/* clear the keymaps */
|
||||
g_memset(keymap, 0, sizeof(struct xrdp_keymap));
|
||||
|
||||
km_load_file(filename, keymap);
|
||||
|
||||
if (g_memcmp(lkeymap, keymap, sizeof(struct xrdp_keymap)) != 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING,
|
||||
"local keymap file for 0x%08x found and doesn't match "
|
||||
"built in keymap, using local keymap file", keylayout);
|
||||
}
|
||||
|
||||
g_free(lkeymap);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING, "File does not exist: %s", filename);
|
||||
}
|
||||
|
||||
g_free(filename);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
int km_load_file(const char *filename, struct xrdp_keymap *keymap)
|
||||
{
|
||||
int fd;
|
||||
|
||||
LOG(LOG_LEVEL_INFO, "Loading keymap file %s", filename);
|
||||
fd = g_file_open(filename);
|
||||
|
||||
if (fd != -1)
|
||||
{
|
||||
/* read the keymaps */
|
||||
km_read_section(fd, "noshift", keymap->keys_noshift);
|
||||
km_read_section(fd, "shift", keymap->keys_shift);
|
||||
@ -278,22 +302,13 @@ get_keymaps(int keylayout, struct xrdp_keymap *keymap)
|
||||
km_read_section(fd, "shiftcapslock", keymap->keys_shiftcapslock);
|
||||
km_read_section(fd, "shiftcapslockaltgr", keymap->keys_shiftcapslockaltgr);
|
||||
|
||||
if (g_memcmp(lkeymap, keymap, sizeof(struct xrdp_keymap)) != 0)
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING,
|
||||
"local keymap file for 0x%08x found and doesn't match "
|
||||
"built in keymap, using local keymap file", keylayout);
|
||||
}
|
||||
|
||||
g_free(lkeymap);
|
||||
g_file_close(fd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(LOG_LEVEL_WARNING, "File does not exist: %s", filename);
|
||||
LOG(LOG_LEVEL_ERROR, "Error loading keymap file %s (%s)", filename, g_get_strerror());
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_free(filename);
|
||||
return 0;
|
||||
}
|
||||
|
@ -411,6 +411,9 @@ get_char_from_scan_code(int device_flags, int scan_code, int *keys,
|
||||
int
|
||||
get_keymaps(int keylayout, struct xrdp_keymap *keymap);
|
||||
|
||||
int
|
||||
km_load_file(const char *filename, struct xrdp_keymap *keymap);
|
||||
|
||||
/* xrdp_login_wnd.c */
|
||||
/**
|
||||
* Gets the DPI of the login (primary) monitor
|
||||
|
Loading…
Reference in New Issue
Block a user