urob / zmk-helpers

Convenience macros simplifying ZMK's keymap configuration
MIT License
235 stars 79 forks source link

Unicode pair using correct OS setting mistakenly uses Alt-codes method #35

Closed arilebedey closed 7 months ago

arilebedey commented 7 months ago

Working from this repo (https://github.com/urob/zmk-config) and trying to use unicode pair functions through my Glove80, I followed the instructions and set the correct OS in base.keymap as such:

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

#define HOST_OS 1 // Linux
#include "../zmk-nodefree-config/helper.h"
#include "../zmk-nodefree-config/international_chars/greek.dtsi"

But upon pressing one of the keys with the greek letters, this is what gets inputted by my keyboard (as recorded by xev):

108 Alt_R
30  u
19  0
12  3
54  c
16  7
36  Return

This looks like the correct way to input unicode using Alt-codes, so perhaps the OS setting isn't being read?

urob commented 7 months ago

The snippet you gave should be correct. Running

#define HOST_OS 1 // Linux
#include "../zmk-nodefree-config/helper.h"
#include "../zmk-nodefree-config/international_chars/greek.dtsi"

through the preprocessor, yields:

/ { macros { el_sigma_lower: el_sigma_lower { compatible = "zmk,behavior-macro"; label = "UC_MACRO_el_sigma_lower"; wait-ms = <0>; tap-ms = <0>; #binding-cells = <0>; bindings = <&macro_tap &kp LS(LC(U))>, <&macro_tap &kp N0 &kp N3 &kp C &kp N3>, <&macro_tap &kp SPACE>; }; }; }; / { macros { el_sigma_upper: el_sigma_upper { compatible = "zmk,behavior-macro"; label = "UC_MACRO_el_sigma_upper"; wait-ms = <0>; tap-ms = <0>; #binding-cells = <0>; bindings = <&macro_tap &kp LS(LC(U))>, <&macro_tap &kp N0 &kp N3 &kp A &kp N3>, <&macro_tap &kp SPACE>; }; }; }; / { behaviors { el_sigma: el_sigma { compatible = "zmk,behavior-mod-morph"; label = "UC_MORPH_el_sigma"; #binding-cells = <0>; bindings = <&el_sigma_lower>, <&el_sigma_upper>; mods = <(MOD_LSFT|MOD_RSFT)>; }; }; };
// ...

That is, each macro binding expands to something like this:

<&macro_tap &kp LS(LC(U))>, <&macro_tap &kp N0 &kp N3 &kp C &kp N3>, <&macro_tap &kp SPACE>;

Some common issues worth double-checking:

arilebedey commented 7 months ago

Bingo! Thank you for your help.