Skip to content

nguyendown/zmk-behavior-socd

Repository files navigation

SOCD Behavior

SOCD cleaner for ZMK.

Build

See Building With Modules.

Edit zmk-config/config/west.yml.

manifest:
  remotes:
    - name: zmkfirmware
      url-base: https://github.com/zmkfirmware
+    - name: nguyendown
+      url-base: https://github.com/nguyendown
  projects:
    - name: zmk
      remote: zmkfirmware
      revision: main
      import: app/west.yml
+    - name: zmk-behavior-socd
+      remote: nguyendown
+      revision: main
  self:
    path: config

Keymap

&socd is the default SOCD instance. It is Last Input Priority (LIP) and uses key press binding &kp.

Add this to .keymap to use &socd.

#include <behaviors.dtsi>
+#include <behaviors/socd.dtsi>
#include <dt-bindings/zmk/keys.h>

The following keymap prevents A and D from overlapping each other.

/ {
    keymap {
        default_layer {
            bindings = <
                &kp   Q &kp W &kp   E
                &socd A &kp S &socd D>;
        };
    };
};

For W and S, create a new SOCD instance. See Multiple instances

Config

first-input-priority

When first-input-priority is set, SOCD behavior will switch to First Input Priority (FIP).

&socd {
    first-input-priority;
};

/ {
    keymap {
        ...
    };
};

absolute-priority

The following example gives &socd A absolute priority.

&socd {
    absolute-priority = <A>;
};

no-resume

When no-resume is set, SOCD behavior will not resume the remaining pressed key.

neutral

When neutral is set, pressing two keys at the same time results in no input being registered.

This also overrides all the properties mentioned above. The behavior does not prioritize any input, whether it is FIP, LIP or absolute priority. The remaining pressed key always resumes even if no-resume is set.

Multiple instances

The following example creates a new SOCD instance that works separately from the default &socd.

/ {
    behaviors {
        socd2: socd2 {
            compatible = "zmk,behavior-socd";
            #binding-cells = <1>;
            bindings = <&kp>;
        };
    };

    keymap {
        default_layer {
            bindings = <
                &kp   Q &socd2 W &kp   E
                &socd A &socd2 S &socd D>;
        };
    };
};

Test

cd /path/to/zmk/app
ZMK_EXTRA_MODULES="/path/to/zmk-behavior-socd" west test /path/to/zmk-behavior-socd/tests

For a specific test case.

ZMK_EXTRA_MODULES="/path/to/zmk-behavior-socd" west test /path/to/zmk-behavior-socd/tests/socd/last-input-priority

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published