-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkey-layouts.scad
57 lines (49 loc) · 1.57 KB
/
key-layouts.scad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use <positioning.scad>
use <placeholders.scad>
include <definitions.scad>
$render_keycaps = false;
$render_switches = false;
$render_plates = false;
$render_all = false;
module layout(cluster) {
assert(cluster == "finger" || cluster == "thumb", "'cluster' must be one of (finger|thumb)");
columns = cluster == "finger" ? finger_columns : thumb_columns;
transform = function (col, row) cluster == "finger"
? place_finger_key(col, row)
: place_thumb_key(col, row);
for (col=[0:len(columns)-1]) {
column_u = get_column_width(cluster, col);
for (rowIndex=[0:len(columns[col])-1]) {
row = columns[col][rowIndex];
align = get_alignment_override(cluster, col, rowIndex);
size_overrides = get_overrides(cluster, col, rowIndex);
$u = size_overrides[0];
$h = size_overrides[1];
multmatrix(transform(col, row)) {
if ($render_plates) plate($u=column_u, align=align);
translate([$u < column_u ? -plate_width * $u/4 : 0, 0, 0]) {
if ($render_keycaps) keycap();
if ($render_switches) switch();
}
}
}
}
}
module finger_cluster_layout() {
for (col=[0:len(finger_columns)-1]) {
for (row=finger_columns[col]) {
place_finger_key(col, row) children();
}
}
}
module thumb_cluster_layout() {
for (col=[0:len(thumb_columns)-1]) {
for (rowIndex=[0:len(thumb_columns[col])-1]) {
row = thumb_columns[col][rowIndex];
overrides = get_overrides("thumb", col, rowIndex);
$u = overrides[0];
$h = overrides[1];
place_thumb_key(col, row) children();
}
}
}