Skip to content

Commit

Permalink
fix(common,core): support other lookup for modifiers
Browse files Browse the repository at this point in the history
- the 'other' keyword was incorrectly called 'default'

Fixes: #11072
  • Loading branch information
srl295 committed Apr 2, 2024
1 parent 5615a5e commit 5b1c853
Show file tree
Hide file tree
Showing 12 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions common/include/kmx_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ namespace kmx {

#define K_MODIFIERFLAG 0x007F
#define K_NOTMODIFIERFLAG 0xFF00 // I4548
// Note: DEFAULT_MODIFIER = 0x10000, used by KMX+ for the
// default modifier flag in layers, > 16 bit so not available here.
// See keys_mod_default in keyman_core_ldml.ts
// Note: OTHER_MODIFIER = 0x10000, used by KMX+ for the
// other modifier flag in layers, > 16 bit so not available here.
// See keys_mod_other in keyman_core_ldml.ts

struct COMP_STORE {
KMX_DWORD_unaligned dwSystemID;
Expand Down
6 changes: 3 additions & 3 deletions common/web/keyboard-processor/src/text/codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ const Codes = {
"VIRTUAL_KEY":0x4000, // ISVIRTUALKEY
"VIRTUAL_CHAR_KEY":0x8000 // VIRTUALCHARKEY // Unused by KMW, but reserved for use by other Keyman engines.

// Note: keys_mod_default = 0x10000, used by KMX+ for the
// default modifier flag in layers, > 16 bit so not available here.
// See keys_mod_default in keyman_core_ldml.ts
// Note: keys_mod_other = 0x10000, used by KMX+ for the
// other modifier flag in layers, > 16 bit so not available here.
// See keys_mod_other in keyman_core_ldml.ts
},

modifierBitmasks: {
Expand Down
6 changes: 3 additions & 3 deletions common/web/types/src/kmx/kmx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ export class KMXFile {
public static readonly ISVIRTUALKEY = 0x4000; // It is a Virtual Key Sequence
public static readonly VIRTUALCHARKEY = 0x8000; // Keyman 6.0: Virtual Key Cap Sequence NOT YET

// Note: DEFAULT_MODIFIER = 0x10000, used by KMX+ for the
// default modifier flag in layers, > 16 bit so not available here.
// See keys_mod_default in keyman_core_ldml.ts
// Note: OTHER_MODIFIER = 0x10000, used by KMX+ for the
// other modifier flag in layers, > 16 bit so not available here.
// See keys_mod_other in keyman_core_ldml.ts

public static readonly MASK_MODIFIER_CHIRAL = KMXFile.LCTRLFLAG | KMXFile.RCTRLFLAG | KMXFile.LALTFLAG | KMXFile.RALTFLAG;
public static readonly MASK_MODIFIER_SHIFT = KMXFile.K_SHIFTFLAG;
Expand Down
8 changes: 4 additions & 4 deletions common/windows/cpp/include/legacy_kmx_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
#define RALTFLAG 0x0008 // Right Alt flag
#define K_SHIFTFLAG 0x0010 // Either shift flag
#define K_CTRLFLAG 0x0020 // Either ctrl flag
#define K_ALTFLAG 0x0040 // Either alt lag
#define K_ALTFLAG 0x0040 // Either alt flag
//#define K_METAFLAG 0x0080 // Either Meta-key flag (tentative). Not usable in keyboard rules;
// Used internally (currently, only by KMW) to ensure Meta-key
// shortcuts safely bypass rules
Expand All @@ -320,9 +320,9 @@
#define K_MODIFIERFLAG 0x007F
#define K_NOTMODIFIERFLAG 0xFF00 // I4548

// Note: DEFAULT_MODIFIER = 0x10000, used by KMX+ for the
// default modifier flag in layers, > 16 bit so not available here.
// See keys_mod_default in keyman_core_ldml.ts
// Note: OTHER_MODIFIER = 0x10000, used by KMX+ for the
// other modifier flag in layers, > 16 bit so not available here.
// See keys_mod_other in keyman_core_ldml.ts

/*
These sanity checks help ensure we don't
Expand Down
6 changes: 3 additions & 3 deletions common/windows/delphi/keyboards/kmxfileconsts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ interface
KMX_ISVIRTUALKEY = $4000; // It is a Virtual Key Sequence
KMX_VIRTUALCHARKEY = $8000; // It is a virtual character key sequence - mnemonic layouts

// Note: KMX_DEFAULT_MODIFIER = $10000, used by KMX+ for the
// default modifier flag in layers, > 16 bit so not available here.
// See keys_mod_default in keyman_core_ldml.ts
// Note: KMX_OTHER_MODIFIER = $10000, used by KMX+ for the
// other modifier flag in layers, > 16 bit so not available here.
// See keys_mod_other in keyman_core_ldml.ts

// Combinations of key masks
KMX_MASK_MODIFIER_CHIRAL = KMX_LCTRLFLAG or KMX_RCTRLFLAG or KMX_LALTFLAG or KMX_RALTFLAG;
Expand Down
2 changes: 1 addition & 1 deletion core/include/ldml/keyman_core_ldml.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
#define LDML_KEYS_MOD_CTRL 0x20
#define LDML_KEYS_MOD_CTRLL 0x1
#define LDML_KEYS_MOD_CTRLR 0x2
#define LDML_KEYS_MOD_DEFAULT 0x10000
#define LDML_KEYS_MOD_NONE 0x0
#define LDML_KEYS_MOD_OTHER 0x10000
#define LDML_KEYS_MOD_SHIFT 0x10
#define LDML_LAYR_LIST_HARDWARE_TOUCH "touch"
#define LDML_LENGTH_BKSP 0xC
Expand Down
6 changes: 3 additions & 3 deletions core/include/ldml/keyman_core_ldml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ class Constants {
readonly keys_mod_shift = 0x0010;

/**
* bitmask for 'default'.
* bitmask for 'other'.
*/
readonly keys_mod_default = 0x10000;
readonly keys_mod_other = 0x10000;

/**
* Convenience map for modifiers
Expand All @@ -289,7 +289,7 @@ class Constants {
["ctrlL", this.keys_mod_ctrlL],
["ctrlR", this.keys_mod_ctrlR],
["shift", this.keys_mod_shift],
["default", this.keys_mod_default],
["other", this.keys_mod_other],
]
);

Expand Down
2 changes: 1 addition & 1 deletion core/src/kmx/kmx_plus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ static_assert(LALTFLAG == LDML_KEYS_MOD_ALTL, "LDML modifier bitfield vs. kmx_fi
static_assert(K_ALTFLAG == LDML_KEYS_MOD_ALT, "LDML modifier bitfield vs. kmx_file.h #define mismatch");
static_assert(CAPITALFLAG == LDML_KEYS_MOD_CAPS, "LDML modifier bitfield vs. kmx_file.h #define mismatch");
static_assert(K_SHIFTFLAG == LDML_KEYS_MOD_SHIFT, "LDML modifier bitfield vs. kmx_file.h #define mismatch"); // "either" shift
// LDML_KEYS_MOD_DEFAULT is not present in kmx_file.h (>16 bit)
// LDML_KEYS_MOD_OTHER is not present in kmx_file.h (>16 bit)

/**
* \def LDML_IS_VALID_MODIFIER_BITS test whether x is a valid modifier bitfield
Expand Down
2 changes: 1 addition & 1 deletion core/src/ldml/C7043_ldml.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ For each key:
| 0x0020 | `ctrl` | `K_CTRLFLAG` | Either Control |
| 0x0040 | `alt` | `K_ALTFLAG` | Either Alt |
| 0x0100 | `caps` | `CAPITALFLAG` | Caps lock |
| 0x10000 | `default` | n/a | Default (not used in conjunction with others) |
| 0x10000 | `other` | n/a | Other (not used in conjunction with others) |

TODO-LDML: Note that conforming to other keyman values, left versus right shift
cannot be distinguished.
Expand Down
4 changes: 2 additions & 2 deletions core/src/ldml/ldml_vkeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ vkeys::lookup(km_core_virtual_key vk, uint16_t modifier_state, bool &found) cons
}
}

// look for a layer with "default"
// look for a layer with "other"
{
const vkey_id id_default(vk, (LDML_KEYS_MOD_DEFAULT));
const vkey_id id_default(vk, (LDML_KEYS_MOD_OTHER));
ret = lookup(id_default, found);
if (found) {
return ret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ will match the default layer
<layer id="shift" modifiers="shift">
<row keys="s" /> <!-- number row -->
</layer>
<layer id="default" modifiers="default">
<layer id="other" modifiers="other">
<row keys="d" /> <!-- number row -->
</layer>
</layers>
Expand Down
2 changes: 1 addition & 1 deletion core/tests/unit/ldml/keyboards/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tests_without_testdata = [
'k_005_modbittest',
'k_010_mt',
'k_011_mt_iso',
'k_012_default',
'k_012_other',
'k_100_keytest',
'k_101_keytest',
'k_102_keytest',
Expand Down

0 comments on commit 5b1c853

Please sign in to comment.