Add option for customising Shift keycap

This commit is contained in:
Johannes Marbach 2021-09-20 12:57:08 +02:00
parent e93d853f3d
commit 94e5cfa841
9 changed files with 330 additions and 240 deletions

View file

@ -16,7 +16,7 @@ Afterwards you can execute the script with `pipenv run`. Use the `-h` / `--help`
```
$ pipenv run python squeek2lvgl.py --help
usage: squeek2lvgl.py [-h] --input INPUT [--surround-space-with-arrows] [--generate-scancodes] --output OUTPUT
usage: squeek2lvgl.py [-h] --input INPUT [--shift-keycap SHIFT_KEYCAP] [--surround-space-with-arrows] [--generate-scancodes] --output OUTPUT
Convert squeekboard layouts to LVGL-compatible C code.
@ -24,6 +24,8 @@ optional arguments:
-h, --help show this help message and exit
--input INPUT squeekboard layout to use as input for generation. Has to be a YAML file path relative to data/keyboards. Can be specified
multiple times.
--shift-keycap SHIFT_KEYCAP
key caption for the Shift key. Defaults to "Shift".
--surround-space-with-arrows
insert left / right arrow before / after space key
--generate-scancodes also generate scancode tables (only works for US layout currently)

View file

@ -0,0 +1,219 @@
/**
* Auto-generated with squeek2lvgl
**/
#include "sq2lv_layouts.h"
#define SQ2LV_SYMBOL_SHIFT "ABC"
/**
* Layout: German - generated from de
**/
static const char * const name_de = "German";
static const char * const short_name_de = "de";
/* Layer: Lowercase letters - generated from base */
static const int num_keys_lower_de = 36;
static const char * const keycaps_lower_de[] = { \
"q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "\n", \
"a", "s", "d", "f", "g", "h", "j", "k", "l", "\n", \
SQ2LV_SYMBOL_SHIFT, "y", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
"123", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ",", ".", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_lower_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, \
SQ2LV_CTRL_MOD_INACTIVE | 3, 2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_INACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_lower_de = 0;
static const int modifier_idxs_lower_de[] = { \
\
};
static const int num_switchers_lower_de = 3;
static const int switcher_idxs_lower_de[] = { \
19, 28, 29 \
};
static const int switcher_dests_lower_de[] = { \
1, 2, 3 \
};
/* Layer: Uppercase letters - generated from upper */
static const int num_keys_upper_de = 36;
static const char * const keycaps_upper_de[] = { \
"Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", "\n", \
"A", "S", "D", "F", "G", "H", "J", "K", "L", "\n", \
SQ2LV_SYMBOL_SHIFT, "Y", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
"123", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "!", "?", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_upper_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, \
SQ2LV_CTRL_MOD_ACTIVE | 3, 2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_INACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_upper_de = 0;
static const int modifier_idxs_upper_de[] = { \
\
};
static const int num_switchers_upper_de = 3;
static const int switcher_idxs_upper_de[] = { \
19, 28, 29 \
};
static const int switcher_dests_upper_de[] = { \
0, 2, 3 \
};
/* Layer: Numbers / symbols - generated from numbers */
static const int num_keys_numbers_de = 36;
static const char * const keycaps_numbers_de[] = { \
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\n", \
"@", "#", "", "%", "&", "-", "_", "+", "(", ")", "\n", \
";", "\"", "'", ":", "=", "<", ">", LV_SYMBOL_BACKSPACE, "\n", \
"abc", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ",", ".", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_numbers_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_INACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_numbers_de = 0;
static const int modifier_idxs_numbers_de[] = { \
\
};
static const int num_switchers_numbers_de = 2;
static const int switcher_idxs_numbers_de[] = { \
28, 29 \
};
static const int switcher_dests_numbers_de[] = { \
0, 3 \
};
/* Layer: Special characters - generated from eschars */
static const int num_keys_special_de = 37;
static const char * const keycaps_special_de[] = { \
"ä", "è", "é", "ö", "ü", "Ä", "È", "É", "Ö", "Ü", "\n", \
"à", "â", "ê", "î", "ô", "À", "Â", "È", "Î", "Ô", "\n", \
"123", "«", "»", "ç", "Ç", "æ", "œ", "ß", LV_SYMBOL_BACKSPACE, "\n", \
"abc", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "", "", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_special_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
SQ2LV_CTRL_NON_CHAR | 3, 2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_ACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_special_de = 0;
static const int modifier_idxs_special_de[] = { \
\
};
static const int num_switchers_special_de = 3;
static const int switcher_idxs_special_de[] = { \
20, 29, 30 \
};
static const int switcher_dests_special_de[] = { \
2, 0, 0 \
};
/* Layer array */
static const int num_layers_de = 4;
static const sq2lv_layer_t layers_de[] = {
{
.num_keys = num_keys_lower_de,
.keycaps = keycaps_lower_de,
.attributes = attributes_lower_de,
.num_modifiers = num_modifiers_lower_de,
.modifier_idxs = modifier_idxs_lower_de,
.num_switchers = num_switchers_lower_de,
.switcher_idxs = switcher_idxs_lower_de,
.switcher_dests = switcher_dests_lower_de
},
{
.num_keys = num_keys_upper_de,
.keycaps = keycaps_upper_de,
.attributes = attributes_upper_de,
.num_modifiers = num_modifiers_upper_de,
.modifier_idxs = modifier_idxs_upper_de,
.num_switchers = num_switchers_upper_de,
.switcher_idxs = switcher_idxs_upper_de,
.switcher_dests = switcher_dests_upper_de
},
{
.num_keys = num_keys_numbers_de,
.keycaps = keycaps_numbers_de,
.attributes = attributes_numbers_de,
.num_modifiers = num_modifiers_numbers_de,
.modifier_idxs = modifier_idxs_numbers_de,
.num_switchers = num_switchers_numbers_de,
.switcher_idxs = switcher_idxs_numbers_de,
.switcher_dests = switcher_dests_numbers_de
},
{
.num_keys = num_keys_special_de,
.keycaps = keycaps_special_de,
.attributes = attributes_special_de,
.num_modifiers = num_modifiers_special_de,
.modifier_idxs = modifier_idxs_special_de,
.num_switchers = num_switchers_special_de,
.switcher_idxs = switcher_idxs_special_de,
.switcher_dests = switcher_dests_special_de
}
};
/**
* Public interface
**/
const int sq2lv_num_layouts = 1;
const sq2lv_layout_t sq2lv_layouts[] = {
/* German */
{
.name = name_de,
.short_name = short_name_de,
.num_layers = num_layers_de,
.layers = layers_de
}
};
const char * const sq2lv_layout_names =
"German";
const char * const sq2lv_layout_short_names =
"de";

View file

@ -16,10 +16,7 @@
/* Layout IDs, values can be used as indexes into the sq2lv_layouts array */
typedef enum {
SQ2LV_LAYOUT_DE = 0,
SQ2LV_LAYOUT_ES = 1,
SQ2LV_LAYOUT_FR = 2,
SQ2LV_LAYOUT_US = 3
SQ2LV_LAYOUT_DE = 0
} sq2lv_layout_id_t;
/* Layer type */

View file

@ -4,195 +4,7 @@
#include "sq2lv_layouts.h"
/**
* Layout: German - generated from de
**/
static const char * const name_de = "German";
static const char * const short_name_de = "de";
/* Layer: Lowercase letters - generated from base */
static const int num_keys_lower_de = 36;
static const char * const keycaps_lower_de[] = { \
"q", "w", "e", "r", "t", "z", "u", "i", "o", "p", "\n", \
"a", "s", "d", "f", "g", "h", "j", "k", "l", "\n", \
"ABC", "y", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
"123", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ",", ".", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_lower_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, \
SQ2LV_CTRL_MOD_INACTIVE | 3, 2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_INACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_lower_de = 0;
static const int modifier_idxs_lower_de[] = { \
\
};
static const int num_switchers_lower_de = 3;
static const int switcher_idxs_lower_de[] = { \
19, 28, 29 \
};
static const int switcher_dests_lower_de[] = { \
1, 2, 3 \
};
/* Layer: Uppercase letters - generated from upper */
static const int num_keys_upper_de = 36;
static const char * const keycaps_upper_de[] = { \
"Q", "W", "E", "R", "T", "Z", "U", "I", "O", "P", "\n", \
"A", "S", "D", "F", "G", "H", "J", "K", "L", "\n", \
"abc", "Y", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
"123", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "!", "?", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_upper_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, \
SQ2LV_CTRL_MOD_ACTIVE | 3, 2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_INACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_upper_de = 0;
static const int modifier_idxs_upper_de[] = { \
\
};
static const int num_switchers_upper_de = 3;
static const int switcher_idxs_upper_de[] = { \
19, 28, 29 \
};
static const int switcher_dests_upper_de[] = { \
0, 2, 3 \
};
/* Layer: Numbers / symbols - generated from numbers */
static const int num_keys_numbers_de = 36;
static const char * const keycaps_numbers_de[] = { \
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "\n", \
"@", "#", "", "%", "&", "-", "_", "+", "(", ")", "\n", \
";", "\"", "'", ":", "=", "<", ">", LV_SYMBOL_BACKSPACE, "\n", \
"abc", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ",", ".", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_numbers_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_INACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_numbers_de = 0;
static const int modifier_idxs_numbers_de[] = { \
\
};
static const int num_switchers_numbers_de = 2;
static const int switcher_idxs_numbers_de[] = { \
28, 29 \
};
static const int switcher_dests_numbers_de[] = { \
0, 3 \
};
/* Layer: Special characters - generated from eschars */
static const int num_keys_special_de = 37;
static const char * const keycaps_special_de[] = { \
"ä", "è", "é", "ö", "ü", "Ä", "È", "É", "Ö", "Ü", "\n", \
"à", "â", "ê", "î", "ô", "À", "Â", "È", "Î", "Ô", "\n", \
"123", "«", "»", "ç", "Ç", "æ", "œ", "ß", LV_SYMBOL_BACKSPACE, "\n", \
"abc", "äÄ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "", "", LV_SYMBOL_OK, "" \
};
static const lv_btnmatrix_ctrl_t attributes_special_de[] = { \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, \
SQ2LV_CTRL_NON_CHAR | 3, 2, 2, 2, 2, 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3, \
SQ2LV_CTRL_NON_CHAR | 3, SQ2LV_CTRL_MOD_ACTIVE | 3, SQ2LV_CTRL_NON_CHAR | 2, 7, SQ2LV_CTRL_NON_CHAR | 2, 2, 2, SQ2LV_CTRL_NON_CHAR | 3 \
};
static const int num_modifiers_special_de = 0;
static const int modifier_idxs_special_de[] = { \
\
};
static const int num_switchers_special_de = 3;
static const int switcher_idxs_special_de[] = { \
20, 29, 30 \
};
static const int switcher_dests_special_de[] = { \
2, 0, 0 \
};
/* Layer array */
static const int num_layers_de = 4;
static const sq2lv_layer_t layers_de[] = {
{
.num_keys = num_keys_lower_de,
.keycaps = keycaps_lower_de,
.attributes = attributes_lower_de,
.num_modifiers = num_modifiers_lower_de,
.modifier_idxs = modifier_idxs_lower_de,
.num_switchers = num_switchers_lower_de,
.switcher_idxs = switcher_idxs_lower_de,
.switcher_dests = switcher_dests_lower_de
},
{
.num_keys = num_keys_upper_de,
.keycaps = keycaps_upper_de,
.attributes = attributes_upper_de,
.num_modifiers = num_modifiers_upper_de,
.modifier_idxs = modifier_idxs_upper_de,
.num_switchers = num_switchers_upper_de,
.switcher_idxs = switcher_idxs_upper_de,
.switcher_dests = switcher_dests_upper_de
},
{
.num_keys = num_keys_numbers_de,
.keycaps = keycaps_numbers_de,
.attributes = attributes_numbers_de,
.num_modifiers = num_modifiers_numbers_de,
.modifier_idxs = modifier_idxs_numbers_de,
.num_switchers = num_switchers_numbers_de,
.switcher_idxs = switcher_idxs_numbers_de,
.switcher_dests = switcher_dests_numbers_de
},
{
.num_keys = num_keys_special_de,
.keycaps = keycaps_special_de,
.attributes = attributes_special_de,
.num_modifiers = num_modifiers_special_de,
.modifier_idxs = modifier_idxs_special_de,
.num_switchers = num_switchers_special_de,
.switcher_idxs = switcher_idxs_special_de,
.switcher_dests = switcher_dests_special_de
}
};
#define SQ2LV_SYMBOL_SHIFT "Shift"
/**
* Layout: Spanish - generated from es
@ -208,7 +20,7 @@ static const int num_keys_lower_es = 37;
static const char * const keycaps_lower_es[] = { \
"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n", \
"a", "s", "d", "f", "g", "h", "j", "k", "l", "ñ", "\n", \
"ABC", "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
"123", "áÁ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "?", ".", LV_SYMBOL_OK, "" \
};
@ -242,7 +54,7 @@ static const int num_keys_upper_es = 37;
static const char * const keycaps_upper_es[] = { \
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "\n", \
"A", "S", "D", "F", "G", "H", "J", "K", "L", "Ñ", "\n", \
"abc", "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
"123", "áÁ", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "¿", ".", LV_SYMBOL_OK, "" \
};
@ -398,7 +210,7 @@ static const int num_keys_lower_fr = 35;
static const char * const keycaps_lower_fr[] = { \
"a", "z", "e", "r", "t", "y", "u", "i", "o", "p", "\n", \
"q", "s", "d", "f", "g", "h", "j", "k", "l", "m", "\n", \
"ABC", "w", "x", "c", "v", "b", "n", ".", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "w", "x", "c", "v", "b", "n", ".", LV_SYMBOL_BACKSPACE, "\n", \
"123", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "âÂ", LV_SYMBOL_OK, "" \
};
@ -432,7 +244,7 @@ static const int num_keys_upper_fr = 35;
static const char * const keycaps_upper_fr[] = { \
"A", "Z", "E", "R", "T", "Y", "U", "I", "O", "P", "\n", \
"Q", "S", "D", "F", "G", "H", "J", "K", "L", "M", "\n", \
"abc", "W", "X", "C", "V", "B", "N", ",", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "W", "X", "C", "V", "B", "N", ",", LV_SYMBOL_BACKSPACE, "\n", \
"123", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, "âÂ", LV_SYMBOL_OK, "" \
};
@ -588,7 +400,7 @@ static const int num_keys_lower_us = 34;
static const char * const keycaps_lower_us[] = { \
"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n", \
"a", "s", "d", "f", "g", "h", "j", "k", "l", "\n", \
"ABC", "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
"123", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ".", LV_SYMBOL_OK, "" \
};
@ -622,7 +434,7 @@ static const int num_keys_upper_us = 34;
static const char * const keycaps_upper_us[] = { \
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "\n", \
"A", "S", "D", "F", "G", "H", "J", "K", "L", "\n", \
"abc", "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
"123", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ".", LV_SYMBOL_OK, "" \
};
@ -724,16 +536,9 @@ static const sq2lv_layer_t layers_us[] = {
* Public interface
**/
const int sq2lv_num_layouts = 4;
const int sq2lv_num_layouts = 3;
const sq2lv_layout_t sq2lv_layouts[] = {
/* German */
{
.name = name_de,
.short_name = short_name_de,
.num_layers = num_layers_de,
.layers = layers_de
},
/* Spanish */
{
.name = name_es,
@ -758,13 +563,11 @@ const sq2lv_layout_t sq2lv_layouts[] = {
};
const char * const sq2lv_layout_names =
"German" "\n"
"Spanish" "\n"
"French" "\n"
"US English";
const char * const sq2lv_layout_short_names =
"de" "\n"
"es" "\n"
"fr" "\n"
"us";

View file

@ -0,0 +1,64 @@
/**
* Auto-generated with squeek2lvgl
**/
#ifndef SQ2LV_LAYOUTS_H
#define SQ2LV_LAYOUTS_H
#include "lvgl/lvgl.h"
#define SQ2LV_SCANCODES_ENABLED 0
/* Key attributes */
#define SQ2LV_CTRL_NON_CHAR (LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_CHECKED)
#define SQ2LV_CTRL_MOD_ACTIVE (LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_CHECKABLE)
#define SQ2LV_CTRL_MOD_INACTIVE (LV_BTNMATRIX_CTRL_NO_REPEAT | LV_BTNMATRIX_CTRL_CLICK_TRIG | LV_BTNMATRIX_CTRL_CHECKABLE | LV_BTNMATRIX_CTRL_CHECKED)
/* Layout IDs, values can be used as indexes into the sq2lv_layouts array */
typedef enum {
SQ2LV_LAYOUT_ES = 0,
SQ2LV_LAYOUT_FR = 1,
SQ2LV_LAYOUT_US = 2
} sq2lv_layout_id_t;
/* Layer type */
typedef struct {
/* Number of keys */
const int num_keys;
/* Key caps */
const char ** const keycaps;
/* Key attributes */
const lv_btnmatrix_ctrl_t * const attributes;
/* Number of modifier keys */
const int num_modifiers;
/* Button indexes of modifier keys */
const int * const modifier_idxs;
/* Number of buttons that trigger a layer switch */
const int num_switchers;
/* Button indexes that trigger a layer switch */
const int * const switcher_idxs;
/* Indexes of layers to jump to when triggering layer switch buttons */
const int * const switcher_dests;
} sq2lv_layer_t;
/* Layout type */
typedef struct {
/* Layout name */
const char * const name;
/* Layout short name */
const char * const short_name;
/* Total number of layers */
const int num_layers;
/* Layers array */
const sq2lv_layer_t * const layers;
} sq2lv_layout_t;
/* Layouts */
extern const int sq2lv_num_layouts;
extern const sq2lv_layout_t sq2lv_layouts[];
/* Layout names (suitable for use in lv_dropdown_t) */
extern const char * const sq2lv_layout_names;
extern const char * const sq2lv_layout_short_names;
#endif /* SQ2LV_LAYOUTS_H */

View file

@ -5,6 +5,8 @@
#include "sq2lv_layouts.h"
#include <linux/input.h>
#define SQ2LV_SYMBOL_SHIFT "Shift"
/**
* Layout: US English (Terminal) - generated from terminal/us
**/
@ -20,7 +22,7 @@ static const char * const keycaps_lower_terminal_us[] = { \
"Ctrl", "Alt", LV_SYMBOL_UP, LV_SYMBOL_DOWN, LV_SYMBOL_LEFT, LV_SYMBOL_RIGHT, "\n", \
"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n", \
"a", "s", "d", "f", "g", "h", "j", "k", "l", "\n", \
"ABC", "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
"123", " ", LV_SYMBOL_OK, "" \
};
@ -82,7 +84,7 @@ static const char * const keycaps_upper_terminal_us[] = { \
"Ctrl", "Alt", "PgUp", "PgDn", "Home", "End", "\n", \
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "\n", \
"A", "S", "D", "F", "G", "H", "J", "K", "L", "\n", \
"abc", "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
"123", " ", LV_SYMBOL_OK, "" \
};

View file

@ -4,6 +4,8 @@
#include "sq2lv_layouts.h"
#define SQ2LV_SYMBOL_SHIFT "Shift"
/**
* Layout: US English - generated from us
**/
@ -18,7 +20,7 @@ static const int num_keys_lower_us = 34;
static const char * const keycaps_lower_us[] = { \
"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n", \
"a", "s", "d", "f", "g", "h", "j", "k", "l", "\n", \
"ABC", "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "z", "x", "c", "v", "b", "n", "m", LV_SYMBOL_BACKSPACE, "\n", \
"123", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ".", LV_SYMBOL_OK, "" \
};
@ -52,7 +54,7 @@ static const int num_keys_upper_us = 34;
static const char * const keycaps_upper_us[] = { \
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "\n", \
"A", "S", "D", "F", "G", "H", "J", "K", "L", "\n", \
"abc", "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
SQ2LV_SYMBOL_SHIFT, "Z", "X", "C", "V", "B", "N", "M", LV_SYMBOL_BACKSPACE, "\n", \
"123", LV_SYMBOL_LEFT, " ", LV_SYMBOL_RIGHT, ".", LV_SYMBOL_OK, "" \
};

View file

@ -26,10 +26,15 @@ pipenv run python squeek2lvgl.py \
pipenv run python squeek2lvgl.py \
--input de.yaml \
--output examples/de-with-custom-shift-keycap \
--surround-space-with-arrows \
--shift-keycap ABC
pipenv run python squeek2lvgl.py \
--input es.yaml \
--input fr.yaml \
--input us.yaml \
--output examples/de+es+fr+us \
--output examples/es+fr+us \
--surround-space-with-arrows
pipenv run python squeek2lvgl.py \

View file

@ -63,6 +63,8 @@ def parse_arguments():
parser.add_argument('--input', dest='input', action='append', required=True, help='squeekboard layout to '
+ 'use as input for generation. Has to be a YAML file path relative to data/keyboards. '
+ 'Can be specified multiple times.')
parser.add_argument('--shift-keycap', dest='shift_keycap', type=str, required=False, help='key caption for '
+ 'the Shift key. Defaults to "Shift".')
parser.add_argument('--surround-space-with-arrows', action='store_true', dest='arrows_around_space',
help='insert left / right arrow before / after space key')
parser.add_argument('--generate-scancodes', action='store_true', dest='generate_scancodes', help='also '
@ -328,30 +330,18 @@ keycap_for_key = {
'BackSpace': 'LV_SYMBOL_BACKSPACE',
'colon': ':',
'period': '.',
'Shift_L': {
'base': 'ABC',
'upper': 'abc'
},
'Shift_L': 'SQ2LV_SYMBOL_SHIFT',
'space': ' ',
'Return': 'LV_SYMBOL_OK',
}
def key_to_keycap(key, view_id, layout_id):
def key_to_keycap(args, key):
"""Return the keycap for a key
args -- commandline arguments
key -- the key
view_id -- ID of the view the key appears on
layout_id -- ID of the layout the view is part of
"""
keycap = keycap_for_key[key] if key in keycap_for_key else key
if isinstance(keycap, dict):
if view_id in keycap:
keycap = keycap[view_id]
elif layout_id in keycap:
keycap = keycap[layout_id]
else:
keycap = None
return keycap
return keycap_for_key[key] if key in keycap_for_key else key
def key_is_modifier(key, data_buttons):
@ -395,7 +385,7 @@ def key_to_attributes(key, is_locked, is_lockable, data_buttons):
def keycap_to_c_value(keycap):
"""Return the right-hand side C value for a keycap
"""
return keycap if keycap.startswith('LV_') else f'"{keycap}"'
return keycap if keycap.startswith('LV_') or keycap.startswith('SQ2LV_') else f'"{keycap}"'
scancodes_for_keycap = {
@ -497,23 +487,25 @@ scancodes_for_keycap = {
'.': ['KEY_DOT']
}
def keycap_to_scancodes(keycap):
def keycap_to_scancodes(args, keycap):
"""Return the scancodes needed to produce a keycap
args -- commandline arguments
keycap -- keycap to produce
"""
if keycap == 'SQ2LV_SYMBOL_SHIFT':
return []
if keycap not in scancodes_for_keycap:
warn(f'Cannot determine scancodes for unknown keycap "{keycap}"')
return []
return scancodes_for_keycap[keycap]
def get_keycaps_attrs_modifiers_switchers_scancodes(args, layout_id, view_id, data_views, data_buttons):
def get_keycaps_attrs_modifiers_switchers_scancodes(args, view_id, data_views, data_buttons):
"""Return keycaps, LVGL button attributes, modifier key indexes, layer switching key indexes,
layer switching key destinations and scancodes for a view
args -- Commandline arguments
layout_id -- ID of the layout
args -- commandline arguments
view_id -- ID of the view
data_views -- the "views" object from the layout's YAML file
data_buttons -- the "buttons" object from the layout's YAML file
@ -554,7 +546,7 @@ def get_keycaps_attrs_modifiers_switchers_scancodes(args, layout_id, view_id, da
if key in data_buttons and 'label' in data_buttons[key]:
keycap = data_buttons[key]['label']
else:
keycap = key_to_keycap(key, view_id, layout_id)
keycap = key_to_keycap(args, key)
if not keycap:
continue
@ -587,7 +579,7 @@ def get_keycaps_attrs_modifiers_switchers_scancodes(args, layout_id, view_id, da
attrs_in_row.append(key_to_attributes(key, is_locked, is_lockable, data_buttons))
if args.generate_scancodes:
scancodes_in_row.append(keycap_to_scancodes(keycap))
scancodes_in_row.append(keycap_to_scancodes(args, keycap))
idx += 1
@ -643,6 +635,10 @@ if __name__ == '__main__':
c_builder.add_system_include('linux/input.h')
c_builder.add_line()
shift_keycap = args.shift_keycap if args.shift_keycap else 'Shift'
c_builder.add_line(f'#define SQ2LV_SYMBOL_SHIFT "{shift_keycap}"')
c_builder.add_line()
h_builder = SourceFileBuilder()
h_builder.add_include('lvgl/lvgl.h')
h_builder.add_line()
@ -693,7 +689,7 @@ if __name__ == '__main__':
c_builder.add_line()
keycaps, attrs, modifier_idxs, switcher_idxs, switcher_dests, scancodes = get_keycaps_attrs_modifiers_switchers_scancodes(
args, layout_id, view_id, data_views, data_buttons)
args, view_id, data_views, data_buttons)
for dest in switcher_dests:
if dest not in view_ids: