Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update scancode processing #3138

Merged
merged 11 commits into from
Aug 6, 2024

Conversation

matt335672
Copy link
Member

@matt335672 matt335672 commented Jun 24, 2024

Fixes #621
Fixes #355

This is a significant re-write of xrdp keyboard handling.

See also xorgxrdp PR neutrinolabs/xorgxrdp#316

This builds on the work in #3039 / #3113 with significant changes:-

  1. The ad-hoc ways of indexing scancodes have been brought together in a 'scancode index' which maps an RDP scancode into an 8-bit value. This index can then be used to access an array containing state information about a particular key.
  2. RDP scancode defines are provided in a new development file xrdp_scancode_defs.h
  3. (related to the above) A lot of magic numbers have been removed.
  4. Some keys which only worked with xorgxrdp (pause and ABNT2 keypad point) now work with VNC as well.
  5. The confusingly named function xrdp_load_keyboard_layout() which is only needed for xorgxrdp has been renamed xrdp_init_xkb_layout() and is now only called when needed.
  6. The keycode set (base or evdev) can be specified for the X server at run-time.The corresponding XKB rules are passed to xorgxrdp.
  7. A minor unreported problem with xorgxrdp has been resolved.

I've got a bit more testing to do before I can merge this, but I'd welcome any comments.

@matt335672
Copy link
Member Author

Unless anyone's got any great objections, I'll merge this and neutrinolabs/xorgxrdp#316 into devel after we've shipped v0.10.1 (see #3155). It seems pretty solid to me, but I've not got a huge array of keyboards here for testing. Getting it out into the community should flush out any last few problems before we ship it in a major release.

The mapping from scancodes to the indexes used in xrdp_keymap
is not well designed and contains an implicit dependency on
keycode values.

This mapping is alse slightly different from the index used for
the 'keys' map in the xrdp_wm structure.

This commit introduces support for mapping scancodes directly
to 'scancode indexes' suitable for indexing into both structures.

Some renaming is also done; [MS-RDPBCGR] uses the terms scancode
and keyCode interchangeably. An effort is made to use key_code for a
raw value from a TS_KEYBOARD_EVENT, and scancode for a value which is
produced by the scancode module.
Replace definitions in ms-rdpbcgr.h marked as TODO with the
names defined in [MS-RDPBCGR]

Some other simplifications around the fake Unicode event processing
have also been made.
- All scancode definitions are moved to scancode.h
- Magic numbers are replaced where applicable with definitions
This commit moves processing of the pause key from xorgxrdp
back to xrdp itself, so that the key can be passed to the VNC
backend.
The Brazilian ABNT2 Keyboard layout contains a keypad
decimal key which doesn't exist on other keypads:-

https://www.kbdlayout.info/kbdbr/virtualkeys

This key is curently mapped in xorgxrdp to keycode 134 (basic mapping),
but isn't present in the scancode map. It needs to be added so that it
is available to VNC sessions and will be mapped for xorgxrdp when we
move to evdev keycode mappings.
Regenerate keymaps with pause key and ABNT2 keypad point
keys added.
Add a development header xrdp_scancode_defs.h which contains
common scancode definitions for xrdp and xorgxrdp
xrdp_load_keyboard_layout() is used exclusively by the xup module to
work out the parameters to pass to xorgxrdp for XKB. This function
does not need to be called locally from the SEC module.

This commit moves the function to xrdp/lang.c and renames it as
xrdp_init_xkb_layout(). The module interface is modified so that xup can
call this function. Other modules do not need to call it.
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.
When a connection is made to a system with the client numlock pressed, a
TS_SYNC_EVENT is sent before the module is loaded. This TS_SYNC_EVENT
correctly contains the NumLock status as 'pressed'. The event is, however,
discarded as the module isn't loaded.

When the module is loaded, a TS_SYNC_EVENT is not sent again unless
client focus is removed from the xrdp window and re-applied. As a
result, the NumLock state is incorrect unless this is done.

This commit stores the last TS_SYNC_EVENT sent before a module is
loaded. When the module is loaded, the sync state can be correctly
communicated to the module.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

xdotool does not type keys with AltGr modifier keyboard issue with xorgxrdp
1 participant