diff --git a/src/key_layouts.scad b/src/key_layouts.scad index 10b5630..7b53a51 100644 --- a/src/key_layouts.scad +++ b/src/key_layouts.scad @@ -17,4 +17,7 @@ include include include +include +include + include diff --git a/src/layouts/layout.scad b/src/layouts/layout.scad index cd3c9c2..3dbd3a9 100644 --- a/src/layouts/layout.scad +++ b/src/layouts/layout.scad @@ -127,3 +127,30 @@ module simple_layout(list) { } } } + +// layout function for use with advanced legends (multiple fonts and font sizes) +// see numpad layouts for an example +module layout_children(list, items) { + for (n=[0:1:$children-1]){ + row = layout_children_row(list,n); + column = layout_children_col(list,n); + key_length = list[row][column]; + column_distance = abs_sum([for (x = [0 : column]) list[row][x]]); + translate_u(column_distance - (key_length/2), -row) + children(n); + } +} + +function layout_children_row(list, n, count=0, row=0, col=0) = + count == n ? + row : + col >= len(list[row]) - 1 ? + layout_children_row(list, n, count+1, row+1, 0) : + layout_children_row(list, n, count+1, row, col+1); + +function layout_children_col(list, n, count=0, row=0, col=0) = + count == n ? + col : + col >= len(list[row]) - 1 ? + layout_children_col(list, n, count+1, row+1, 0) : + layout_children_col(list, n, count+1, row, col+1); diff --git a/src/layouts/numpad/default.scad b/src/layouts/numpad/default.scad new file mode 100644 index 0000000..6d4a065 --- /dev/null +++ b/src/layouts/numpad/default.scad @@ -0,0 +1,125 @@ +include <../layout.scad> + +numpad_default_top_layout = [ + [1,1,1,1], +]; + +numpad_default_layout = [ + [1,1,1,1], + [1,1,1], + [1,1,1,1], + [1,1,1], + [2,1,1] +]; + +module numpad_default() { + char_size=8; + unicode_font="Noto Sans Symbols2"; + front_offset=-0.2; + $font="Noto Sans:style=bold"; + + module profile(row) { + dcs_row(row) + children(); + } + + module char(text, pos=[0,0], size=char_size) { + legend(text,pos,size) + children(); + } + + module unicode(text, pos=[0,0], size=char_size) { + $font=unicode_font; + legend(text,pos,size) + children(); + } + + module front_unicode(text,pos=[0,front_offset],size=5) { + $font=unicode_font; + front_legend(text,pos,size) + children(); + } + + module arrow(top, front, front_pos=[0,front_offset]) { + intersection() { + char(top)children(); + front_unicode(front, front_pos)children(); + } + } + + module front(text, pos=[0,front_offset], size=3) { + front_legend(text, pos, size) + children(); + } + + module front_char(text, pos=[0,front_offset], size=5) { + front_legend(text, pos, size) + children(); + } + + colors=true; + module ifcolor(c) { + if(colors) { + color(c) + children(); + } else { + children(); + } + } + module num() { + ifcolor("purple") + children(); + } + + module sym() { + ifcolor("gray") + children(); + } + module ctl() { + ifcolor("sienna") + children(); + } + module arw() { + ifcolor("red") + children(); + } + + // kbdpad has an extra top row + translate_u(0,1.5) + layout_children(numpad_default_top_layout) { + legend("ESC", size=4) profile(0) ctl() key(); + front_char("%") legend("TAB", size=4) profile(0) ctl() key(); + front_char(")") legend("DEL", size=4) profile(0) ctl() key(); + intersection() { + front_char(")") profile(0) ctl() key(); + unicode(chr(129044),[0,0.2]) profile(0) ctl() key(); + } + }; + + layout_children(numpad_default_layout) { + + front("MOD") legend("NUM", [0,-0.5], size=2.5) legend("LOCK", [0,0.5], size=2.5) profile(0) ctl() key(); + //unicode("⇭") profile(0) key(); + front_char("$") char("/") profile(0) sym() key(); + front_char("=") char("*", [0,0.3]) profile(0) sym() key(); + front_char(",") char("-", [0,0.3]) profile(0) sym() key(); + + front("HOME")char("7") profile(1) num() key(); + arrow("8", chr(129153)) profile(1) arw() key(); + front("PG UP")char("9") profile(1) num() key(); + + arrow("4", chr(129152)) profile(2) arw() key(); + arrow("5", chr(129155),[0,0]) bump() profile(2) arw() key(); + arrow("6", chr(129154)) profile(2) arw() key(); + translate_u(0,0.5) char("+") profile(1) 2uh() sym() key(); + + front("END")char("1") profile(3) num() key(); + arrow("2", chr(129155),[0,0]) profile(3) num() key(); + front("PG DN")char("3") profile(3) num() key(); + + front("INS",[-1.07,front_offset])char("0") profile(4) 2u() num() key(); + front("DEL")char(".") profile(4) sym() key(); + translate_u(0,0.5) unicode(chr(9166)) profile(2) 2uh() sym() key(); + + } +} diff --git a/src/layouts/numpad/iracing.scad b/src/layouts/numpad/iracing.scad new file mode 100644 index 0000000..73fd28b --- /dev/null +++ b/src/layouts/numpad/iracing.scad @@ -0,0 +1,165 @@ +numpad_iracing_top_layout = [ + [1,1,1,1], +]; + +numpad_iracing_layout = [ + [1,1,1,1], + [1,1,1,1], + [1,1,1,1], + [1,1,1,1], + [1,1,1,1], + [1,1,1,1] +]; + +module numpad_iracing() { + $font_size=4; + $font="Noto Sans:style=bold"; + + module plus(top, front) { + intersection() { + legend(top,[0,0.7],size=3.4) front(front) children(); + plus_symbol() children(); + } + } + module plus_symbol() { + $font="Noto Sans Symbols2"; + legend("\u2B9D",[0,-0.7],size=5) + children(); + } + + module minus(top,front) { + intersection() { + legend(top,[0,-0.7],size=3.4) front(front) children(); + minus_symbol() children(); + } + } + module minus_symbol() { + $font="Noto Sans Symbols2"; + legend("\u2B9F",[0,0.7],size=5) + children(); + } + + module front_unicode(text,size=8) { + $font="Noto Sans Symbols2"; + front_legend(text,size=size) + children(); + } + module unicode(text,size=8) { + $font="Noto Sans Symbols2"; + legend(text,size=size) + children(); + } + + module unicode_and_front(code,text) { + intersection() { + unicode(code) + children(); + front(text) + children(); + } + } + + + module front(text) { + front_legend(text,[0,-0.5],size=3) + children(); + } + + + cam_color="sienna"; + car_color="gray"; + lap_color="sienna"; + inc_color="gray"; + + // estimated gap for top row of kbdpad + translate_u(0,1.25) + layout_children(numpad_iracing_top_layout) { + plus("CAM", "SUB") dcs_row(0) if_color(cam_color) key(); + plus("CAR", "DRV") dcs_row(0) if_color(car_color) key(); + plus("LAP", "SES") dcs_row(0) if_color(lap_color) key(); + plus("INC", "START") dcs_row(0) if_color(inc_color)key(); + } + + colors=false; + + module if_color(c) { + if(colors){ + color(c) + children(); + } else { + children(); + } + + } + + module frame() { + if_color("gold") children(); + } + + module direction() { + if_color("darkorange") children(); + } + + module red() { + if_color("red") children(); + } + + module silver() { + if_color("gray") children(); + } + + module brown() { + if_color("sienna") children(); + } + + module mods() { + if_color("gray") children(); + } + + module purple() { + if_color("purple") children(); + //$primary_color="purple"; + //$secondary_color="purple"; + //children(); + } + + + + layout_children(numpad_iracing_layout) { + minus("CAM", "SUB") dcs_row(0) if_color(cam_color) key(); + minus("CAR", "DRV") dcs_row(0) if_color(car_color)key(); + minus("LAP", "SES") dcs_row(0) if_color(lap_color) key(); + minus("INC", "END") dcs_row(0) if_color(inc_color) key(); + + unicode_and_front("\u23EA","FOV") dcs_row(1) direction() key(); + unicode_and_front("\u25B6","STEP") bump() dcs_row(1) red() key(); + unicode("\u23E9") dcs_row(1) direction() key(); + unicode(chr(9201),6) dcs_row(1) purple() key(); + + + unicode_and_front("\u23EE","FOV") dcs_row(2) frame() key(); + unicode_and_front(chr(129153),"STEP") dcs_row(2) purple() key(); // https://unicode-table.com/en/1F881/ + unicode("\u23ED") dcs_row(2) frame() key(); + unicode(chr(9210)) dcs_row(2) frame() key(); + //legend("PRINT", [0,-0.6], size=2.5) legend("SCREEN", [0,0.6], size=2) dcs_row(2) brown() key(); + + unicode(chr(129152)) dcs_row(3) purple() key(); // https://unicode-table.com/en/1F880/ + unicode(chr(129155)) dcs_row(3) purple() key(); // https://unicode-table.com/en/1F883/ + unicode(chr(129154)) dcs_row(3) purple() key(); // https://unicode-table.com/en/1F882/ + dcs_row(3) purple() key(); // https://unicode-table.com/en/1F882/ + //legend("CAM", [0,-0.6], size=3.5) legend("TOOL", [0,0.7], size=2.9) dcs_row(3) purple() key(); // https://unicode-table.com/en/1F881/ + + legend("CTRL",size=3) dcs_row(4) mods() key(); + legend("ALT") front_legend("AIM") dcs_row(4) mods() key(); + //unicode(chr(11017)) unicode(chr(11018)) dcs_row(4) purple() key(); // https://unicode-table.com/en/1F881/ + fullscreen_size=7.5; + unicode(chr(128253)) + front_unicode("\u2B66",fullscreen_size) + front_unicode("\u2B68",fullscreen_size) + front_unicode("\u2B67",fullscreen_size) + front_unicode("\u2B69",fullscreen_size) + dcs_row(4) purple() key(); + front_legend("MOD") legend("UI",size=6) dcs_row(4) mods() key(); + + }; +};