From 37122c2885213ffb6247fdc307a36ddf51e42681 Mon Sep 17 00:00:00 2001 From: Ivan Mahonin Date: Sep 09 2023 14:39:19 +0000 Subject: update layouts --- diff --git a/graph.c b/graph.c index d848cca..0d4ba39 100644 --- a/graph.c +++ b/graph.c @@ -10,15 +10,18 @@ int graphInit(Graph *g, App *app) { g->app = app; enum { - F = 65535u, // full - H = 32768u, // half - Q = 16384u }; // quart + F = 0xffffu, // full + B = 0x9000u, // bright + D = 0x7000u, // dark + Q = 0x4000u }; // quart static const XRenderColor renderColors[GC_COUNT] = { { 0, 0, Q, F }, // window - { 0, 0, H, F }, // inactive button + { 0, 0, D, F }, // inactive button + { 0, 0, B, F }, // highlighted button { 0, 0, F, F }, // active button - { H, 0, F, F }, // active button 2 + { B, 0, F, F }, // active button 2 { F, F, 0, F }, // inactive text + { F, F, 0, F }, // highlighted text { F, F, 0, F }, // active text { F, F, 0, F } }; // active text 2 @@ -95,9 +98,10 @@ void graphDrawBackgound(Graph *g, int x, int y, int w, int h) { } -void graphDrawButton(Graph *g, int x, int y, int w, int h, int active) { +void graphDrawButton(Graph *g, int x, int y, int w, int h, int active, int highlight) { GraphStyle s = active == 1 ? GC_BUTTON_ACTIVE : active == 2 ? GC_BUTTON_ACTIVE2 + : highlight ? GC_BUTTON_HIGHTLIGHT : GC_BUTTON_INACTIVE; XftDrawRect(g->draw, &g->colors[s], x, y, w, h); } @@ -135,10 +139,11 @@ void textLayoutDeinit(TextLayout *tl) { CLEARFROM(tl, g); } -void textLayoutDraw(TextLayout *tl, int x, int y, int w, int h, int active) { +void textLayoutDraw(TextLayout *tl, int x, int y, int w, int h, int active, int highlight) { if (!tl->len) return; GraphStyle s = active == 1 ? GC_TEXT_ACTIVE : active == 2 ? GC_TEXT_ACTIVE2 + : highlight ? GC_TEXT_HIGHTLIGHT : GC_TEXT_INACTIVE; // find font size diff --git a/graph.h b/graph.h index e5f6202..6a93edf 100644 --- a/graph.h +++ b/graph.h @@ -11,8 +11,10 @@ typedef enum { GC_WINDOW, GC_BUTTON_INACTIVE, + GC_BUTTON_HIGHTLIGHT, GC_BUTTON_ACTIVE, GC_BUTTON_ACTIVE2, + GC_TEXT_HIGHTLIGHT, GC_TEXT_INACTIVE, GC_TEXT_ACTIVE, GC_TEXT_ACTIVE2 } GraphStyle; @@ -48,11 +50,11 @@ int graphInit(Graph *g, App *app); void graphDeinit(Graph *g); void graphResize(Graph *g); void graphDrawBackgound(Graph *g, int x, int y, int w, int h); -void graphDrawButton(Graph *g, int x, int y, int w, int h, int active); +void graphDrawButton(Graph *g, int x, int y, int w, int h, int active, int highlight); void textLayoutInit(TextLayout *tl, Graph *g, const char *text); void textLayoutDeinit(TextLayout *tl); -void textLayoutDraw(TextLayout *tl, int x, int y, int w, int h, int active); +void textLayoutDraw(TextLayout *tl, int x, int y, int w, int h, int active, int highlight); #endif diff --git a/keyboard.c b/keyboard.c index 181acf6..21b945d 100644 --- a/keyboard.c +++ b/keyboard.c @@ -55,7 +55,8 @@ void keyDraw(Key *k, int cx, int cy, int cw, int ch) { int w = k->w - 2*KEY_BORDER; int h = k->h - 2*KEY_BORDER; - graphDrawButton(&k->l->kbd->app->graph, k->x + KEY_BORDER, k->y + KEY_BORDER, w, h, active); + int highlight = !!(k->flags & KF_HIGHLIGHT); + graphDrawButton(&k->l->kbd->app->graph, k->x + KEY_BORDER, k->y + KEY_BORDER, w, h, active, highlight); TextLayout *tl = &k->tl; TextLayout *tl2 = &k->tl2; @@ -79,9 +80,9 @@ void keyDraw(Key *k, int cx, int cy, int cw, int ch) { lh2 -= h/2; } - textLayoutDraw(tl, lx, ly, lw, lh, active); + textLayoutDraw(tl, lx, ly, lw, lh, active, highlight); if (!k->isLetter) - textLayoutDraw(tl2, lx2, ly2, lw2, lh2, active); + textLayoutDraw(tl2, lx2, ly2, lw2, lh2, active, highlight); } @@ -198,7 +199,7 @@ void keyUp(Key *k, int force) { keyboardSwitchLayout(kbd, k->optValue); // on releasing a regular key release all held special keys - if (!force && !k->flags) + if (!force && !(k->flags & KF_SPECIAL)) keyboardRelaseHeld(kbd); // redraw @@ -216,6 +217,8 @@ int layoutInit(Layout *l, Keyboard *kbd) { if (!l->keysCount) return 1; + l->hidden = 0; + // fix keys coords Key *k = &l->keys[0]; int x0 = k->ox; @@ -240,12 +243,15 @@ int layoutInit(Layout *l, Keyboard *kbd) { if (y0 > k->oy) y0 = k->oy; if (x1 < k->ox + k->ow) x1 = k->ox + k->ow; if (y1 < k->oy + k->oh) y1 = k->oy + k->oh; + + if ((k->flags & KF_LAYOUT) && k->optValue == LI_REVERT) + l->hidden = 1; } // fix layout size if (!l->ow) l->ow = x1 + x0; if (!l->oh) l->oh = y1 + y0; - LOGDBG("layout: init: size x0=%d y0=%d x1=%d y1=%d w=%d h=%d", x0, y0, x1, y1, l->ow, l->oh); + LOGDBG("layout: init: size x0=%d y0=%d x1=%d y1=%d w=%d h=%d, hedden: %d", x0, y0, x1, y1, l->ow, l->oh, l->hidden); // init keys for(int i = 0; i < l->keysCount; ++i) { @@ -453,19 +459,26 @@ void keyboardSwitchLayout(Keyboard *kbd, int index) { //keyboardRelaseHeld(kbd); if (index == LI_PREV) { - index = kbd->current ? prevIndex - 1: 0; - if (index < 0) index = kbd->layoutsCount - 1; + for(int i = 1; i <= kbd->layoutsCount; ++i) { + index = (prevIndex + kbd->layoutsCount - i) % kbd->layoutsCount; + if (!kbd->layouts[index].hidden) break; + } } else if (index == LI_NEXT) { - index = kbd->current ? prevIndex + 1: 0; - if (index >= kbd->layoutsCount) index = 0; + for(int i = 1; i <= kbd->layoutsCount; ++i) { + index = (prevIndex + i) % kbd->layoutsCount; + if (!kbd->layouts[index].hidden) break; + } } else if (index == LI_REVERT) { - if (!kbd->current || !kbd->current->prev) + if (!kbd->current || !kbd->current->prev) { + LOGWRN("keyboard: switch layout: cannot revert"); return; - index = kbd->current->prev - kbd->layouts; + } + Layout *l = kbd->current->prev; + while(l->hidden && l->prev) l = l->prev; + index = l - kbd->layouts; remember = 0; - return; } if (index < 0 || index >= kbd->layoutsCount) { diff --git a/keyboard.h b/keyboard.h index de508b3..8276c46 100644 --- a/keyboard.h +++ b/keyboard.h @@ -11,12 +11,17 @@ // key flags enum { - KF_HOLD = 1 << 0, // key will be hold until it will pressed again or non-hold key will pressed - KF_MOD = 1 << 1, // visible value depends on modifier state (using optValue field) - KF_LAYOUT = 1 << 2, // key to switch layout (using optValue field); - KF_MOVE = 1 << 3, // handle to move the window - KF_SIZE = 1 << 4, // key to resize the window - KF_CLOSE = 1 << 5 }; // key to close the window + KF_HIGHLIGHT = 1 << 0, // key will be hightlighted + KF_HOLD = 1 << 1, // key will be hold until it will pressed again or non-hold key will pressed + KF_MOD = 1 << 2, // visible value depends on modifier state (using optValue field) + KF_LAYOUT = 1 << 3, // key to switch layout (using optValue field); + KF_MOVE = 1 << 4, // handle to move the window + KF_SIZE = 1 << 5, // key to resize the window + KF_CLOSE = 1 << 6, // key to close the window + + KF_SPECIAL = KF_HOLD | KF_MOD | KF_LAYOUT | KF_MOVE | KF_SIZE | KF_CLOSE, +}; + // special layout indices enum { @@ -70,6 +75,7 @@ struct Layout { // these fields will be set while initialization Keyboard *kbd; + int hidden; // dynamic fields int w, h; diff --git a/layout.am.inc.c b/layout.am.inc.c index 0d6babe..2833bfd 100644 --- a/layout.am.inc.c +++ b/layout.am.inc.c @@ -7,8 +7,19 @@ Key keysAm[] = { HEADER(FW) - { X0, Y1, W2, H, XK_Armenian_exclam, 0, "՝", "՜" }, - { N, 0, W, 0, XK_Armenian_fe, 0, "ֆ", "Ֆ" }, + { X0, Y1, W, H, XK_Armenian_exclam, 0, "՝", "՜" }, + { N, 0, 0, 0, XK_1, XK_exclam }, + { N, 0, 0, 0, XK_2, XK_at }, + { N, 0, 0, 0, XK_3, XK_numbersign }, + { N, 0, 0, 0, XK_4, XK_dollar }, + { N, 0, 0, 0, XK_5, XK_percent }, + { N, 0, 0, 0, XK_6, XK_asciicircum }, + { N, 0, 0, 0, XK_7, XK_ampersand }, + { N, 0, 0, 0, XK_8, XK_asterisk }, + { N, 0, 0, 0, XK_9, XK_parenleft }, + { N, 0, 0, 0, XK_0, XK_parenright }, + { N, 0, 0, 0, XK_BackSpace, 0, "⌫" }, + { X0, N, 0, 0, XK_Armenian_fe, 0, "ֆ", "Ֆ" }, { N, 0, 0, 0, XK_Armenian_dza, 0, "ձ", "Ձ" }, { N, 0, 0, 0, XK_Armenian_hyphen, 0, "֊", "—" }, { N, 0, 0, 0, XK_comma }, @@ -20,9 +31,7 @@ Key keysAm[] = { { N, 0, 0, 0, XK_Armenian_o, 0, "օ", "Օ" }, { N, 0, 0, 0, XK_Armenian_e, 0, "է", "Է" }, { N, 0, 0, 0, XK_Armenian_ghat, 0, "ղ", "Ղ" }, - { N, 0, W2, 0, XK_BackSpace, 0, "⌫" }, - { X0, N, W2, 0, XK_Tab, 0, "⇥" }, - { N, 0, W, 0, XK_Armenian_tche, 0, "ճ", "Ճ" }, + { X0, N, 0, 0, XK_Armenian_tche, 0, "ճ", "Ճ" }, { N, 0, 0, 0, XK_Armenian_pyur, 0, "փ", "Փ" }, { N, 0, 0, 0, XK_Armenian_ben, 0, "բ", "Բ" }, { N, 0, 0, 0, XK_Armenian_se, 0, "ս", "Ս" }, @@ -34,9 +43,7 @@ Key keysAm[] = { { N, 0, 0, 0, XK_Armenian_to, 0, "թ", "Թ" }, { N, 0, 0, 0, XK_Armenian_tsa, 0, "ծ", "Ծ" }, { N, 0, 0, 0, XK_Armenian_tso, 0, "ց", "Ց" }, - { N, 0, W2, H2, XK_Return, 0, "Return" }, - { X0, Y3, W2, H, XK_Caps_Lock, 0, "Caps Lock", "", KF_MOD, IM_CAPSLOCK_BIT }, - { N, 0, W, 0, XK_Armenian_je, 0, "ջ", "Ջ" }, + { X0, N, 0, 0, XK_Armenian_je, 0, "ջ", "Ջ" }, { N, 0, 0, 0, XK_Armenian_vev, 0, "վ", "Վ" }, { N, 0, 0, 0, XK_Armenian_gim, 0, "գ", "Գ" }, { N, 0, 0, 0, XK_Armenian_yech, 0, "ե", "Ե" }, @@ -47,9 +54,9 @@ Key keysAm[] = { { N, 0, 0, 0, XK_Armenian_ho, 0, "հ", "Հ" }, { N, 0, 0, 0, XK_Armenian_pe, 0, "պ", "Պ" }, { N, 0, 0, 0, XK_Armenian_re, 0, "ր", "Ր" }, - { N, 0, 0, 0, XK_backslash, XK_slash, "\\", "/" }, - { X0, N, W4, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD }, - { N, 0, W, 0, XK_Armenian_zhe, 0, "ժ", "Ժ" }, + { N, 0, 0, 0, XK_minus, XK_underscore }, + { X0, N, 0, 0, XK_Tab, 0, "⇥", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Armenian_zhe, 0, "ժ", "Ժ" }, { N, 0, 0, 0, XK_Armenian_da, 0, "դ", "Դ" }, { N, 0, 0, 0, XK_Armenian_cha, 0, "չ", "Չ" }, { N, 0, 0, 0, XK_Armenian_hi, 0, "յ", "Յ" }, @@ -59,14 +66,16 @@ Key keysAm[] = { { N, 0, 0, 0, XK_Armenian_khe, 0, "խ", "Խ" }, { N, 0, 0, 0, XK_Armenian_sha, 0, "շ", "Շ" }, { N, 0, 0, 0, XK_Armenian_ra, 0, "ռ", "Ռ" }, - { N, 0, W4, 0, XK_Shift_R, 0, "Shift", "", KF_HOLD }, - { X0, N, W2, 0, XK_Control_L, 0, "Ctrl", "", KF_HOLD }, - { N, 0, W2, 0, XK_Alt_L, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, - { N, 0, W5, 0, XK_space }, - { N, 0, W2, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, - { N, 0, W2, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD }, + { N, 0, 0, 0, XK_equal, XK_plus }, + { X0, N, W+S+W, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W, 0, 0, 0, "Fn", "", KF_LAYOUT, 1 }, + { N, 0, 0, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, + { N, 0, 0, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, + { N, 0, W+S+W, 0, XK_space }, + { N, 0, W, 0, XK_backslash, XK_slash, "\\", "/" }, + { N, 0, 0, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT} , + { N, 0, W+S+W, 0, XK_Return, 0, "Enter", "", KF_HIGHLIGHT }, FOOTER(FW) }; diff --git a/layout.defs.h b/layout.defs.h index 46c409f..a3c9ac5 100644 --- a/layout.defs.h +++ b/layout.defs.h @@ -15,7 +15,7 @@ #define W2 50 // more width #define W3 80 // more #define W4 (W2+W+S) // and more -#define W5 (12*W+11*S-4*W2-4*S) // space bar width +#define W5 (12*W+11*S-7*W2-7*S) // space bar width #define H 40 // height #define H2 (H*2+S) // double height diff --git a/layout.en.full.inc.c b/layout.en.full.inc.c index d62cebb..3d46911 100644 --- a/layout.en.full.inc.c +++ b/layout.en.full.inc.c @@ -14,7 +14,7 @@ Key keysEnFull[] = { HEADER(LEF_FW) - { X0, Y1, W, H, XK_Escape, 0, "Esc" }, + { X0, Y1, W, H, XK_Escape, 0, "Esc", "", KF_HIGHLIGHT }, { LEF_N, 0, 0, 0, XK_F1, 0, "F1" }, { N, 0, 0, 0, XK_F2, 0, "F2" }, { N, 0, 0, 0, XK_F3, 0, "F3" }, @@ -43,7 +43,7 @@ Key keysEnFull[] = { { N, 0, 0, 0, XK_equal, XK_plus }, { N, 0, W2, 0, XK_BackSpace, 0, "⌫" }, - { X0, N, W2, 0, XK_Tab, 0, "⇥" }, + { X0, N, W2, 0, XK_Tab, 0, "⇥", "", KF_HIGHLIGHT }, { N, 0, W, 0, XK_q }, { N, 0, 0, 0, XK_w }, { N, 0, 0, 0, XK_e }, @@ -56,9 +56,9 @@ Key keysEnFull[] = { { N, 0, 0, 0, XK_p }, { N, 0, 0, 0, XK_bracketleft, XK_braceleft }, { N, 0, 0, 0, XK_bracketright, XK_braceright }, - { N, 0, W2, H2, XK_Return, 0, "Enter" }, + { N, 0, W2, H2, XK_Return, 0, "Enter", "", KF_HIGHLIGHT }, - { X0, Y4+S2-S, W2, H, XK_Caps_Lock, 0, "Caps Lock", "", KF_MOD, IM_CAPSLOCK_BIT }, + { X0, Y4+S2-S, W2, H, XK_Caps_Lock, 0, "Caps Lock", "", KF_MOD | KF_HIGHLIGHT, IM_CAPSLOCK_BIT }, { N, 0, W, 0, XK_a }, { N, 0, 0, 0, XK_s }, { N, 0, 0, 0, XK_d }, @@ -72,7 +72,7 @@ Key keysEnFull[] = { { N, 0, 0, 0, XK_apostrophe, XK_quotedbl }, { N, 0, 0, 0, XK_backslash, XK_bar }, - { X0, N, W4, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD }, + { X0, N, W4, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, { N, 0, W, 0, XK_z }, { N, 0, 0, 0, XK_x }, { N, 0, 0, 0, XK_c }, @@ -83,15 +83,18 @@ Key keysEnFull[] = { { N, 0, 0, 0, XK_comma, XK_less }, { N, 0, 0, 0, XK_period, XK_greater }, { N, 0, 0, 0, XK_slash, XK_question }, - { N, 0, W4, 0, XK_Shift_R, 0, "Shift", "", KF_HOLD }, + { N, 0, W4, 0, XK_Shift_R, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, - { X0, N, W2, 0, XK_Control_L, 0, "Ctrl", "", KF_HOLD }, - { N, 0, W2, 0, XK_Alt_L, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, + { X0, N, W2, 0, XK_Control_L, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W2, 0, XK_Super_L, 0, "Super", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W2, 0, XK_Alt_L, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W2, 0, 0, 0, "<--", "", KF_LAYOUT, LI_REVERT }, + { N, 0, W2, 0, 0, 0, "Fn", "", KF_LAYOUT, 1 }, { N, 0, W5, 0, XK_space }, - { N, 0, W2, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, - { N, 0, W2, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD }, + { N, 0, W2, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W2, 0, XK_Super_R, 0, "Super", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W2, 0, XK_Menu, 0, "Menu", "", KF_HIGHLIGHT }, + { N, 0, W2, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT }, // col 2 diff --git a/layout.en.inc.c b/layout.en.inc.c index 8d2a1b9..bcc09f4 100644 --- a/layout.en.inc.c +++ b/layout.en.inc.c @@ -7,8 +7,8 @@ Key keysEn[] = { HEADER(FW) - { X0, Y1, W2, H, XK_grave, XK_asciitilde }, - { N, 0, W, 0, XK_1, XK_exclam }, + { X0, Y1, W, H, XK_grave, XK_asciitilde }, + { N, 0, 0, 0, XK_1, XK_exclam }, { N, 0, 0, 0, XK_2, XK_at }, { N, 0, 0, 0, XK_3, XK_numbersign }, { N, 0, 0, 0, XK_4, XK_dollar }, @@ -18,11 +18,8 @@ Key keysEn[] = { { N, 0, 0, 0, XK_8, XK_asterisk }, { N, 0, 0, 0, XK_9, XK_parenleft }, { N, 0, 0, 0, XK_0, XK_parenright }, - { N, 0, 0, 0, XK_minus, XK_underscore }, - { N, 0, 0, 0, XK_equal, XK_plus }, - { N, 0, W2, 0, XK_BackSpace, 0, "⌫" }, - { X0, N, W2, 0, XK_Tab, 0, "⇥" }, - { N, 0, W, 0, XK_q }, + { N, 0, 0, 0, XK_BackSpace, 0, "⌫" }, + { X0, N, 0, 0, XK_q }, { N, 0, 0, 0, XK_w }, { N, 0, 0, 0, XK_e }, { N, 0, 0, 0, XK_r }, @@ -34,9 +31,7 @@ Key keysEn[] = { { N, 0, 0, 0, XK_p }, { N, 0, 0, 0, XK_bracketleft, XK_braceleft }, { N, 0, 0, 0, XK_bracketright, XK_braceright }, - { N, 0, W2, H2, XK_Return, 0, "Enter" }, - { X0, Y3, W2, H, XK_Caps_Lock, 0, "Caps Lock", "", KF_MOD, IM_CAPSLOCK_BIT }, - { N, 0, W, 0, XK_a }, + { X0, N, 0, 0, XK_a }, { N, 0, 0, 0, XK_s }, { N, 0, 0, 0, XK_d }, { N, 0, 0, 0, XK_f }, @@ -47,9 +42,9 @@ Key keysEn[] = { { N, 0, 0, 0, XK_l }, { N, 0, 0, 0, XK_semicolon, XK_colon }, { N, 0, 0, 0, XK_apostrophe, XK_quotedbl }, - { N, 0, 0, 0, XK_backslash, XK_bar }, - { X0, N, W4, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD }, - { N, 0, W, 0, XK_z }, + { N, 0, 0, 0, XK_minus, XK_underscore }, + { X0, N, 0, 0, XK_Tab, 0, "⇥", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_z }, { N, 0, 0, 0, XK_x }, { N, 0, 0, 0, XK_c }, { N, 0, 0, 0, XK_v }, @@ -59,14 +54,16 @@ Key keysEn[] = { { N, 0, 0, 0, XK_comma, XK_less }, { N, 0, 0, 0, XK_period, XK_greater }, { N, 0, 0, 0, XK_slash, XK_question }, - { N, 0, W4, 0, XK_Shift_R, 0, "Shift", "", KF_HOLD }, - { X0, N, W2, 0, XK_Control_L, 0, "Ctrl", "", KF_HOLD }, - { N, 0, W2, 0, XK_Alt_L, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, - { N, 0, W5, 0, XK_space }, - { N, 0, W2, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, - { N, 0, W2, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD }, + { N, 0, 0, 0, XK_equal, XK_plus }, + { X0, N, W+S+W, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W, 0, 0, 0, "Fn", "", KF_LAYOUT, 1 }, + { N, 0, 0, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, + { N, 0, 0, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, + { N, 0, W+S+W, 0, XK_space }, + { N, 0, W, 0, XK_backslash, XK_bar }, + { N, 0, 0, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W+S+W, 0, XK_Return, 0, "Enter", "", KF_HIGHLIGHT }, FOOTER(FW) }; diff --git a/layout.fn.inc.c b/layout.fn.inc.c new file mode 100644 index 0000000..698aaac --- /dev/null +++ b/layout.fn.inc.c @@ -0,0 +1,92 @@ +#ifndef LAYOUT_FN_INC_C +#define LAYOUT_FN_INC_C + + +#include "layout.defs.h" + + +Key keysFn[] = { + HEADER(FW) + + { X0, Y1, W, H, XK_F1, 0, "F1" }, + { N, 0, 0, 0, XK_F2, 0, "F2" }, + { N, 0, 0, 0, XK_F3, 0, "F3" }, + { N, 0, 0, 0, XK_F4, 0, "F4" }, + { N, 0, 0, 0, XK_F5, 0, "F5" }, + { N, 0, 0, 0, XK_F6, 0, "F6" }, + { N, 0, 0, 0, XK_F7, 0, "F7" }, + { N, 0, 0, 0, XK_F8, 0, "F8" }, + { N, 0, 0, 0, XK_F9, 0, "F9" }, + { N, 0, 0, 0, XK_F10, 0, "F10" }, + { N, 0, 0, 0, XK_F11, 0, "F11" }, + { N, 0, 0, 0, XK_F12, 0, "F12" }, + + { X0, N, 0, 0, XK_Escape, 0, "Esc", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_grave, XK_asciitilde }, + { N, 0, 0, 0, XK_exclam, XK_at }, + { N, 0, 0, 0, XK_numbersign, XK_dollar }, + { N, 0, 0, 0, XK_percent, XK_asciicircum }, + { N, 0, 0, 0, XK_ampersand, XK_asterisk }, + { N, 0, 0, 0, XK_BackSpace, 0, "⌫" }, + { N, 0, 0, 0, XK_Print, 0, "PrtScr", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Pause, 0, "Pause", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Num_Lock, 0, "NumLk", "", KF_MOD | KF_HIGHLIGHT, IM_NUMLOCK_BIT }, + { N, 0, 0, 0, XK_Caps_Lock, 0, "Caps Lock", "", KF_MOD | KF_HIGHLIGHT, IM_CAPSLOCK_BIT }, + { N, 0, 0, 0, XK_Scroll_Lock, 0, "ScrLk", "", KF_MOD | KF_HIGHLIGHT, IM_SCRLOCK_BIT }, + + { X0, N, 0, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_equal, XK_underscore }, + { N, 0, 0, 0, XK_parenleft, XK_backslash }, + { N, 0, 0, 0, XK_parenright, XK_bar }, + { N, 0, 0, 0, XK_Shift_R, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Insert, 0, "Ins", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Home, 0, "Home", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Page_Up, 0, "PgUp", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_KP_Home, XK_KP_7, "Home", "7" }, + { N, 0, 0, 0, XK_KP_Up, XK_KP_8, "↑", "8" }, + { N, 0, 0, 0, XK_KP_Page_Down, XK_KP_9, "PgDn", "9" }, + { N, 0, 0, 0, XK_KP_Divide, 0, "/" }, + + { X0, N, 0, 0, XK_Control_L, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_semicolon, XK_colon }, + { N, 0, 0, 0, XK_bracketleft, XK_braceleft }, + { N, 0, 0, 0, XK_bracketright, XK_braceright }, + { N, 0, 0, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Delete, 0, "Del", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_End, 0, "End", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Page_Down, 0, "PgDn", "", KF_HIGHLIGHT }, + { N, 0, 0, H, XK_KP_Left, XK_KP_4, "←", "4" }, + { N, 0, 0, 0, 0, XK_KP_5, "", "5" }, + { N, 0, 0, 0, XK_KP_Right, XK_KP_6, "→", "6" }, + { N, 0, 0, 0, XK_KP_Multiply, 0, "*" }, + + { X0, N, 0, 0, XK_Alt_L, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_apostrophe, XK_quotedbl }, + { N, 0, 0, 0, XK_slash, XK_question }, + { N, 0, 0, 0, XK_Menu, 0, "Menu", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_comma, XK_less }, + { N, 0, 0, 0, XK_Up, 0, "↑" }, + { N, 0, 0, 0, XK_period, XK_greater }, + { N, 0, 0, 0, XK_KP_End, XK_KP_1, "End", "1" }, + { N, 0, 0, 0, XK_KP_Down, XK_KP_2, "↓", "2" }, + { N, 0, 0, 0, XK_KP_Page_Down, XK_KP_3, "PgDn", "2" }, + { N, 0, 0, 0, XK_KP_Subtract, 0, "-" }, + + { X0, N, 0, 0, XK_Super_L, 0, "Super", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, 0, 0, "<--", "", KF_LAYOUT, LI_REVERT }, + { N, 0, 0, 0, 0, 0, "Full", "", KF_LAYOUT, 2 }, + { N, 0, 0, 0, XK_Return, 0, "Enter", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Super_R, 0, "Super", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Left, 0, "←" }, + { N, 0, 0, 0, XK_Down, 0, "↓" }, + { N, 0, 0, 0, XK_Right, 0, "→" }, + { N, 0, 0, 0, XK_KP_Insert, XK_KP_0, "Ins", "0" }, + { N, 0, 0, 0, XK_KP_Delete, XK_KP_Decimal, "Del", "." }, + { N, 0, 0, 0, XK_KP_Enter, 0, "Enter" }, + { N, 0, 0, 0, XK_KP_Add, 0, "+" }, + + FOOTER(FW) +}; + +#endif diff --git a/layout.ru.inc.c b/layout.ru.inc.c index f5c6319..1e3deac 100644 --- a/layout.ru.inc.c +++ b/layout.ru.inc.c @@ -6,8 +6,8 @@ Key keysRu[] = { HEADER(FW) - { X0, Y1, W2, H, XK_Cyrillic_io }, - { N, 0, W, 0, XK_1, XK_exclam }, + { X0, Y1, W, H, XK_Cyrillic_io }, + { N, 0, 0, 0, XK_1, XK_exclam }, { N, 0, 0, 0, XK_2, XK_quotedbl }, { N, 0, 0, 0, XK_3, XK_numerosign }, { N, 0, 0, 0, XK_4, XK_semicolon }, @@ -17,11 +17,8 @@ Key keysRu[] = { { N, 0, 0, 0, XK_8, XK_asterisk }, { N, 0, 0, 0, XK_9, XK_parenleft }, { N, 0, 0, 0, XK_0, XK_parenright }, - { N, 0, 0, 0, XK_minus, XK_underscore }, - { N, 0, 0, 0, XK_equal, XK_plus }, - { N, 0, W2, 0, XK_BackSpace, 0, "⌫" }, - { X0, N, W2, 0, XK_Tab, 0, "⇥" }, - { N, 0, W, 0, XK_Cyrillic_shorti }, + { N, 0, 0, 0, XK_BackSpace, 0, "⌫" }, + { X0, N, 0, 0, XK_Cyrillic_shorti }, { N, 0, 0, 0, XK_Cyrillic_tse }, { N, 0, 0, 0, XK_Cyrillic_u }, { N, 0, 0, 0, XK_Cyrillic_ka }, @@ -33,9 +30,7 @@ Key keysRu[] = { { N, 0, 0, 0, XK_Cyrillic_ze }, { N, 0, 0, 0, XK_Cyrillic_ha }, { N, 0, 0, 0, XK_Cyrillic_hardsign }, - { N, 0, W2, H2, XK_Return, 0, "Enter" }, - { X0, Y3, W2, H, XK_Caps_Lock, 0, "Caps Lock", "", KF_MOD, IM_CAPSLOCK_BIT }, - { N, 0, W, 0, XK_Cyrillic_ef }, + { X0, N, 0, 0, XK_Cyrillic_ef }, { N, 0, 0, 0, XK_Cyrillic_yeru }, { N, 0, 0, 0, XK_Cyrillic_ve }, { N, 0, 0, 0, XK_Cyrillic_a }, @@ -46,9 +41,9 @@ Key keysRu[] = { { N, 0, 0, 0, XK_Cyrillic_de }, { N, 0, 0, 0, XK_Cyrillic_zhe }, { N, 0, 0, 0, XK_Cyrillic_e }, - { N, 0, 0, 0, XK_backslash, XK_slash }, - { X0, N, W4, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD }, - { N, 0, W, 0, XK_Cyrillic_ya }, + { N, 0, 0, 0, XK_minus, XK_underscore }, + { X0, N, 0, 0, XK_Tab, 0, "⇥", "", KF_HIGHLIGHT }, + { N, 0, 0, 0, XK_Cyrillic_ya }, { N, 0, 0, 0, XK_Cyrillic_che }, { N, 0, 0, 0, XK_Cyrillic_es }, { N, 0, 0, 0, XK_Cyrillic_em }, @@ -58,14 +53,16 @@ Key keysRu[] = { { N, 0, 0, 0, XK_Cyrillic_be }, { N, 0, 0, 0, XK_Cyrillic_yu }, { N, 0, 0, 0, XK_comma, XK_period }, - { N, 0, W4, 0, XK_Shift_R, 0, "Shift", "", KF_HOLD }, - { X0, N, W2, 0, XK_Control_L, 0, "Ctrl", "", KF_HOLD }, - { N, 0, W2, 0, XK_Alt_L, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, - { N, 0, W5, 0, XK_space }, - { N, 0, W2, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, - { N, 0, W2, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD }, - { N, 0, W2, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD }, + { N, 0, 0, 0, XK_equal, XK_plus }, + { X0, N, W+S+W, 0, XK_Shift_L, 0, "Shift", "", KF_HOLD | KF_HIGHLIGHT }, + { N, 0, W, 0, 0, 0, "Fn", "", KF_LAYOUT, 1 }, + { N, 0, 0, 0, 0, 0, "<--", "", KF_LAYOUT, LI_PREV }, + { N, 0, 0, 0, 0, 0, "-->", "", KF_LAYOUT, LI_NEXT }, + { N, 0, W+S+W, 0, XK_space }, + { N, 0, W, 0, XK_backslash, XK_slash }, + { N, 0, 0, 0, XK_Control_R, 0, "Ctrl", "", KF_HOLD | KF_HIGHLIGHT}, + { N, 0, 0, 0, XK_Alt_R, 0, "Alt", "", KF_HOLD | KF_HIGHLIGHT}, + { N, 0, W+S+W, 0, XK_Return, 0, "Enter", "", KF_HIGHLIGHT }, FOOTER(FW) }; diff --git a/main.c b/main.c index 12e4cac..f6de611 100644 --- a/main.c +++ b/main.c @@ -8,15 +8,17 @@ #include "keyboard.c" #include "layout.en.inc.c" +#include "layout.fn.inc.c" +#include "layout.en.full.inc.c" #include "layout.am.inc.c" #include "layout.ru.inc.c" -#include "layout.en.full.inc.c" Layout layouts[] = { { keysEn, COUNTOF(keysEn) }, + { keysFn, COUNTOF(keysFn) }, + { keysEnFull, COUNTOF(keysEnFull) }, { keysAm, COUNTOF(keysAm) }, { keysRu, COUNTOF(keysRu) }, - { keysEnFull, COUNTOF(keysEnFull) }, }; App app = {