Page MenuHomeFreeBSD

Add support for Unicode characters in kbdmap dead key maps
ClosedPublic

Authored by se on Feb 4 2023, 1:17 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 24, 6:37 AM
Unknown Object (File)
Sat, Nov 23, 12:00 AM
Unknown Object (File)
Fri, Nov 22, 11:29 AM
Unknown Object (File)
Fri, Nov 22, 11:25 AM
Unknown Object (File)
Thu, Nov 21, 6:31 AM
Unknown Object (File)
Mon, Nov 18, 11:39 PM
Unknown Object (File)
Oct 20 2024, 10:36 PM
Unknown Object (File)
Sep 30 2024, 8:05 AM

Details

Summary

The keymap files support a 32 bit range for characters assigned to key codes, but only 8 bits of range for accented characters reached via dead keys.

This patch set adds support for the full range of Unicode characters to the accentmap table.
It provides backwards compatibility to allow an unpatched kbdcontrol command to load a keymap file on a kernel built with these patches applied.
This allows an old user land to run on a new kernel.

A kbdcontrol command built with these patches will not be able to load or display a dead key map when run on an old kernel (it will only load or display the non-dead key definitions).
(Compatibility code could be added to kbdcontrol to cover this case, but this has not been done when key codes have been extended to the full Unicode character set, some time ago.)

Test Plan

Install and boot a kernel built with these patches.
Verify that the kbdcontrol program works as before (with the limitation of 8 bit range for dead key map entries).

Rebuild the world with these patches (or just kbdcontrol after installation of sys/sys/kbio.h in /usr/include/sys).
Verify that the newly built kbdcontrol program works with your keymap file.

Load a keymap with Unicode characters in the dead keys map (e.g. "sk.kbd") and dump it with kbdcontrol -xd to verify the correct function with Unicode characters in the dead keys map.
(Best use "kbdcontrol < /dev/ttyv0" as root in a remote SSH session to compare keymap file and "kbdcontrol -xd" output for several complex keymap definitions.)

Since this patch set fixes an issue reported by users that need Unicode support for accented keys in dead key maps, this patch set should be considered for inclusion in FreeBSD-13.2.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

se requested review of this revision.Feb 4 2023, 1:17 PM
sys/sys/kbio.h
260

this would preclude updating kbdcontrol to do a fallback in case the kernel isn't new enough.

How hard would it be to add that?

The reason: we have some limited amount of need to run new code on old kernels. In this case, wouldn't it be needed to set the right keymap so that the keyboard would work well enough to unwind the problems?

sys/sys/kbio.h
260

It would be quite simple, in fact, but it seems that this was not done when the PIO_KEYMAP ioctl() was updated to support Unicode.

Required changes: the definitions of OGIO_DEADKEYMAP and OPIO_DEADKEYMAP, oaccentmap_t etc. need to be visible to user land builds (i.e. removal of #ifdef _KERNEL).

If the ioctl() fails for PIO_DEADKEYMAP, another one for OPIO_DEADKEYMAP with remapped argument can be attempted.

I'm not sure whether OGIO_DEADKEYMAP needs to be supported, too, but it would be trivially added, too.

The code required can be mostly grabbed from kbd/kbd.c (the API compatibility code implements the remapping between old and new data structure in both directions).

I'd appreciate if this review was accepted as is and I'd prepare another review for the kbdcontrol API compatibility within the next 2 days. It is really quite simple, but I do not have the time for testing right now.

se marked an inline comment as done.Feb 5 2023, 10:52 AM
brooks added a subscriber: brooks.

I'd somewhat like to see the compat bits go under COMPAT_FREEBSD13, probably along with O[GP]IO_KEYMAP, but that can go in another commit and there are arguments against it since people do tend to get bitten by not including COMPAT_* options in their custom kernels.

sys/dev/kbd/kbd.c
926–948

We almost always use sizeof as a function-like thing rather than operator including in the GIO_DEADKEYMAP above.

This revision is now accepted and ready to land.Feb 6 2023, 10:17 PM
se marked an inline comment as done.Feb 6 2023, 10:45 PM
se added inline comments.
sys/dev/kbd/kbd.c
926–948

I'll commit with function style sizeof() as suggested.
There are still operator style uses of sizeof in the OG/PIO_KEYMAP compatibility functions (and I'm not going to touch that code in this commit).

This revision was automatically updated to reflect the committed changes.
se marked an inline comment as done.