Allow keycode set to be specified for the X server

This commit allows a keycode_set to be specified as a module parameter
in xrdp.ini. This has the following effects:-
1) xrdp loads the specified keycode set for mapping RDP scancodes to
   X11 keycodes. These are then passed to xorgxrdp as part of key press/
   key release events.
2) The name of the XKB rules which use the specified keycode set are
   passed to xorgxrdp so that XKB can be configured with rules which
   match the chosen keycodes.

The effect is to remove all keycode set dependencies from xorgxrdp.
Normally evdev rules and evdev keycodes will be used but base rules and
base keycodes can be used instead for applications that require them.
Also, any systems which do not ship the evdev rules can be made to
work with base rules.
This commit is contained in:
matt335672 2024-06-24 15:07:54 +01:00
parent c9a2039858
commit ba1d93930a
7 changed files with 42 additions and 2 deletions

View File

@ -200,6 +200,11 @@ struct xrdp_client_info
char layout[16]; char layout[16];
char variant[16]; char variant[16];
char options[256]; char options[256];
char xkb_rules[32];
// A few x11 keycodes are needed by the xup module
int x11_keycode_caps_lock;
int x11_keycode_num_lock;
int x11_keycode_scroll_lock;
/* ==================================================================== */ /* ==================================================================== */
/* Private to xrdp below this line */ /* Private to xrdp below this line */
@ -269,6 +274,6 @@ enum xrdp_encoder_flags
/* yyyymmdd of last incompatible change to xrdp_client_info */ /* yyyymmdd of last incompatible change to xrdp_client_info */
/* also used for changes to all the xrdp installed headers */ /* also used for changes to all the xrdp installed headers */
#define CLIENT_INFO_CURRENT_VERSION 20240514 #define CLIENT_INFO_CURRENT_VERSION 20240805
#endif #endif

View File

@ -390,6 +390,11 @@ use of \fBxrdp\-chansrv\fR facilities in the VNC session.
The first form of this setting is recommended, replacing \fIn\fR with the The first form of this setting is recommended, replacing \fIn\fR with the
X11 display number of the session. X11 display number of the session.
.TP
\fBkeycode_set\fR=\fI<string>\fR
[Xorg only] Asks for the specified keycode set to be used by the X server.
Normally "evdev" or "base". The default should be correct for your system.
.SH "EXAMPLES" .SH "EXAMPLES"
This is an example \fBxrdp.ini\fR: This is an example \fBxrdp.ini\fR:

@ -1 +1 @@
Subproject commit c6b41afa6986d5e6df18778a342b407cae40e1b5 Subproject commit e8208bfc0b9d122b1c393a659427fbb135e9cd75

View File

@ -653,4 +653,14 @@ xrdp_init_xkb_layout(struct xrdp_client_info *client_info)
LOG(LOG_LEVEL_ERROR, "xrdp_init_xkb_layout: error opening %s", LOG(LOG_LEVEL_ERROR, "xrdp_init_xkb_layout: error opening %s",
keyboard_cfg_file); keyboard_cfg_file);
} }
// Initialise the rules and a few keycodes for xorgxrdp
snprintf(client_info->xkb_rules, sizeof(client_info->xkb_rules),
"%s", scancode_get_xkb_rules());
client_info->x11_keycode_caps_lock =
scancode_to_x11_keycode(SCANCODE_CAPS_KEY);
client_info->x11_keycode_num_lock =
scancode_to_x11_keycode(SCANCODE_NUMLOCK_KEY);
client_info->x11_keycode_scroll_lock =
scancode_to_x11_keycode(SCANCODE_SCROLL_KEY);
} }

View File

@ -248,6 +248,7 @@ username=ask
password=ask password=ask
port=-1 port=-1
code=20 code=20
#keycode_set=evdev
[Xvnc] [Xvnc]
name=Xvnc name=Xvnc

View File

@ -175,7 +175,21 @@ lib_mod_connect(struct mod *mod)
// be set. // be set.
// //
// Load the XKB layout // Load the XKB layout
if (mod->keycode_set[0] != '\0')
{
if (scancode_set_keycode_set(mod->keycode_set) == 0)
{
LOG(LOG_LEVEL_INFO, "Loaded '%s' keycode set", mod->keycode_set);
}
else
{
LOG(LOG_LEVEL_WARNING, "Unable to load '%s' keycode set",
mod->keycode_set);
}
}
mod->server_init_xkb_layout(mod, &(mod->client_info)); mod->server_init_xkb_layout(mod, &(mod->client_info));
LOG(LOG_LEVEL_INFO, "XKB rules '%s' will be used by the module",
mod->client_info.xkb_rules);
make_stream(s); make_stream(s);
g_sprintf(con_port, "%s", mod->port); g_sprintf(con_port, "%s", mod->port);
@ -1869,6 +1883,10 @@ lib_mod_set_param(struct mod *mod, const char *name, const char *value)
{ {
g_strncpy(mod->port, value, 255); g_strncpy(mod->port, value, 255);
} }
else if (g_strcasecmp(name, "keycode_set") == 0)
{
g_snprintf(mod->keycode_set, sizeof(mod->keycode_set), "%s", value);
}
else if (g_strcasecmp(name, "client_info") == 0) else if (g_strcasecmp(name, "client_info") == 0)
{ {
g_memcpy(&(mod->client_info), value, sizeof(mod->client_info)); g_memcpy(&(mod->client_info), value, sizeof(mod->client_info));

View File

@ -201,6 +201,7 @@ struct mod
int screen_shmem_id_mapped; /* boolean */ int screen_shmem_id_mapped; /* boolean */
char *screen_shmem_pixels; char *screen_shmem_pixels;
struct trans *trans; struct trans *trans;
char keycode_set[32];
}; };
#endif // XUP_H #endif // XUP_H