feat(qmkasciigen): split raw binding and transform
parent
d8b3a199ab
commit
0b4de29e5f
|
@ -11,7 +11,7 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md
|
// https://github.com/qmk/qmk_firmware/blob/master/docs/keycodes.md
|
||||||
var mapFromTo = []map[string]string{
|
var mapRawBinding = []map[string]string{
|
||||||
{
|
{
|
||||||
// My custom
|
// My custom
|
||||||
"CTL_T(KC_ESC)": "ESC CTRL",
|
"CTL_T(KC_ESC)": "ESC CTRL",
|
||||||
|
@ -60,12 +60,30 @@ var mapFromTo = []map[string]string{
|
||||||
// Space cadet
|
// Space cadet
|
||||||
"SC_LSPO": "( SHIFT",
|
"SC_LSPO": "( SHIFT",
|
||||||
"SC_RSPC": ") SHIFT",
|
"SC_RSPC": ") SHIFT",
|
||||||
|
// Quantum
|
||||||
|
"EE_CLR": "EECLR",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
var mapTransform = []map[string]string{
|
||||||
|
{
|
||||||
|
// Layer enum
|
||||||
|
"LAYER_QWERTY": "0",
|
||||||
|
"LAYER_COMMON": "1",
|
||||||
|
"LAYER_RARELY": "2",
|
||||||
|
"LAYER_RECOVERY": "3",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Prefix
|
// Prefix
|
||||||
"KC_": "",
|
"KC_": "",
|
||||||
"QK_": "",
|
"QK_": "",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"MO(0)": "L0",
|
||||||
|
"MO(1)": "L1",
|
||||||
|
"MO(2)": "L2",
|
||||||
|
"MO(3)": "L3",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
type DrawConfig struct {
|
type DrawConfig struct {
|
||||||
|
@ -146,11 +164,22 @@ func Draw(
|
||||||
keyStr := layer[count]
|
keyStr := layer[count]
|
||||||
|
|
||||||
// Convert keyStr
|
// Convert keyStr
|
||||||
for _, m := range mapFromTo {
|
isRaw := false
|
||||||
|
for _, m := range mapRawBinding {
|
||||||
|
if _, ok := m[keyStr]; ok {
|
||||||
|
isRaw = true
|
||||||
|
keyStr = m[keyStr]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isRaw {
|
||||||
|
for _, m := range mapTransform {
|
||||||
for from, to := range m {
|
for from, to := range m {
|
||||||
keyStr = strings.ReplaceAll(keyStr, from, to)
|
keyStr = strings.ReplaceAll(keyStr, from, to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Padding to center key
|
// Padding to center key
|
||||||
// Why / 2, why - 1 ?
|
// Why / 2, why - 1 ?
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
+-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
|
+-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
|
||||||
| ESC CTRL | A | S | D | F | G | H | J | K | L | ; | ' | ENTER |
|
| ESC CTRL | A | S | D | F | G | H | J | K | L | ; | ' | ENTER |
|
||||||
+-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
|
+-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
|
||||||
| ( SHIFT | Z | X | C | V | B | N | M | , | . | / | ) SHIFT | MO(1) |
|
| ( SHIFT | Z | X | C | V | B | N | M | , | . | / | ) SHIFT | L1 |
|
||||||
+-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
|
+-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
|
||||||
| | OPT | CMD | SPACE | CMD | OPT | |
|
| | OPT | CMD | SPACE | CMD | OPT | |
|
||||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||||
|
@ -29,13 +29,13 @@
|
||||||
+-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
|
+-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
|
||||||
| CAPS | VOLD | VOLU | MUTE | | | | | HOME | PGUP | | | |
|
| CAPS | VOLD | VOLU | MUTE | | | | | HOME | PGUP | | | |
|
||||||
+-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
|
+-------------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---------+-------+
|
||||||
| | RGBH | RGBS | RGBV | | | | | END | PGDN | | | MO(3) |
|
| | RGBH | RGBS | RGBV | | | | | END | PGDN | | | L3 |
|
||||||
+-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
|
+-----------+-----+-+-----+-----+-+-------+-------+-------+-------+-------+-------+-----+-+-------+-+-------+---+-------+
|
||||||
| | | | | RGBTO | RGBMO | |
|
| | | | | RGBTO | RGBMO | |
|
||||||
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
+-----------+-------+-----------+-------------------------------------------------------+-----------+-------+-----------+
|
||||||
|
|
||||||
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
|
+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
|
||||||
| BOOT | EE_CLR| | | | | | | | | | | | | |
|
| BOOT | EECLR | | | | | | | | | | | | | |
|
||||||
+-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
|
+-------+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+-------+
|
||||||
| | | | | | | | | | | | | | |
|
| | | | | | | | | | | | | | |
|
||||||
+-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
|
+-----------+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-+-----+-----------+
|
||||||
|
|
Loading…
Reference in New Issue