keymanapp / keyman

Keyman cross platform input methods system running on Android, iOS, Linux, macOS, Windows and mobile and desktop web
https://keyman.com/
Other
379 stars 106 forks source link

feat(linux): Mnemonic keyboard support #3345

Open ermshiperete opened 3 years ago

ermshiperete commented 3 years ago

Currently Linux doesn't properly support mnemonic keyboards - a US-English keyboard base layout is always assumed. see #8972, #8973, #8974, #8975, #8977, #8978, #8979

mcdurdin commented 3 years ago

The way I'd like to solve this is to use the mnemonic layout recompiler (mcompile) to build positional versions of a mnemonic keyboard. mcompile takes a mnemonic layout and combines it with a Windows base layout to produce a positional layout that should work unmodified on other platforms. We then ensure that the other platforms always treat the base layout as US (with a couple of minor tweaks around modifiers and additional keys not on a US keyboard) so that positional layouts always work consistently.

Note that the Windows core itself is positional now, because mcompile does the hard work.

Right now, mcompile has a dependency on Windows for parsing the base layout, but I think we can build a table of base layouts into mcompile, and once we have that then mcompile itself should be very cross-platform.

mcdurdin commented 3 years ago

The same approach applies for mac (won't open an issue on this just now)

ermshiperete commented 3 years ago

So mcompile gets executed when the keyboard gets installed? And as base layout the default (or first) keyboard/language is used. What happens when the user sets a different default?

mcdurdin commented 3 years ago

On Windows, yes, mcompile runs when the keyboard is installed. The base layout by default is the first Latin-script Windows keyboard on the system (the user's default keyboard is first keyboard). The user can change the base layout in Keyman Configuration, which then triggers a re-run of mcompile. Keyman on Windows stores each mrecompiled keyboard along with the original in the keyboard folder:

image

Note that the -d alternative treats 'deadkeys as plain keys'. Keyman uses this keyboard internally if that option is selected in Configuration.

ermshiperete commented 3 years ago

Hmm, implementing an option to select the base keyboard in km-config might be a quicker way to support mnemonic keyboards on Linux.

No, not really. Without a way of knowing if it's a positional or a mnemonic keyboard this would break positional keyboards. Or does it? Need to test...

mcdurdin commented 3 years ago

Hmm, implementing an option to select the base keyboard in km-config might be a quicker way to support mnemonic keyboards on Linux.

Mnemonic keyboards will not work correctly without mcompile. The algorithm for mnemonic layouts is not straightforward to implement, because it's based on matching character output rather than key codes, and there are a bunch of nuances around modifier keys and dead keys. I don't think we want to pursue an implementation that doesn't make use of mcompile.

No, not really. Without a way of knowing if it's a positional or a mnemonic keyboard this would break positional keyboards. Or does it? Need to test...

A .kmx file has a &mnemoniclayout flag.

mcdurdin commented 3 years ago

See also https://community.software.sil.org/t/keyman-sil-ipa-with-a-german-keyboard/3238/7

ermshiperete commented 2 years ago

There are some ibus-keyman integration tests that should be enabled (in linux/ibus-keyman/tests/testfixture.cpp) once mnemonic keyboards are supported on Linux:

SabineSIL commented 5 months ago

bumped to 18.0/Future since comparing/testing resulting files and deadkeys need to be done.