1
Fork 0

Update keymap

This commit is contained in:
Matei Adriel 2023-10-22 01:06:33 +02:00
parent d8180afd3d
commit 377fe0dd3d
No known key found for this signature in database
4 changed files with 43 additions and 33 deletions

View file

@ -17,10 +17,10 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1671883564, "lastModified": 1695360818,
"narHash": "sha256-C15oAtyupmLB3coZY7qzEHXjhtUx/+77olVdqVMruAg=", "narHash": "sha256-JlkN3R/SSoMTa+CasbxS1gq+GpGxXQlNZRUh9+LIy/0=",
"path": "/nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source", "path": "/nix/store/09yvj6yyxspzfivv91bcxwrjxawpk1g2-source",
"rev": "dac57a4eccf1442e8bf4030df6fcbb55883cb682", "rev": "e35dcc04a3853da485a396bdd332217d0ac9054f",
"type": "path" "type": "path"
}, },
"original": { "original": {

View file

@ -2,17 +2,17 @@
description = "Kayboard layout diagram generation"; description = "Kayboard layout diagram generation";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { nixpkgs, flake-utils, ... }@inputs: outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem flake-utils.lib.eachDefaultSystem
(system: (system:
let let
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
swoop = pkgs.callPackage ./swoop.nix {}; swoop = pkgs.callPackage ./swoop.nix { };
in in
rec { rec {
packages.swoop = swoop; packages.swoop = swoop;
defaultPackage = packages.swoop; defaultPackage = packages.swoop;
devShell = pkgs.callPackage ./shell.nix {}; devShell = pkgs.callPackage ./shell.nix { };
} }
); );
} }

View file

