aboutsummaryrefslogtreecommitdiff
path: root/layouts/community/ergodox/algernon/tools/text-to-log.py
diff options
context:
space:
mode:
authorJack Humbert <jack.humb@gmail.com>2017-08-23 22:29:07 -0400
committerGitHub <noreply@github.com>2017-08-23 22:29:07 -0400
commitd2ff66a985b938e87fffe55c1d9f1dc55e356f91 (patch)
tree561b3e203033849573a17f5ac6248077ab687676 /layouts/community/ergodox/algernon/tools/text-to-log.py
parent7260fc3eef98fb7b0e2ed24d3d0d14cf2e613000 (diff)
downloadqmk_firmware-d2ff66a985b938e87fffe55c1d9f1dc55e356f91.tar.gz
qmk_firmware-d2ff66a985b938e87fffe55c1d9f1dc55e356f91.zip
Creates a layouts/ folder for keymaps shared between keyboards (#1609)
* include variables and .h files as pp directives * start layout compilation * split ergodoxes up * don't compile all layouts for everything * might seg fault * reset layouts variable * actually reset layouts * include rules.mk instead * remove includes from rules.mk * update variable setting * load visualizer from path * adds some more examples * adds more layouts * more boards added * more boards added * adds documentation for layouts * use lowercase names for LAYOUT_ * add layout.json files for each layout * add community folder, default keymaps for layouts * touch-up default layouts * touch-up layouts, some keyboard rules.mk * update documentation for layouts * fix up serial/i2c switches
Diffstat (limited to 'layouts/community/ergodox/algernon/tools/text-to-log.py')
-rw-r--r--layouts/community/ergodox/algernon/tools/text-to-log.py107
1 files changed, 107 insertions, 0 deletions
diff --git a/layouts/community/ergodox/algernon/tools/text-to-log.py b/layouts/community/ergodox/algernon/tools/text-to-log.py
new file mode 100644
index 000000000..f080c32cd
--- /dev/null
+++ b/layouts/community/ergodox/algernon/tools/text-to-log.py
@@ -0,0 +1,107 @@
1#!/usr/bin/env python3
2
3import os
4import sys
5
6charmap = {
7 '9': [[1, 0]],
8 '7': [[2, 0]], '@': [[2, 5], [2, 0]],
9 '5': [[3, 0]], '*': [[2, 5], [3, 0]],
10 '3': [[4, 0]], '^': [[2, 5], [4, 0]],
11 '1': [[5, 0]], '$': [[2, 5], [5, 0]],
12 '0': [[8, 0]], '%': [[2, 5], [8, 0]],
13 '2': [[9, 0]], '!': [[2, 5], [9, 0]],
14 '4': [[10, 0]], '#': [[2, 5], [10, 0]],
15 '6': [[11, 0]], '&': [[2, 5], [11, 0]],
16 '8': [[12, 0]],
17
18 '\\': [[0, 1]], '|': [[2, 5], [0, 1]],
19 'x': [[1, 1]], 'X': [[2, 5], [1, 1]],
20 'w': [[2, 1]], 'W': [[2, 5], [2, 1]],
21 'c': [[3, 1]], 'C': [[2, 5], [3, 1]],
22 'h': [[4, 1]], 'H': [[2, 5], [4, 1]],
23 'f': [[5, 1]], 'F': [[2, 5], [5, 1]],
24 '[': [[6, 1]], '{': [[2, 5], [6, 1]], '(': [[6, 1], [6, 1]],
25 ']': [[7, 1]], '}': [[2, 5], [7, 1]], ')': [[7, 1], [7, 1]],
26 'm': [[8, 1]], 'M': [[2, 5], [8, 1]],
27 'g': [[9, 1]], 'G': [[2, 5], [9, 1]],
28 'l': [[10, 1]], 'L': [[2, 5], [10, 1]],
29 'p': [[11, 1]], 'P': [[2, 5], [11, 1]],
30 '/': [[12, 1]], '?': [[2, 5], [12, 1]],
31 '`': [[13, 1]], '~': [[2, 5], [13, 1]],
32
33 '\t': [[0, 2]],
34 'a': [[1, 2]], 'A': [[2, 5], [1, 2]],
35 'o': [[2, 2]], 'O': [[2, 5], [2, 2]],
36 'e': [[3, 2]], 'E': [[2, 5], [3, 2]],
37 'i': [[4, 2]], 'I': [[2, 5], [4, 2]],
38 'u': [[5, 2]], 'U': [[2, 5], [5, 2]],
39 'd': [[8, 2]], 'D': [[2, 5], [8, 2]],
40 'r': [[9, 2]], 'R': [[2, 5], [9, 2]],
41 't': [[10, 2]], 'T': [[2, 5], [10, 2]],
42 'n': [[11, 2]], 'N': [[2, 5], [11, 2]],
43 's': [[12, 2]], 'S': [[2, 5], [12, 2]],
44 '=': [[13, 2]], '+': [[2, 5], [13, 2]],
45
46 'z': [[1, 3]], 'Z': [[2, 5], [1, 3]],
47 'q': [[2, 3]], 'Q': [[2, 5], [2, 3]],
48 '\'': [[3, 3]], '"': [[2, 5], [3, 3]],
49 ',': [[4, 3]], '<': [[2, 5], [4, 3]],
50 '.': [[5, 3]], '>': [[2, 5], [5, 3]],
51 'b': [[8, 3]], 'B': [[2, 5], [8, 3]],
52 'k': [[9, 3]], 'K': [[2, 5], [9, 3]],
53 'v': [[10, 3]], 'V': [[2, 5], [10, 3]],
54 'y': [[11, 3]], 'Y': [[2, 5], [11, 3]],
55 'j': [[12, 3]], 'J': [[2, 5], [12, 3]],
56
57 ':': [[4, 4]], ';': [[4, 4], [4, 4]],
58 '-': [[9, 4]], '_': [[2, 5], [9, 4]],
59
60 ' ': [[10, 5]],
61 '\n': [[11, 5]],
62
63 ## Layered things
64 # Hungarian
65 'á': [[9, 5], [1, 2]], 'Á': [[2, 5], [9, 5], [1, 2]],
66 'ó': [[9, 5], [2, 2]], 'Ó': [[2, 5], [9, 5], [2, 2]],
67 'ő': [[9, 5], [2, 1]], 'Ő': [[2, 5], [9, 5], [2, 1]],
68 'ö': [[9, 5], [2, 3]], 'Ö': [[2, 5], [9, 5], [2, 3]],
69 'é': [[9, 5], [3, 2]], 'É': [[2, 5], [9, 5], [3, 2]],
70 'ú': [[9, 5], [4, 2]], 'Ú': [[2, 5], [9, 5], [4, 2]],
71 'ű': [[9, 5], [4, 1]], 'Ű': [[2, 5], [9, 5], [4, 1]],
72 'ü': [[9, 5], [4, 3]], 'Ü': [[2, 5], [9, 5], [4, 3]],
73 'í': [[9, 5], [5, 2]], 'Í': [[2, 5], [9, 5], [5, 2]],
74}
75
76def lookup_char(layer, ch):
77 if ch in charmap:
78 return charmap[ch]
79 return None
80
81def process_char(layer, ch, out=sys.stdout):
82 keys = lookup_char(layer, ch)
83 if not keys:
84 print ("Unknown char: %s" % ch, file=sys.stderr)
85 else:
86 for (c, r) in keys:
87 print ("KL: col=%d, row=%d, pressed=1, layer=%s" % (r, c, layer), file=out)
88 print ("KL: col=%d, row=%d, pressed=0, layer=%s" % (r, c, layer), file=out)
89
90def process_file(fn, layer, out=sys.stdout):
91 with open(fn, "r") as f:
92 ch = f.read(1)
93 while ch:
94 process_char(layer, ch, out)
95 ch = f.read(1)
96
97if sys.argv[1] == '-':
98 out='/dev/stdin'
99else:
100 out=sys.argv[1]
101
102if len(sys.argv) >= 2:
103 layer = 'ADORE'
104else:
105 layer = sys.argv[2]
106
107process_file(out, layer = layer)