diff --git a/.gitignore b/.gitignore index 61740f2..726d2d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,2 @@ -*~ -env/ result -flash/target -flash/debug .direnv diff --git a/flake.lock b/flake.lock index 15fb526..5578abe 100644 --- a/flake.lock +++ b/flake.lock @@ -84,16 +84,15 @@ "glove80-zmk": { "flake": false, "locked": { - "lastModified": 1716636649, - "narHash": "sha256-b9M0/yZ3oUxKHOjwLxDQXEn/neVE1jhuEFDB5AWXTRA=", - "owner": "darknao", + "lastModified": 1731106960, + "narHash": "sha256-074MPEfhCmrN/5jOO2ezG+BKR+I05/NyUqJBPirNUe0=", + "owner": "juliamertz", "repo": "zmk", - "rev": "6d82f4819c71df9fea7b8e4f7936c60f4b6a50b4", + "rev": "128ac51edcb4b735b2435d54eb24a90981035f37", "type": "github" }, "original": { - "owner": "darknao", - "ref": "darknao/rgb-dts", + "owner": "juliamertz", "repo": "zmk", "type": "github" } @@ -182,7 +181,8 @@ "glove80-zmk": "glove80-zmk", "keymap-drawer": "keymap-drawer", "nixpkgs": "nixpkgs", - "poetry2nix": "poetry2nix" + "poetry2nix": "poetry2nix", + "zmk-helpers": "zmk-helpers" } }, "rust-overlay": { @@ -255,6 +255,22 @@ "repo": "treefmt-nix", "type": "github" } + }, + "zmk-helpers": { + "flake": false, + "locked": { + "lastModified": 1729650883, + "narHash": "sha256-fKqp3sr6+ZmFLXwTXE7Ge9n7F6sy5mDakulJNvucy+I=", + "owner": "urob", + "repo": "zmk-helpers", + "rev": "230c7e18ee3c82325352287db29b59f53f20fa2a", + "type": "github" + }, + "original": { + "owner": "urob", + "repo": "zmk-helpers", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 732d8cf..12de082 100644 --- a/flake.nix +++ b/flake.nix @@ -5,11 +5,17 @@ url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; }; + poetry2nix = { + url = "github:nix-community/poetry2nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; glove80-zmk = { - # Community fork with per-layer rgb - url = "github:darknao/zmk/darknao/rgb-dts"; - # url = "github:moergo-sc/zmk"; + url = "github:juliamertz/zmk"; + flake = false; + }; + zmk-helpers = { + url = "github:urob/zmk-helpers"; flake = false; }; firmware-loader = { @@ -20,10 +26,6 @@ url = "github:caksoylar/keymap-drawer"; flake = false; }; - poetry2nix = { - url = "github:nix-community/poetry2nix"; - inputs.nixpkgs.follows = "nixpkgs"; - }; }; outputs = diff --git a/packages/dtsfmt.nix b/packages/dtsfmt.nix index e78fa53..2a80ce7 100644 --- a/packages/dtsfmt.nix +++ b/packages/dtsfmt.nix @@ -9,8 +9,8 @@ rustPlatform.buildRustPackage rec { meta.mainProgram = pname; src = fetchgit { url = "https://github.com/juliamertz/${pname}.git"; - rev = "b47a3720002ca06d657c7147f7dc56ca7abd68eb"; - hash = "sha256-iepKJVZmCPo6TKoy1+kI41N7tDy+Ozf2SjW9bkcVmLo="; + rev = "ce24df4f243130876558d6ddfb958880b6187b13"; + hash = "sha256-YVlvwZkr9m5SUY6AsG4dobvgKSeQbtAwOm/I7/kdXXc="; }; cargoHash = "sha256-5fMoMaDHAAhfaTEdFwMqzD6N2zheh+AIjgCmaZZex84="; } diff --git a/packages/firmware.nix b/packages/firmware.nix index c5c5751..b4771c5 100644 --- a/packages/firmware.nix +++ b/packages/firmware.nix @@ -2,16 +2,17 @@ let firmware = import inputs.glove80-zmk { inherit pkgs; }; - keymap = ../glove80.keymap; + keymap = "${../src}/main.dts"; kconfig = ../glove80.conf; + extra_modules = [ inputs.zmk-helpers ]; left = firmware.zmk.override { - inherit keymap kconfig; + inherit keymap kconfig extra_modules; board = "glove80_lh"; }; right = firmware.zmk.override { - inherit keymap kconfig; + inherit keymap kconfig extra_modules; board = "glove80_rh"; }; in diff --git a/src/defaults.dts b/src/defaults.dts new file mode 100644 index 0000000..2b6f33b --- /dev/null +++ b/src/defaults.dts @@ -0,0 +1,94 @@ +/ { + behaviors { + lower: lower { + compatible = "zmk,behavior-tap-dance"; + label = "LAYER_TAP_DANCE"; + #binding-cells = <0>; + tapping-term-ms = <200>; + bindings = <&mo LAYER_Lower>, <&to LAYER_Lower>; + }; + }; +}; + +/ { + macros { + rgb_ug_status_macro: rgb_ug_status_macro { + label = "RGB_UG_STATUS"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + bindings = <&rgb_ug RGB_STATUS>; + }; + }; +}; + +/ { + behaviors { + magic: magic { + compatible = "zmk,behavior-hold-tap"; + label = "MAGIC_HOLD_TAP"; + #binding-cells = <2>; + tapping-term-ms = <200>; + bindings = <&mo>, <&rgb_ug_status_macro>; + }; + }; +}; + +// Bluetooth behaviors +/ { + behaviors { + bt_0: bt_0 { + compatible = "zmk,behavior-tap-dance"; + label = "BT_0"; + #binding-cells = <0>; + tapping-term-ms = <200>; + bindings = <&bt_select_0>, <&bt BT_DISC 0>; + }; + bt_1: bt_1 { + compatible = "zmk,behavior-tap-dance"; + label = "BT_1"; + #binding-cells = <0>; + tapping-term-ms = <200>; + bindings = <&bt_select_1>, <&bt BT_DISC 1>; + }; + bt_2: bt_2 { + compatible = "zmk,behavior-tap-dance"; + label = "BT_2"; + #binding-cells = <0>; + tapping-term-ms = <200>; + bindings = <&bt_select_2>, <&bt BT_DISC 2>; + }; + bt_3: bt_3 { + compatible = "zmk,behavior-tap-dance"; + label = "BT_3"; + #binding-cells = <0>; + tapping-term-ms = <200>; + bindings = <&bt_select_3>, <&bt BT_DISC 3>; + }; + }; + macros { + bt_select_0: bt_select_0 { + label = "BT_SELECT_0"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + bindings = <&out OUT_BLE>, <&bt BT_SEL 0>; + }; + bt_select_1: bt_select_1 { + label = "BT_SELECT_1"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + bindings = <&out OUT_BLE>, <&bt BT_SEL 1>; + }; + bt_select_2: bt_select_2 { + label = "BT_SELECT_2"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + bindings = <&out OUT_BLE>, <&bt BT_SEL 2>; + }; + bt_select_3: bt_select_3 { + label = "BT_SELECT_3"; + compatible = "zmk,behavior-macro"; + #binding-cells = <0>; + bindings = <&out OUT_BLE>, <&bt BT_SEL 3>; + }; + }; +}; diff --git a/src/keys.dts b/src/keys.dts new file mode 100644 index 0000000..0d56686 --- /dev/null +++ b/src/keys.dts @@ -0,0 +1,5 @@ +#include "zmk-helpers/key-labels/glove80.h" + +#define KEYS_L LC1 LC2 LC3 LC4 LC5 LN0 LN1 LN2 LN3 LN4 LN5 LT0 LT1 LT2 LT3 LT4 LT5 LM0 LM1 LM2 LM3 LM4 LM5 LB0 LB1 LB2 LB3 LB4 LB5 LF1 LF2 LF3 LF4 LF5 +#define KEYS_R RC1 RC2 RC3 RC4 RC5 RN0 RN1 RN2 RN3 RN4 RN5 RT0 RT1 RT2 RT3 RT4 RT5 RM0 RM1 RM2 RM3 RM4 RM5 RB0 RB1 RB2 RB3 RB4 RB5 RF1 RF2 RF3 RF4 RF5 +#define THUMBS LH0 LH1 LH2 LH3 LH4 LH5 RH0 RH1 RH2 RH3 RH4 RH5 diff --git a/glove80.keymap b/src/main.dts similarity index 66% rename from glove80.keymap rename to src/main.dts index 9256ce2..cce64f5 100644 --- a/glove80.keymap +++ b/src/main.dts @@ -10,6 +10,9 @@ #define LAYER_Magic 2 #define LAYER_Gaming 3 +#include "keys.dts" +#include "defaults.dts" + / { underglow-layer { compatible = "zmk,underglow-layer"; @@ -86,121 +89,6 @@ }; }; -// key definitions -// https://github.com/urob/zmk-helpers/blob/main/include/zmk-helpers/key-labels/glove80.h -// Groups -#define KEYS_L LC1 LC2 LC3 LC4 LC5 LN0 LN1 LN2 LN3 LN4 LN5 LT0 LT1 LT2 LT3 LT4 LT5 LM0 LM1 LM2 LM3 LM4 LM5 LB0 LB1 LB2 LB3 LB4 LB5 LF1 LF2 LF3 LF4 LF5 -#define KEYS_R RC1 RC2 RC3 RC4 RC5 RN0 RN1 RN2 RN3 RN4 RN5 RT0 RT1 RT2 RT3 RT4 RT5 RM0 RM1 RM2 RM3 RM4 RM5 RB0 RB1 RB2 RB3 RB4 RB5 RF1 RF2 RF3 RF4 RF5 -#define THUMBS LH0 LH1 LH2 LH3 LH4 LH5 RH0 RH1 RH2 RH3 RH4 RH5 - -// left-ceiling row -#define LC1 4 -#define LC2 3 -#define LC3 2 -#define LC4 1 -#define LC5 0 - -// right-ceiling row -#define RC1 5 -#define RC2 6 -#define RC3 7 -#define RC4 8 -#define RC5 9 - -// left-number row -#define LN0 15 -#define LN1 14 -#define LN2 13 -#define LN3 12 -#define LN4 11 -#define LN5 10 - -// right-number row -#define RN0 16 -#define RN1 17 -#define RN2 18 -#define RN3 19 -#define RN4 20 -#define RN5 21 - -// left-top row -#define LT0 27 -#define LT1 26 -#define LT2 25 -#define LT3 24 -#define LT4 23 -#define LT5 22 - -// right-top row -#define RT0 28 -#define RT1 29 -#define RT2 30 -#define RT3 31 -#define RT4 32 -#define RT5 33 - -// left-middle row -#define LM0 39 -#define LM1 38 -#define LM2 37 -#define LM3 36 -#define LM4 35 -#define LM5 34 - -// right-middle row -#define RM0 40 -#define RM1 41 -#define RM2 42 -#define RM3 43 -#define RM4 44 -#define RM5 45 - -// left-bottom row -#define LB0 51 -#define LB1 50 -#define LB2 49 -#define LB3 48 -#define LB4 47 -#define LB5 46 - -// right-bottom row -#define RB0 58 -#define RB1 59 -#define RB2 60 -#define RB3 61 -#define RB4 62 -#define RB5 63 - -// left-floor row -#define LF1 68 -#define LF2 67 -#define LF3 66 -#define LF4 65 -#define LF5 64 - -// right-floor row -#define RF1 75 -#define RF2 76 -#define RF3 77 -#define RF4 78 -#define RF5 79 - -// left thumb keys -#define LH0 71 -#define LH1 70 -#define LH2 69 -#define LH3 54 -#define LH4 53 -#define LH5 52 - -// right thumb keys -#define RH0 72 -#define RH1 73 -#define RH2 74 -#define RH3 55 -#define RH4 56 -#define RH5 57 - // home row mods / { behaviors { @@ -228,100 +116,3 @@ }; }; }; - -// misc -/ { - behaviors { - lower: lower { - compatible = "zmk,behavior-tap-dance"; - label = "LAYER_TAP_DANCE"; - #binding-cells = <0>; - tapping-term-ms = <200>; - bindings = <&mo LAYER_Lower>, <&to LAYER_Lower>; - }; - }; -}; - -/ { - macros { - rgb_ug_status_macro: rgb_ug_status_macro { - label = "RGB_UG_STATUS"; - compatible = "zmk,behavior-macro"; - #binding-cells = <0>; - bindings = <&rgb_ug RGB_STATUS>; - }; - }; -}; - -/ { - behaviors { - magic: magic { - compatible = "zmk,behavior-hold-tap"; - label = "MAGIC_HOLD_TAP"; - #binding-cells = <2>; - flavor = "tap-preferred"; - tapping-term-ms = <200>; - bindings = <&mo>, <&rgb_ug_status_macro>; - }; - }; -}; - -// Bluetooth behaviors -/ { - behaviors { - bt_0: bt_0 { - compatible = "zmk,behavior-tap-dance"; - label = "BT_0"; - #binding-cells = <0>; - tapping-term-ms = <200>; - bindings = <&bt_select_0>, <&bt BT_DISC 0>; - }; - bt_1: bt_1 { - compatible = "zmk,behavior-tap-dance"; - label = "BT_1"; - #binding-cells = <0>; - tapping-term-ms = <200>; - bindings = <&bt_select_1>, <&bt BT_DISC 1>; - }; - bt_2: bt_2 { - compatible = "zmk,behavior-tap-dance"; - label = "BT_2"; - #binding-cells = <0>; - tapping-term-ms = <200>; - bindings = <&bt_select_2>, <&bt BT_DISC 2>; - }; - bt_3: bt_3 { - compatible = "zmk,behavior-tap-dance"; - label = "BT_3"; - #binding-cells = <0>; - tapping-term-ms = <200>; - bindings = <&bt_select_3>, <&bt BT_DISC 3>; - }; - }; - macros { - bt_select_0: bt_select_0 { - label = "BT_SELECT_0"; - compatible = "zmk,behavior-macro"; - #binding-cells = <0>; - bindings = <&out OUT_BLE>, <&bt BT_SEL 0>; - }; - bt_select_1: bt_select_1 { - label = "BT_SELECT_1"; - compatible = "zmk,behavior-macro"; - #binding-cells = <0>; - bindings = <&out OUT_BLE>, <&bt BT_SEL 1>; - }; - bt_select_2: bt_select_2 { - label = "BT_SELECT_2"; - compatible = "zmk,behavior-macro"; - #binding-cells = <0>; - bindings = <&out OUT_BLE>, <&bt BT_SEL 2>; - }; - bt_select_3: bt_select_3 { - label = "BT_SELECT_3"; - compatible = "zmk,behavior-macro"; - #binding-cells = <0>; - bindings = <&out OUT_BLE>, <&bt BT_SEL 3>; - }; - }; -};