@ -45,7 +45,7 @@ function indent(amount: number, text: string) {
function tag( function tag(
name: string, name: string,
attributes: Record<string, string | number | undefined>, attributes: Record<string, string | number | undefined>,
children: string = "" children: string = "",
) { ) {
const attributeString = Object.entries(attributes) const attributeString = Object.entries(attributes)
.map(([k, v]) => `${k}="${v}"`) .map(([k, v]) => `${k}="${v}"`)
@ -74,7 +74,7 @@ function textContents(input: string): string {
function renderKey( function renderKey(
visual: VisualKey, visual: VisualKey,
key: KeyboardKey, key: KeyboardKey,
colorscheme: LayoutColorscheme colorscheme: LayoutColorscheme,
) { ) {
const centerX = visual.position[0] + visual.size[0] / 2; const centerX = visual.position[0] + visual.size[0] / 2;
const centerY = visual.position[1] + visual.size[1] / 2; const centerY = visual.position[1] + visual.size[1] / 2;
@ -117,7 +117,7 @@ function renderKey(
fill: textColor(key.main, colorscheme.mainLayerColor), fill: textColor(key.main, colorscheme.mainLayerColor),
...textAttribs, ...textAttribs,
}, },
textContents(key.main) textContents(key.main),
), ),
tag( tag(
"text", "text",
@ -128,7 +128,7 @@ function renderKey(
"font-size": "66%", "font-size": "66%",
...textAttribs, ...textAttribs,
}, },
textContents(key.tlLayer) textContents(key.tlLayer),
), ),
tag( tag(
"text", "text",
@ -140,7 +140,7 @@ function renderKey(
...textAttribs, ...textAttribs,
"text-anchor": "end", "text-anchor": "end",
}, },
textContents(key.trLayer) textContents(key.trLayer),
), ),
tag( tag(
"text", "text",
@ -152,9 +152,9 @@ function renderKey(
...textAttribs, ...textAttribs,
"text-anchor": "start", "text-anchor": "start",
}, },
textContents(key.blLayer) textContents(key.blLayer),
), ),
].join("\n") ].join("\n"),
); );
} }
@ -168,12 +168,14 @@ function renderLayout(layout: Layout) {
2 * layout.padding + layout.size[0], 2 * layout.padding + layout.size[0],
2 * layout.padding + layout.size[1], 2 * layout.padding + layout.size[1],
].join(" "), ].join(" "),
xmlns: "http://www.w3.org/2000/svg",
"xmlns:xlink": "http://www.w3.org/1999/xlink",
}, },
layout.visual layout.visual
.map((key, index) => .map((key, index) =>
renderKey(key, layout.keys[index], layout.colorscheme) renderKey(key, layout.keys[index], layout.colorscheme),
) )
.join("\n") .join("\n"),
); );
} }
@ -209,7 +211,7 @@ function neg(v: Vec2): Vec2 {
function thumbs( function thumbs(
at: Vec2, at: Vec2,
reverse: boolean, reverse: boolean,
thumbRotation = reverse ? -15 : 15 thumbRotation = reverse ? -15 : 15,
): VisualLayout { ): VisualLayout {
// Distance between thumb key centers // Distance between thumb key centers
const factor = keySize; const factor = keySize;
@ -238,7 +240,7 @@ function key(
main: string, main: string,
tlLayer = "", tlLayer = "",
trLayer = "", trLayer = "",
blLayer = "" blLayer = "",
): KeyboardKey { ): KeyboardKey {
return { main, tlLayer, trLayer, blLayer }; return { main, tlLayer, trLayer, blLayer };
} }
@ -269,28 +271,36 @@ const layout: Layout = {
keys: [ keys: [
[ [
key("Q", "!", "1", "f1"), key("Q", "!", "1", "f1"),
key("A", "(", "6", "f6"), key("A", "&lt;", "6", "f6"),
key("Z", ")", "", "f11"), key("X", "&gt;", "", "f11"),
], ],
[ [
key("W", "@", "2", "f2"), key("W", "@", "2", "f2"),
key("S", "[", "7", "f7"), key("R", "(", "7", "f7"),
key("X", "]", "", "f12"), key("C", ")", "", "f12"),
], ],
[key("E", "#", "3", "f3"), key("D", "{", "8", "f8"), key("C", "}")], [key("F", "#", "3", "f3"), key("S", "[", "8", "f8"), key("D", "]")],
[key("R", "$", "4", "f4"), key("F", "&lt", "9", "f9"), key("V", "&gt")], [key("P", "$", "4", "f4"), key("T", "{", "9", "f9"), key("V", "}")],
[key("T", "%", "5", "f5"), key("G", ";", "0", "f10"), key("B", "")], [key("B", "%", "5", "f5"), key("G", "-", "0", "f10"), key("Z", "—")],
[key("TR", "", ""), key("␣", "", "")], [key("TR", "", ""), key("␣", "", "")],
[key("⇧", "", ""), key("TL", "", "")], [key("⇧", "", ""), key("TL", "", "")],
[key("Y", "^", ""), key("H", "-", "◄", "😱"), key("N", "?", "", "🎮")], [key("J", "^", "🏠"), key("M", "?", "◄", "😱"), key("K", "", "", "🎮")],
[ [
key("U", "&", "", "🔊"), key("L", "&amp;", "⏬", "🔊"),
key("J", "_", "▼", "🔉"), key("N", "_", "▼", "🔉"),
key("M", "/", "", "🔇"), key("H", "|", "", "🔇"),
],
[key("U", "*", "⏫", "🔆"), key("E", "/", "▲", "🔅"), key(",", "\\", "")],
[
key("Y", "~", "end", "⏪"),
key("I", "=", "►", "⏯️"),
key(".", "+", "", "⏩"),
],
[
key(":", "`", "del", "copy"),
key("O", ";", "", "paste"),
key("'", '"', "", "cut"),
], ],
[key("I", "*", "", "🔆"), key("K", "=", "▲", "🔅"), key(",", "\\", "")],
[key("O", "~", "", "⏪"), key("L", "+", "►", "⏯️"), key(".", "|", "", "⏩")],
[key("P", "`", "del"), key(":", "", ""), key('"', "'", "")],
].flat(), ].flat(),
padding: 20, padding: 20,
size: [keySize * 12, keySize * 6], size: [keySize * 12, keySize * 6],

View file

@ -12,7 +12,7 @@ pkgs.stdenv.mkDerivation {
]; ];
buildPhase = '' buildPhase = ''
esbuild $src/index.ts --bundle --outfile=./out.js esbuild $src/index.ts --bundle --outfile=./out.js --platform=node
''; '';
installPhase = '' installPhase = ''