Skip to content

Commit

Permalink
Moving BT control stuff to a dtsi to be included in multiple keymaps.
Browse files Browse the repository at this point in the history
  • Loading branch information
amacleod committed Sep 29, 2024
1 parent c3b0c61 commit aad1541
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 44 deletions.
24 changes: 0 additions & 24 deletions config/corne.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -269,30 +269,6 @@ combos {
};

macros {
// Select a specific Bluetooth profile and then toggle the
// keyboard control layer; this is intended to deactivate that layer
// when activated from within it.
btsel: bluetooth_select_and_toggle {
compatible = "zmk,behavior-macro-one-param";
#binding-cells = <1>;
bindings
= <&macro_param_1to2>
, <&bt BT_SEL MACRO_PLACEHOLDER>
, <&macro_pause_for_release>
, <&tog KEEBCTL>
;
};
// Clear a specific Bluetooth profile, relying on the &btsel macro to
// toggle the layer.
btclr: bluetooth_clear_and_toggle {
compatible = "zmk,behavior-macro-one-param";
#binding-cells = <1>;
bindings
= <&macro_param_1to1>
, <&btsel MACRO_PLACEHOLDER>
, <&bt BT_CLR>
;
};
};

behaviors {
Expand Down
62 changes: 62 additions & 0 deletions config/glam-util.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright (c) 2024 Allister MacLeod
*
* SPDX-License-Identifier: MIT
*/

// Devicetree include for sharing miscellaneous utility code between
// my various ZMK keymaps. Other .dtsi files in this directory have
// more specific themes:
// - glam-multigraph.dtsi is about character-sequence macros

// NOTE: Assumptions!
// This dtsi assumes that you will be including it from a file where
// there is a #define for the KEEBCTL layer number. This is needed so
// that the Bluetooth macros can toggle the keyboard control layer
// off after doing their thing.
// This dtsi must be included after the #define KEEBCTL line.

/ {

macros {
// Select a specific Bluetooth profile and then toggle the
// keyboard control layer; this is intended to deactivate that layer
// when activated from within it.
btsel: bluetooth_select_and_toggle {
compatible = "zmk,behavior-macro-one-param";
#binding-cells = <1>;
bindings
= <&macro_param_1to2>
, <&bt BT_SEL MACRO_PLACEHOLDER>
, <&macro_pause_for_release>
, <&tog KEEBCTL>
;
};
// Clear a specific Bluetooth profile, relying on the &btsel macro to
// toggle the layer.
btclr: bluetooth_clear_and_toggle {
compatible = "zmk,behavior-macro-one-param";
#binding-cells = <1>;
bindings
= <&macro_param_1to1>
, <&btsel MACRO_PLACEHOLDER>
, <&bt BT_CLR>
;
};
// Clear the current Bluetooth profile and toggle the keyboard
// control layer.
btcc: bluetooth_clear_current_and_toggle {
compatible = "zmk,behavior-macro";
#binding-cells = <0>;
bindings = <&bt BT_CLR>, <&tog KEEBCTL>;
};
// Clear all Bluetooth profiles and toggle the keyboard control
// layer.
btclall: bluetooth_clear_all_and_toggle {
compatible = "zmk,behavior-macro";
#binding-cells = <0>;
bindings = <&bt BT_CLR_ALL>, <&tog KEEBCTL>;
};
};

};
36 changes: 16 additions & 20 deletions config/zaphod_lite.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include "zmk-helpers/helper.h"
#include "zmk-helpers/key-labels/34.h"

#include "glam-multigraph.dtsi"

// Zaphod Lite keymap.

// Refactoring thougts:
Expand All @@ -29,6 +27,7 @@
// - finish making the mod-morphs for shifted punctuation in HDNEU layer
// - "smart" semi-layers: smart nav stays in arrows and nav until non-nav pressed, for example
// - other smarts: numeric, caps
// - move backspace to a mod-morph of space, freeing up RH1 as a layer control key

#define DEFAULT 0
#define HDNEU 0
Expand All @@ -37,6 +36,11 @@
#define NUMPAD 3
#define KEEBCTL 4

// These includes (well, just glam-util) need to be after the layer
// defines, specifically the one for KEEBCTL.
#include "glam-multigraph.dtsi"
#include "glam-util.dtsi"

// Placeholder for unused parameters.
#define UNUSED 0

Expand Down Expand Up @@ -170,13 +174,13 @@ combos {
combo_thumbs_keyboard_control {
timeout-ms = <50>;
key-positions = <LH1 LH0 RH0 RH1>;
bindings = <&sll KEEBCTL>;
bindings = <&tog KEEBCTL>;
};
// Right hand index and ring fingers for BT_CLR_ALL but only on KEEBCTL layer.
combo_midright_bt_clear_all {
combo_bt_clear_all {
timeout-ms = <50>;
key-positions = <RM1 RM2>;
bindings = <&bt BT_CLR_ALL>;
key-positions = <RB1 RB2>;
bindings = <&btclall>;
layers = <KEEBCTL>;
};
// Top and bottom keys on both innermost columns to enter flashing
Expand All @@ -199,14 +203,6 @@ behaviors {
bindings = <&kp HASH>, <&kp AT>;
mods = <(MOD_LSFT|MOD_RSFT)>;
};
// Long duration sticky layer.
sll: sticky_layer_long {
compatible = "zmk,behavior-sticky-key";
#binding-cells = <1>;
release-after-ms = <8000>;
bindings = <&mo>;
quick-release;
};
};

keymap {
Expand Down Expand Up @@ -273,14 +269,14 @@ keymap {
// Bluetooth clear-all on right hand index and ring finger combo.
// ,-----------------------------. ,-----------------------------.
// | | | | | | | | | | | |
// | BT1 | BT2 | BT3 | BT4 | BT5 | | Clr | Clr-All | | |
// | | | | | | | | | | | |
// `-----------------| | | | | |-----------------'
// | BT1 | BT2 | BT3 | BT4 | BT5 | |ClCur| Clear All | |
// `-----------------| | | |Base | |-----------------'
bindings = <
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &bt BT_CLR &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&btsel 0 &btsel 1 &btsel 2 &btsel 3 &btsel 4 &btcc &trans &trans &trans &trans
&trans &trans &tog KEEBCTL &trans
>;
display-name = "KBDCTL";
};
Expand Down

0 comments on commit aad1541

Please sign in to comment.