diff --git a/common/include/kmx_file.h b/common/include/kmx_file.h index 998c9780072..b689ba685ad 100644 --- a/common/include/kmx_file.h +++ b/common/include/kmx_file.h @@ -7,6 +7,24 @@ #include +/* + When we read .kmx files, they have no alignment guarantees, so we need to tell + the compiler to generate unaligned-safe code for accesses to COMP_ structure + members. Note we are assuming that COMP_KEYBOARD is aligned because it is + always the start of the file, so will be at the start of any buffer which will + automatically be aligned correctly. +*/ +#ifdef __EMSCRIPTEN__ +typedef KMX_DWORD __attribute__((aligned(1))) KMX_DWORD_unaligned; +typedef KMX_BOOL __attribute__((aligned(1))) KMX_BOOL_unaligned; +typedef KMX_WORD __attribute__((aligned(1))) KMX_WORD_unaligned; +#else +// TODO: consider other platforms +#define KMX_DWORD_unaligned KMX_DWORD +#define KMX_BOOL_unaligned KMX_BOOL +#define KMX_WORD_unaligned KMX_WORD +#endif + #ifdef KMN_KBP // TODO: move this to a common namespace keyman::common::kmx_file or similar in the future namespace km { @@ -153,7 +171,13 @@ namespace kmx { #define TSS__KEYMAN_150_MAX 43 -#define TSS__MAX 43 +/* Keyman 17.0 system stores */ + +#define TSS_DISPLAYMAP 44 + +#define TSS__KEYMAN_170_MAX 44 + +#define TSS__MAX 44 /* wm_keyman_control_internal message control codes */ @@ -297,27 +321,27 @@ namespace kmx { #define K_NOTMODIFIERFLAG 0xFF00 // I4548 struct COMP_STORE { - KMX_DWORD dwSystemID; - KMX_DWORD dpName; - KMX_DWORD dpString; + KMX_DWORD_unaligned dwSystemID; + KMX_DWORD_unaligned dpName; + KMX_DWORD_unaligned dpString; }; struct COMP_KEY { - KMX_WORD Key; - KMX_WORD _reserved; - KMX_DWORD Line; - KMX_DWORD ShiftFlags; - KMX_DWORD dpOutput; - KMX_DWORD dpContext; + KMX_WORD_unaligned Key; + KMX_WORD_unaligned _reserved; + KMX_DWORD_unaligned Line; + KMX_DWORD_unaligned ShiftFlags; + KMX_DWORD_unaligned dpOutput; + KMX_DWORD_unaligned dpContext; }; struct COMP_GROUP { - KMX_DWORD dpName; - KMX_DWORD dpKeyArray; // [LPKEY] address of first item in key array - KMX_DWORD dpMatch; - KMX_DWORD dpNoMatch; - KMX_DWORD cxKeyArray; // in array entries - KMX_BOOL fUsingKeys; // group(xx) [using keys] <-- specified or not + KMX_DWORD_unaligned dpName; + KMX_DWORD_unaligned dpKeyArray; // [LPKEY] address of first item in key array + KMX_DWORD_unaligned dpMatch; + KMX_DWORD_unaligned dpNoMatch; + KMX_DWORD_unaligned cxKeyArray; // in array entries + KMX_BOOL_unaligned fUsingKeys; // group(xx) [using keys] <-- specified or not }; struct COMP_KEYBOARD { diff --git a/common/schemas/displaymap/README.md b/common/schemas/displaymap/README.md new file mode 100644 index 00000000000..1958c3047e4 --- /dev/null +++ b/common/schemas/displaymap/README.md @@ -0,0 +1,77 @@ +# displaymap.schema.json + +This mapping file provides data for remapping the touch layout and visual +keyboard key caps. The primary purpose of this file is to provide a pathway for +consistent display of diacritics and other unattached marks which may be +displayed on the keyboard by use of a special font with formatted glyphs in the +Private Use Area, which will have consistent display across all platforms and +not rely on platform-specific or font-specific rendering behaviors. + +This file can be generated by `kmc analyze osk-char-use` command, or hand +crafted. The compiler uses only the `str` and `pua` values in the file, although +there may be additional data in the file provided for reference purposes. The +file should have the following structure, in this example, mapping the Unicode +values `U+17BB U+17C7` (ុះ) to the Private Use Area code `U+F19F`: + +```json +{ + "map": [ + { + "pua": "F19F", + "str": "ុះ", + "unicode": "17BB 17C7", + "usages": [ + "khmer_angkor.kvks", + "khmer_angkor.keyman-touch-layout" + ] + }, + ... + ] +} +``` + +The file can be passed without modification to the [ttkbdfont.py script][2] +(unsupported) to generate a Kbd font. The font may need some manual editing as +insertion of dotted circle (`U+25CC`) as a base may not always be possible +automatically, and combined marks may not render as a cluster in some scenarios. +The open source tool [FontForge][3] is suitable for making these kinds of minor +adjustments to the generated font. + +## Standard conventions for use of displayMaps + +In the Keyman keyboards repository, the PUA range used should start at `U+F100`. + +`&displayMap` JSON files should be named `Kbd