commit 8abc3326dffd8a7772ebcc491eeceb10eb94c02c
parent e3f414536e22908ced14895e40ebc6475a29ef93
Author: Maarten van Gompel <proycon@anaproy.nl>
Date: Mon, 23 Aug 2021 23:31:51 +0200
added cyrillic compose layers and made compose work with non-code keys
Diffstat:
M | keyboard.h | | | 42 | ++++++++++++++++++++---------------------- |
M | layout.mobile.h | | | 240 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- |
2 files changed, 247 insertions(+), 35 deletions(-)
diff --git a/keyboard.h b/keyboard.h
@@ -180,6 +180,19 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) {
void
kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
+ if ((compose == 1) && (k->type != Compose) && (k->type != Mod) && (k->layout)) {
+ compose++;
+ fprintf(stderr,"showing compose %d\n", compose);
+ if ((!kb->prevlayout) || (strcmp(kb->prevlayout->keymap_name, kb->layout->keymap_name) != 0)) {
+ create_and_upload_keymap(kb->layout->keymap_name, 0, 0);
+ }
+ kb->prevlayout = kb->layout;
+ kb->layout = k->layout;
+ kbd_draw_layout(kb);
+ kb->surf->dirty = true;
+ return;
+ }
+
switch (k->type) {
case Code:
if (k->code_mod) {
@@ -191,28 +204,13 @@ kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
} else {
zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
}
- if (compose == 1) {
- if (k->layout) {
- compose++;
- if (compose) {
- fprintf(stderr,"showing compose %d\n", compose);
- }
- if ((!kb->prevlayout) || (strcmp(kb->prevlayout->keymap_name, kb->layout->keymap_name) != 0)) {
- create_and_upload_keymap(kb->layout->keymap_name, 0, 0);
- }
- kb->prevlayout = kb->layout;
- kb->layout = k->layout;
- kbd_draw_layout(kb);
- }
- } else {
- kb->last_press = k;
- kbd_draw_key(kb, k, true);
- zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
- WL_KEYBOARD_KEY_STATE_PRESSED);
- if (compose) {
- fprintf(stderr,"pressing composed key\n");
- compose++;
- }
+ kb->last_press = k;
+ kbd_draw_key(kb, k, true);
+ zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
+ WL_KEYBOARD_KEY_STATE_PRESSED);
+ if (compose) {
+ fprintf(stderr,"pressing composed key\n");
+ compose++;
}
break;
case Mod:
diff --git a/layout.mobile.h b/layout.mobile.h
@@ -48,6 +48,16 @@ enum layout_names {
ComposeB,
ComposeN,
ComposeM,
+ ComposeCyrI,
+ ComposeCyrJ,
+ ComposeCyrE,
+ ComposeCyrU,
+ ComposeCyrL,
+ ComposeCyrN,
+ ComposeCyrTse,
+ ComposeCyrChe,
+ ComposeCyrG,
+ ComposeCyrK,
NumLayouts,
};
@@ -77,7 +87,17 @@ static struct key keys_full[], keys_special[], keys_simple[], keys_cyrillic[],
keys_compose_v[],
keys_compose_b[],
keys_compose_n[],
- keys_compose_m[];
+ keys_compose_m[],
+ keys_compose_cyr_i[],
+ keys_compose_cyr_j[],
+ keys_compose_cyr_e[],
+ keys_compose_cyr_u[],
+ keys_compose_cyr_l[],
+ keys_compose_cyr_n[],
+ keys_compose_cyr_tse[],
+ keys_compose_cyr_che[],
+ keys_compose_cyr_g[],
+ keys_compose_cyr_k[];
static struct layout layouts[NumLayouts] = {
[Full] = {keys_full, 0, "latin"}, //third parameter is the keymap name
@@ -110,6 +130,16 @@ static struct layout layouts[NumLayouts] = {
[ComposeB] = {keys_compose_b, 0, "latin"},
[ComposeN] = {keys_compose_n, 0, "latin"},
[ComposeM] = {keys_compose_m, 0, "latin"},
+ [ComposeCyrI] = {keys_compose_cyr_i, 0, "cyrillic"},
+ [ComposeCyrJ] = {keys_compose_cyr_j, 0, "cyrillic"},
+ [ComposeCyrE] = {keys_compose_cyr_e, 0, "cyrillic"},
+ [ComposeCyrU] = {keys_compose_cyr_u, 0, "cyrillic"},
+ [ComposeCyrL] = {keys_compose_cyr_l, 0, "cyrillic"},
+ [ComposeCyrN] = {keys_compose_cyr_n, 0, "cyrillic"},
+ [ComposeCyrTse] = {keys_compose_cyr_tse, 0, "cyrillic"},
+ [ComposeCyrChe] = {keys_compose_cyr_che, 0, "cyrillic"},
+ [ComposeCyrG] = {keys_compose_cyr_g, 0, "cyrillic"},
+ [ComposeCyrK] = {keys_compose_cyr_k, 0, "cyrillic"},
};
const enum layout_names DefaultLayout = Full;
@@ -363,17 +393,17 @@ static struct key keys_cyrillic[] = {
{"9", "(", 1.0, Code, KEY_9},
{"0", ")", 1.0, Code, KEY_0},
{"ю", "Ю", 1.0, Code, KEY_DOT},
- {"э", "Э", 1.0, Code, KEY_APOSTROPHE},
- {"ё", "Ё", 1.0, Code, KEY_GRAVE},
+ {"э", "Э", 1.0, Code, KEY_APOSTROPHE, &layouts[ComposeCyrE]},
+ {"ё", "Ё", 1.0, Code, KEY_GRAVE, &layouts[ComposeCyrE]},
{"", "", 0.0, EndRow},
- {"й", "Й", 1.0, Code, KEY_Q},
- {"ц", "Ц", 1.0, Code, KEY_W},
+ {"й", "Й", 1.0, Code, KEY_Q, &layouts[ComposeCyrJ]},
+ {"ц", "Ц", 1.0, Code, KEY_W, &layouts[ComposeCyrTse]},
{"у", "У", 1.0, Code, KEY_E},
- {"к", "К", 1.0, Code, KEY_R},
- {"е", "Е", 1.0, Code, KEY_T},
+ {"к", "К", 1.0, Code, KEY_R, &layouts[ComposeCyrK]},
+ {"е", "Е", 1.0, Code, KEY_T, &layouts[ComposeCyrE]},
{"н", "Н", 1.0, Code, KEY_Y},
- {"г", "Г", 1.0, Code, KEY_U},
+ {"г", "Г", 1.0, Code, KEY_U, &layouts[ComposeCyrG]},
{"ш", "ш", 1.0, Code, KEY_I},
{"щ", "щ", 1.0, Code, KEY_O},
{"з", "з", 1.0, Code, KEY_P},
@@ -382,23 +412,23 @@ static struct key keys_cyrillic[] = {
{"", "", 0.0, EndRow},
{"ф", "Ф", 1.0, Code, KEY_A},
- {"ы", "Ы", 1.0, Code, KEY_S},
+ {"ы", "Ы", 1.0, Code, KEY_S, &layouts[ComposeCyrI]},
{"в", "В", 1.0, Code, KEY_D},
{"а", "А", 1.0, Code, KEY_F},
{"п", "П", 1.0, Code, KEY_G},
{"р", "Р", 1.0, Code, KEY_H},
{"о", "О", 1.0, Code, KEY_J},
- {"л", "Л", 1.0, Code, KEY_K},
+ {"л", "Л", 1.0, Code, KEY_K, &layouts[ComposeCyrL]},
{"д", "Д", 1.0, Code, KEY_L},
{"ж", "Ж", 1.0, Code, KEY_SEMICOLON},
{"", "", 0.0, EndRow},
{"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
{"я", "Я", 1.0, Code, KEY_Z},
- {"ч", "Ч", 1.0, Code, KEY_X},
+ {"ч", "Ч", 1.0, Code, KEY_X, &layouts[ComposeCyrChe]},
{"c", "С", 1.0, Code, KEY_C},
{"м", "М", 1.0, Code, KEY_V},
- {"и", "И", 1.0, Code, KEY_B},
+ {"и", "И", 1.0, Code, KEY_B, &layouts[ComposeCyrI]},
{"т", "Т", 1.0, Code, KEY_N},
{"ь", "Ь", 1.0, Code, KEY_M},
{"б", "Б", 1.0, Code, KEY_COMMA},
@@ -407,7 +437,7 @@ static struct key keys_cyrillic[] = {
{"", "", 0.0, EndRow},
{"Abc", "Abc", 1.0, Layout, 0, &layouts[(DefaultLayout == Cyrillic) ? Full : DefaultLayout] , .scheme=1},
- {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {"Cmp", "Cmp", 1.0, Compose, .scheme=1},
{",", "'", 1.0, Code, KEY_EQUAL},
{"", "", 4.0, Code, KEY_SPACE},
{".", "?", 1.0, Code, KEY_SLASH},
@@ -1021,3 +1051,187 @@ static struct key keys_compose_m[] = {
{"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
{"", "", 0.0, Last},
};
+
+static struct key keys_compose_cyr_i[] = {
+ {"і", "І", 1.0, Copy, 0x0456, 0, 0x0406},
+ {"ї", "Ї", 1.0, Copy, 0x0457, 0, 0x0407},
+ {"", "", 8.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_j[] = {
+ {"ј", "Ј", 1.0, Copy, 0x0458, 0, 0x0408},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_e[] = {
+ {"є", "Є", 1.0, Copy, 0x0454, 0, 0x0404},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_u[] = {
+ {"ў", "Ў", 1.0, Copy, 0x045E, 0, 0x040E},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+
+static struct key keys_compose_cyr_l[] = {
+ {"љ", "Љ", 1.0, Copy, 0x0459, 0, 0x0409},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_n[] = {
+ {"њ", "Њ", 1.0, Copy, 0x045A, 0, 0x040A},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_che[] = {
+ {"ћ", "Ћ", 1.0, Copy, 0x045B, 0, 0x040B},
+ {"ђ", "Ђ", 1.0, Copy, 0x0452, 0, 0x0402},
+ {"", "", 8.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_tse[] = {
+ {"џ", "Џ", 1.0, Copy, 0x045F, 0, 0x040F},
+ {"ѕ", "Ѕ", 1.0, Copy, 0x0455, 0, 0x0405},
+ {"", "", 8.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_g[] = {
+ {"ѓ", "Ѓ", 1.0, Copy, 0x0453, 0, 0x0403},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};
+
+static struct key keys_compose_cyr_k[] = {
+ {"ќ", "Ќ", 1.0, Copy, 0x0453, 0, 0x040C},
+ {"", "", 9.0, Pad },
+ {"", "", 0.0, EndRow},
+ {"", "", 0.0, EndRow},
+ {"⇧", "⇧", 1.5, Mod, Shift, .scheme=1},
+ {"", "", 7, Pad},
+ {"⌫", "⌫", 1.5, Code, KEY_BACKSPACE, .scheme=1},
+ {"", "", 0.0, EndRow},
+ {"Abc", "Abc", 1.0, Layout, 0, &layouts[Cyrillic], .scheme=1},
+ {"Ctr", "Ctr", 1.0, Mod, Ctrl, .scheme=1},
+ {",", "'", 1.0, Code, KEY_EQUAL},
+ {"", "", 4.0, Code, KEY_SPACE},
+ {".", "?", 1.0, Code, KEY_SLASH},
+ {"Enter", "Enter", 2.0, Code, KEY_ENTER, .scheme=1},
+ {"", "", 0.0, Last},
+};