diff options
| author | Jules Aguillon | 2025-02-09 13:13:15 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2025-02-09 13:13:15 +0100 |
| commit | bd5c815a6fbd4312ff8fcd2ab6a457c41a1bb8d2 (patch) | |
| tree | 5aa58cebf73889764d836950aba55178ae4a4365 /srcs/juloo.keyboard2/KeyValue.java | |
| parent | 06b76d58c26b1681b79dc632b3f25e33bb84735b (diff) | |
| download | unexpected-keyboard-bd5c815a6fbd4312ff8fcd2ab6a457c41a1bb8d2.tar.gz unexpected-keyboard-bd5c815a6fbd4312ff8fcd2ab6a457c41a1bb8d2.zip | |
Refactor: Cleanup KeyValue flag declarations
Flag 'FLAGS_OFFSET << 8' was incorrectly mentionned as free and the
value bits were not taking free flags into account and were bigger than
expected.
Diffstat (limited to 'srcs/juloo.keyboard2/KeyValue.java')
| -rw-r--r-- | srcs/juloo.keyboard2/KeyValue.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/srcs/juloo.keyboard2/KeyValue.java b/srcs/juloo.keyboard2/KeyValue.java index fb1ce11..60d49e4 100644 --- a/srcs/juloo.keyboard2/KeyValue.java +++ b/srcs/juloo.keyboard2/KeyValue.java @@ -98,10 +98,10 @@ public final class KeyValue implements Comparable<KeyValue> StringWithSymbol, // [_payload] is a [KeyValue.StringWithSymbol], value is unused. } - private static final int FLAGS_OFFSET = 19; + private static final int FLAGS_OFFSET = 20; private static final int KIND_OFFSET = 28; - // Behavior flags. + // Key stay activated when pressed once. public static final int FLAG_LATCH = (1 << FLAGS_OFFSET << 0); // Key can be locked by typing twice when enabled in settings public static final int FLAG_DOUBLE_TAP_LOCK = (1 << FLAGS_OFFSET << 1); @@ -110,24 +110,23 @@ public final class KeyValue implements Comparable<KeyValue> // Whether the symbol should be greyed out. For example, keys that are not // part of the pending compose sequence. public static final int FLAG_GREYED = (1 << FLAGS_OFFSET << 3); - // Rendering flags. - public static final int FLAG_KEY_FONT = (1 << FLAGS_OFFSET << 4); // special font file - public static final int FLAG_SMALLER_FONT = (1 << FLAGS_OFFSET << 5); // 25% smaller symbols - public static final int FLAG_SECONDARY = (1 << FLAGS_OFFSET << 6); // dimmer - // Used by [Pointers]. + // The special font is required to render this key. + public static final int FLAG_KEY_FONT = (1 << FLAGS_OFFSET << 4); + // 25% smaller symbols + public static final int FLAG_SMALLER_FONT = (1 << FLAGS_OFFSET << 5); + // Dimmer symbol + public static final int FLAG_SECONDARY = (1 << FLAGS_OFFSET << 6); // Free: (1 << FLAGS_OFFSET << 7) - // Free: (1 << FLAGS_OFFSET << 8) // Ranges for the different components - private static final int FLAGS_BITS = - FLAG_LATCH | FLAG_DOUBLE_TAP_LOCK | FLAG_SPECIAL | FLAG_GREYED | - FLAG_KEY_FONT | FLAG_SMALLER_FONT | FLAG_SECONDARY; + private static final int FLAGS_BITS = (0b11111111 << FLAGS_OFFSET); // 8 bits wide private static final int KIND_BITS = (0b1111 << KIND_OFFSET); // 4 bits wide - private static final int VALUE_BITS = ~(FLAGS_BITS | KIND_BITS); // 20 bits wide + private static final int VALUE_BITS = 0b11111111111111111111; // 20 bits wide static { - check((FLAGS_BITS & KIND_BITS) == 0); // No overlap + check((FLAGS_BITS & KIND_BITS) == 0); // No overlap with kind + check(~(FLAGS_BITS | KIND_BITS) == VALUE_BITS); // No overlap with value check((FLAGS_BITS | KIND_BITS | VALUE_BITS) == ~0); // No holes // No kind is out of range check((((Kind.values().length - 1) << KIND_OFFSET) & ~KIND_BITS) == 0); |
