miryoku_zmk/miryoku/miryoku-zmk.org
2022-06-02 16:03:50 +10:00

1191 lines
36 KiB
Org Mode

# After making changes to code or tables call org-babel-tangle (C-c C-v t).
#+Title: Miryoku ZMK [[https://raw.githubusercontent.com/manna-harbour/miryoku/master/data/logos/miryoku-roa-32.png]]
[[https://raw.githubusercontent.com/manna-harbour/miryoku/master/data/cover/miryoku-kle-cover.png]]
Miryoku is an ergonomic, minimal, orthogonal, universal keyboard layout.
Miryoku ZMK is the miryoku implemention for [[https://zmkfirmware.dev/][ZMK
Firmware]], a wireless keyboard firmware built on the Zephyr RTOS.
*For miryoku documentation and other implementations see
[[https://github.com/manna-harbour/miryoku/blob/master/README.org][github.com/manna-harbour/miryoku]].*
* Contents :TOC_3:
- [[#status][Status]]
- [[#todo][Todo]]
- [[#integrate-with-zephyr-cmake][Integrate with Zephyr CMake]]
- [[#add-mappings-for-all-boards--shields-in-zmk][Add mappings for all boards / shields in ZMK]]
- [[#layers][Layers]]
- [[#base-base][Base (~BASE~)]]
- [[#tap][Tap]]
- [[#hold][Hold]]
- [[#navigation-navr][Navigation (~NAVR~)]]
- [[#mouse-mour][Mouse (~MOUR~)]]
- [[#mouse-buttons-overlay-mbo][Mouse Buttons Overlay (~MBO~)]]
- [[#media-medr][Media (~MEDR~)]]
- [[#numerals-and-symbols-nsl][Numerals and Symbols (~NSL~)]]
- [[#shifted-numerals-and-symbols-nssl][Shifted Numerals and Symbols (~NSSL~)]]
- [[#function-and-system-funl][Function and System (~FUNL~)]]
- [[#alternative-layouts][Alternative Layouts]]
- [[#base-layer-alphas][Base Layer Alphas]]
- [[#vi-style-navigation][vi-Style Navigation]]
- [[#navigation-layer-clipboard-keys][Navigation Layer Clipboard Keys]]
- [[#code-generation][Code Generation]]
- [[#table-conversion-scripts][Table Conversion Scripts]]
- [[#table-map-taphold][table-map-taphold]]
- [[#table-map-half][table-map-half]]
- [[#table-map-full][table-map-full]]
- [[#table-layer-defines][table-layer-defines]]
- [[#table-keycode-mappings][table-keycode-mappings]]
- [[#data][Data]]
- [[#layers-1][layers]]
- [[#symbol-names][symbol-names]]
- [[#mods][mods]]
- [[#nonkp][nonkp]]
- [[#keycode-translation][keycode-translation]]
- [[#header][header]]
- [[#subset-mapping][Subset Mapping]]
- [[#mappings][mappings]]
- [[#split_3x5_3h][[[split_3x5_3.h]]]]
- [[#split_3x6_3h][[[split_3x6_3.h]]]]
- [[#ortho_4x12h][[[ortho_4x12.h]]]]
- [[#miryoku-include][miryoku include]]
- [[#miryokudtsi][[[miryoku.dtsi]]]]
- [[#documentation][Documentation]]
- [[#contact][Contact]]
* Status
Welcome to the alpha of miryoku ZMK!
You've been added as a collaborator to the repo as it's the easiest way to give
access. You're not expected to contribute but contributions are welcome. In
that case please create a new branch and PR. Otherwise, if you could avoid
accidental force pushes to master that'd be great! Please don't redistribute as
it's only the alpha version.
Just a bit of an explanation of the current status: I'm doing a miryoku
reorganisation at the moment. The general layout docs will move out of the QMK
repo and get expanded. The org stuff will also move and will generate QMK, ZMK,
and KMonad. At the moment the org stuff in ZMK is separate until I finalise the
scripts and re-integrate the changes, so it's a bit of a mess right now but the
generated keymap shouldn't change much.
** Todo
*** TODO Integrate with Zephyr CMake
Support passing configuration options. For now, add the equivalent ~#define~ to
your keymap before the includes, e.g. for ~MIRYOKU_ALPHAS=QWERTY~ add ~#define
MIRYOKU_ALPHAS_QWERTY~.
*** TODO Add mappings for all boards / shields in ZMK
#+TODO: TODO | DONE NA
https://github.com/zmkfirmware/zmk/tree/main/app/boards/shields
**** TODO bfo9000
split_6x9
**** NA boardsource3x4
**** NA clueboard_california
**** DONE corne
split_3x6_3
**** TODO cradio
split_3x5_2
**** DONE crbn
ortho_4x12
**** DONE eek
split_3x5_3
**** TODO ferris
split_3x5_2
**** TODO helix
helix
**** TODO iris
iris
**** TODO jian
jian
**** TODO jorne
jorne
**** TODO kyria
kyria
**** TODO lily58
lily58
**** TODO m60
60_ansi
**** DONE microdox
split_3x5_3
**** TODO nibble
**** NA qaz
**** TODO quefrency
**** TODO reviung41
**** NA romac
**** NA romac_plus
**** TODO sofle
sofle
**** TODO splitreus62
**** TODO tg4x
**** NA tidbit
* Layers
The layers are maintained in tables, with the thumb keys on the bottom row.
~U_NP~ indicates the key is not present and is used to fill in the table around
the thumb keys. The grid arrangement of the tables does not imply a particular
physical layout.
Basic keycodes are entered without the ~KC_~ prefix. Symbols can be entered
as-is, except for '-' (~MINS~), '.' (~DOT~), '|' (~PIPE~), and '"' (~DQUO~).
Empty cells are unused.
The base layer has both halves of the layout joined for convenience. Other
layers are specified as a single hand.
** Base (~BASE~)
The base layer is maintained as separate tap and hold tables and are combined
into the corresponding tap-hold keycodes for mods and layer change. Mods (and
reset) will be available on sub layers on the same hand as the layer change
thumb key. Unknown names are considered to be layer names.
Base layer alphas are Colemak-DHm. Thumb keys are backspace, enter, delete on
the right and space, tab, escape on the left. Dot, comma and apostrophe are
included for prose, dot and slash for file and directory names.
*** Tap
#+NAME: colemakdhm
| Q | W | F | P | B | J | L | U | Y | ' |
| A | R | S | T | G | M | N | E | I | O |
| Z | X | C | D | V | K | H | , | DOT | / |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
*** Hold
#+NAME: hold
| RESET | DF(TAP) | | | | | | | DF(TAP) | RESET |
| LGUI | LALT | LCTL | LSFT | | | LSFT | LCTL | LALT | LGUI |
| | ALGR | | | | | | | ALGR | |
| U_NP | U_NP | MEDR | NAVR | MOUR | NSSL | NSL | FUNL | U_NP | U_NP |
** Navigation (~NAVR~)
Primary right-hand layer (left home thumb) is navigation and editing. Cursor
keys are on the home position, line and page movement below, clipboard above,
caps lock and insert on the inner column. Thumb keys are duplicated from the
base layer to avoid having to layer change mid edit and to enable auto-repeat.
#+NAME: navr
| U_RDO | U_PST | U_CPY | U_CUT | U_UND |
| CAPS | LEFT | DOWN | UP | RGHT |
| INS | HOME | PGDN | PGUP | END |
| ENT | BSPC | DEL | U_NP | U_NP |
** Mouse (~MOUR~)
Secondary right-hand layer is mouse emulation. Mouse movement mirrors cursor
navigation on home and wheel mirrors line / page movement below. Buttons are on
the thumbs (L, M, R). Mouse movement, click, and drag with modifiers can be
performed from the home position. Unused keys are available for other related
functions.
#+NAME: mour
| | | | | |
| | MS_L | MS_D | MS_U | MS_R |
| | WH_L | WH_D | WH_U | WH_R |
| BTN1 | BTN3 | BTN2 | U_NP | U_NP |
*** Mouse Buttons Overlay (~MBO~)
Available for automatic activation depending on keyboard hardware and
configuration. Not activated manually.
#+NAME: mbo
| | | | | | | | | | |
| | | | | | | | | | |
| | | | | | | | | | |
| U_NP | U_NP | | | | BTN1 | BTN3 | BTN2 | U_NP | U_NP |
** Media (~MEDR~)
Tertiary right-hand layer is media control, with volume up / down and next /
prev mirroring the navigation keys. Pause, stop and mute are on thumbs. RGB
control is on the top row (combine with shift to invert). BT control is on the
bottom row, and USB / BT output toggle on the home row inner index.
#+NAME: medr
| RGB_TOG | RGB_MOD | RGB_HUI | RGB_SAI | RGB_VAI |
| &out OUT_TOG | MPRV | VOLD | VOLU | MNXT |
| &bt BT_CLR | &bt BT_SEL 0 | &bt BT_SEL 1 | &bt BT_SEL 2 | &bt BT_SEL 3 |
| MSTP | MPLY | MUTE | U_NP | U_NP |
** Numerals and Symbols (~NSL~)
Primary left-hand layer (right home thumb) is numerals and symbols. Numerals
are in the standard numpad locations with symbols in the remaining positions.
Dot is duplicated from the base layer.
#+NAME: nsl
| [ | 7 | 8 | 9 | ] |
| ; | 4 | 5 | 6 | = |
| ` | 1 | 2 | 3 | \ |
| U_NP | U_NP | DOT | 0 | MINS |
** Shifted Numerals and Symbols (~NSSL~)
Secondary left-hand layer has shifted symbols in the same locations to reduce
chording when using mods with shifted symbols. Open parenthesis is duplicated
next to close parenthesis.
#+NAME: nssl
| { | & | * | ( | } |
| : | $ | % | ^ | + |
| ~ | ! | @ | # | PIPE |
| U_NP | U_NP | ( | ) | _ |
** Function and System (~FUNL~)
Tertiary left-hand layer has function keys mirroring the numerals on the primary
layer with extras on the pinkie column, plus system keys on the inner column.
App (menu) is on the tertiary thumb key and other thumb keys are duplicated from
the base layer to enable auto-repeat.
#+NAME: funl
| F12 | F7 | F8 | F9 | PSCR |
| F11 | F4 | F5 | F6 | SLCK |
| F10 | F1 | F2 | F3 | PAUS |
| U_NP | U_NP | APP | SPC | TAB |
** Alternative Layouts
The defaults are recommended, but alternative layouts are provided to
accommodate existing muscle memory.
*** Base Layer Alphas
To select, append the corresponding option to the ~make~ command line when
building, e.g. ~MIRYOKU_ALPHAS=QWERTY~.
**** Colemak
~MIRYOKU_ALPHAS=COLEMAK~
#+NAME: colemak
| Q | W | F | P | G | J | L | U | Y | ' |
| A | R | S | T | D | H | N | E | I | O |
| Z | X | C | V | B | K | M | , | DOT | / |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
**** Colemak Mod-DH
~MIRYOKU_ALPHAS=COLEMAKDH~
#+NAME: colemakdh
| Q | W | F | P | B | J | L | U | Y | ' |
| A | R | S | T | G | K | N | E | I | O |
| Z | X | C | D | V | M | H | , | DOT | / |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
**** Dvorak
~MIRYOKU_ALPHAS=DVORAK~
#+NAME: dvorak
| ' | , | DOT | P | Y | F | G | C | R | L |
| A | O | E | U | I | D | H | T | N | S |
| / | Q | J | K | X | B | M | W | V | Z |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
**** Halmak
~MIRYOKU_ALPHAS=HALMAK~
#+NAME: halmak
| W | L | R | B | Z | ' | Q | U | D | J |
| S | H | N | T | , | DOT | A | E | O | I |
| F | M | V | C | / | G | P | X | K | Y |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
**** Workman
~MIRYOKU_ALPHAS=WORKMAN~
#+NAME: workman
| Q | D | R | W | B | J | F | U | P | ' |
| A | S | H | T | G | Y | N | E | O | I |
| Z | X | M | C | V | K | L | , | DOT | / |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
**** QWERTY
~MIRYOKU_ALPHAS=QWERTY~
#+NAME: qwerty
| Q | W | E | R | T | Y | U | I | O | P |
| A | S | D | F | G | H | J | K | L | ' |
| Z | X | C | V | B | N | M | , | DOT | / |
| U_NP | U_NP | ESC | SPC | TAB | ENT | BSPC | DEL | U_NP | U_NP |
*** vi-Style Navigation
To select, append ~MIRYOKU_NAV=VI~ to the ~make~ command line when building.
**** Navigation (NAVR)
#+NAME: navr-vi
| U_RDO | U_PST | U_CPY | U_CUT | U_UND |
| LEFT | DOWN | UP | RGHT | CAPS |
| HOME | PGDN | PGUP | END | INS |
| ENT | BSPC | DEL | U_NP | U_NP |
**** Mouse (MOUR)
#+NAME: mour-vi
| | | | | |
| MS_L | MS_D | MS_U | MS_R | |
| WH_L | WH_D | WH_U | WH_R | |
| BTN1 | BTN3 | BTN2 | U_NP | U_NP |
**** Media (MEDR)
#+NAME: medr-vi
| RGB_MOD | RGB_HUI | RGB_SAI | RGB_VAI | RGB_TOG |
| MPRV | VOLD | VOLU | MNXT | &out OUT_TOG |
| &bt BT_SEL 0 | &bt BT_SEL 1 | &bt BT_SEL 2 | &bt BT_SEL 3 | &bt BT_CLR |
| MSTP | MPLY | MUTE | U_NP | U_NP |
*** Navigation Layer Clipboard Keys
Keycodes are translated from those used in the Navigation layer tables according
to the following tables.
By default, the main clipboard keys (cut, copy, and paste) use the CUA bindings
and should work in general unix and windows applications, emacs, and terminal
emulators (paste only). The additional keys (undo, redo) usually require
rebinding in the application.
To select, append the corresponding option to the ~make~ command line when
building, e.g. ~MIRYOKU_CLIPBOARD=WIN~.
**** Default
#+NAME: clipboard
| U_RDO | AGIN |
| U_PST | S(KC_INS) |
| U_CPY | C(KC_INS) |
| U_CUT | S(KC_DEL) |
| U_UND | UNDO |
**** Fun Cluster
~MIRYOKU_CLIPBOARD=FUN~
#+NAME: clipboard-fun
| U_RDO | AGIN |
| U_PST | PSTE |
| U_CPY | COPY |
| U_CUT | CUT |
| U_UND | UNDO |
**** Mac
~MIRYOKU_CLIPBOARD=MAC~
#+NAME: clipboard-mac
| U_RDO | SCMD(KC_Z) |
| U_PST | LCMD(KC_V) |
| U_CPY | LCMD(KC_C) |
| U_CUT | LCMD(KC_X) |
| U_UND | LCMD(KC_Z) |
**** Windows
~MIRYOKU_CLIPBOARD=WIN~
#+NAME: clipboard-win
| U_RDO | C(KC_Y) |
| U_PST | C(KC_V) |
| U_CPY | C(KC_C) |
| U_CUT | C(KC_X) |
| U_UND | C(KC_Z) |
** COMMENT Templates
#+NAME: tem
| <l4> | <l4> | <l4> | <l4> | <l4> | <l4> | <l4> | <l4> | <l4> | <l4> |
|------+------+------+------+------+------+------+------+------+------|
| | | | | | | | | | |
| | | | | | | | | | |
| | | | | | | | | | |
| U_NP | U_NP | | | | | | | U_NP | U_NP |
Duplicate base layer tap keys on thumbs rather than trans to enable auto-repeat.
#+NAME: temr
| <l4> | <l4> | <l4> | <l4> | <l4> |
|------+------+------+------+------|
| | | | | |
| | | | | |
| | | | | |
| ENT | BSPC | DEL | U_NP | U_NP |
#+NAME: teml
| <l4> | <l4> | <l4> | <l4> | <l4> |
|------+------+------+------+------|
| | | | | |
| | | | | |
| | | | | |
| U_NP | U_NP | ESC | SPC | TAB |
* Code Generation
** Table Conversion Scripts
*** table-map-taphold
Produce base layer from separate tap and hold tables.
#+NAME: table-map-taphold
#+BEGIN_SRC python :var tap_table=colemakdhm :var hold_table=hold :var symbol_names_table=symbol-names :var mods_table=mods :var nonkp_table=nonkp :var layers_table=layers :var keycode_translation_table=keycode-translation :tangle no :results verbatim
width = 14
mods_dict = dict.fromkeys(mods_table[0])
nonkp_tuple = tuple(nonkp_table[0])
layers_dict = dict.fromkeys(layers_table[0])
symbol_names_dict = {}
for symbol, name, shifted_symbol, shifted_name in symbol_names_table:
symbol_names_dict[symbol] = name
symbol_names_dict[shifted_symbol] = shifted_name
keycode_translation_dict = {}
for standard, local in keycode_translation_table:
if local != '':
keycode_translation_dict[standard] = local
results = ''
for tap_row, hold_row in map(None, tap_table, hold_table):
for tap, hold in map(None, tap_row, hold_row):
if tap == '':
code = 'U_NU'
elif tap in symbol_names_dict:
code = symbol_names_dict[tap]
else:
code = tap
if code in keycode_translation_dict:
code = keycode_translation_dict[code]
if hold in mods_dict:
if hold in keycode_translation_dict:
hold = keycode_translation_dict[hold]
code = '&hm ' + str(hold) + ' ' + code
elif hold in layers_dict:
code = '&lt ' + str(hold) + ' ' + code
elif not str(code).startswith(nonkp_tuple):
code = '&kp ' + str(code)
results += (code + ', ').ljust(width)
results = results.rstrip(' ') + '\n'
results = results.rstrip('\n, ')
return results
#+END_SRC
#+RESULTS: table-map-taphold
: &kp Q, &kp W, &kp F, &kp P, &kp B, &kp J, &kp L, &kp U, &kp Y, &kp SQT,
: &hm LGUI A, &hm LALT R, &hm LCTRL S, &hm LSHFT T, &kp G, &kp M, &hm LSHFT N, &hm LCTRL E, &hm LALT I, &hm LGUI O,
: &kp Z, &hm RALT X, &kp C, &kp D, &kp V, &kp K, &kp H, &kp COMMA, &hm RALT DOT, &kp SLASH,
: U_NP, U_NP, &lt MEDR ESC, &lt NAVR SPC, &lt MOUR TAB, &lt NSSL RET, &lt NSL BSPC, &lt FUNL DEL, U_NP, U_NP
*** table-map-half
Produce sub layers given layer name and corresponding table for single hand and
incorporating mods and reset from base layer. Layer names must end with 'R' or
'L'. A layer with shifted symbols can also be generated.
#+NAME: table-map-half
#+BEGIN_SRC python :var hold_table=hold :var mode="r" :var half_table=navr :var symbol_names_table=symbol-names :var mods_table=mods :var nonkp_table=nonkp :var shift="false" :var layers_table=layers :var keycode_translation_table=keycode-translation :tangle no :results verbatim
width = 13
mods_dict = dict.fromkeys(mods_table[0])
layers_dict = dict.fromkeys(layers_table[0])
nonkp_tuple = tuple(nonkp_table[0])
symbol_names_dict = {}
shifted_symbol_names_dict = {}
for symbol, name, shifted_symbol, shifted_name in symbol_names_table:
symbol_names_dict[symbol] = name
symbol_names_dict[shifted_symbol] = shifted_name
shifted_symbol_names_dict[symbol] = shifted_name
keycode_translation_dict = {}
for standard, local in keycode_translation_table:
if local != '':
keycode_translation_dict[standard] = local
length = len(half_table[0])
results = ''
for half_row, hold_row in map(None, half_table, hold_table):
hold_row_l, hold_row_r = hold_row[:length], hold_row[length:]
for lr, hold_row_lr in ('l', hold_row_l), ('r', hold_row_r):
if lr == mode:
for half in half_row:
if half == '':
code = 'U_NU'
elif shift == "true" and half in shifted_symbol_names_dict:
code = shifted_symbol_names_dict[half]
elif half in symbol_names_dict:
code = symbol_names_dict[half]
else:
code = half
if code in keycode_translation_dict:
code = keycode_translation_dict[code]
if not str(code).startswith(nonkp_tuple):
code = '&kp ' + str(code)
results += (str(code) + ', ').ljust(width)
else:
for hold in hold_row_lr:
if hold in mods_dict:
if hold in keycode_translation_dict:
hold = keycode_translation_dict[hold]
code = '&kp ' + str(hold)
else:
if hold in keycode_translation_dict:
hold = keycode_translation_dict[hold]
if hold == '' or hold in layers_dict:
code = 'U_NA'
elif str(hold).startswith(nonkp_tuple):
code = hold
else:
code = '&kp ' + str(hold)
results += (str(code) + ', ').ljust(width)
results = results.rstrip(' ') + '\n'
results = results.rstrip('\n, ')
return results
#+END_SRC
#+RESULTS: table-map-half
: &bootloader, U_NA, U_NA, U_NA, U_NA, &kp K_AGAIN, &kp K_UNDO, &kp K_CUT, &kp K_COPY, &kp K_PASTE,
: &kp LGUI, &kp LALT, &kp LCTRL, &kp LSHFT, U_NA, &kp CAPS, &kp LEFT, &kp DOWN, &kp UP, &kp RIGHT,
: U_NA, &kp RALT, U_NA, U_NA, U_NA, &kp INS, &kp HOME, &kp PG_DN, &kp PG_UP, &kp END,
: U_NP, U_NP, U_NA, U_NA, U_NA, &kp RET, &kp BSPC, &kp DEL, U_NP, U_NP
*** table-map-full
Produce full layer from single table. Fill for unused keys is configurable.
#+NAME: table-map-full
#+BEGIN_SRC python :var table=mbo :var fill="&trans" :var symbol_names_table=symbol-names :var nonkp_table=nonkp :var keycode_translation_table=keycode-translation :tangle no :results verbatim
width = 10
symbol_names_dict = {}
nonkp_tuple = tuple(nonkp_table[0])
for symbol, name, shifted_symbol, shifted_name in symbol_names_table:
symbol_names_dict[symbol] = name
symbol_names_dict[shifted_symbol] = shifted_name
keycode_translation_dict = {}
for standard, local in keycode_translation_table:
if local != '':
keycode_translation_dict[standard] = local
results = ''
for row in table:
for key in row:
if key == '':
code = fill
elif key in symbol_names_dict:
code = symbol_names_dict[key]
else:
code = key
if code in keycode_translation_dict:
code = keycode_translation_dict[code]
if not str(code).startswith(nonkp_tuple):
code = '&kp ' + str(code)
results += (code + ', ').ljust(width)
results = results.rstrip(' ') + '\n'
results = results.rstrip('\n, ')
return results
#+END_SRC
#+RESULTS: table-map-full
: &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,
: U_NP, U_NP, &trans, &trans, &trans, U_NU, U_NU, U_NU, U_NP, U_NP
*** table-layer-defines
Produce layer defines from layer names in hold table.
#+NAME: table-layer-defines
#+BEGIN_SRC python :var layers_table=layers :tangle no
width = 5
layers_list = layers_table[0]
results = ''
i = 0
for layer in layers_list:
results += '#define ' + ( layer + ' ').ljust(width) + str(i) + '\n'
i += 1
return results
#+END_SRC
#+RESULTS: table-layer-defines
: #define BASE 0
: #define MBO 1
: #define NAVR 2
: #define MOUR 3
: #define MEDR 4
: #define NSL 5
: #define NSSL 6
: #define FUNL 7
*** table-keycode-mappings
#+NAME: table-keycode-mappings
#+BEGIN_SRC python :var table=clipboard :var symbol_names_table=symbol-names :var nonkp_table=nonkp :var keycode_translation_table=keycode-translation :tangle no
nonkp_tuple = tuple(nonkp_table[0])
symbol_names_dict = {}
for symbol, name, shifted_symbol, shifted_name in symbol_names_table:
symbol_names_dict[symbol] = name
symbol_names_dict[shifted_symbol] = shifted_name
results = ''
keycode_translation_dict = {}
for standard, local in keycode_translation_table:
if local != '':
keycode_translation_dict[standard] = local
for f,t in table:
if t == '':
code = 'U_NU'
elif t in symbol_names_dict:
code = symbol_names_dict[t]
else:
code = t
if code in keycode_translation_dict:
code = keycode_translation_dict[code]
if not str(code).startswith(nonkp_tuple):
code = '&kp ' + str(code)
results += '#define ' + f + ' ' + code + '\n'
return results
#+END_SRC
#+RESULTS: table-keycode-mappings
: #define U_RDO &kp K_AGAIN
: #define U_PST &kp LS(INS)
: #define U_CPY &kp LC(INS)
: #define U_CUT &kp S(DEL)
: #define U_UND &kp K_UNDO
** Data
*** layers
#+NAME: layers
| BASE | TAP | MBO | NAVR | MOUR | MEDR | NSL | NSSL | FUNL |
*** symbol-names
Symbol, name, and shifted symbol mappings for use in tables.
#+NAME: symbol-names
| ` | GRV | ~ | TILD |
| "-" | MINS | _ | UNDS |
| = | EQL | + | PLUS |
| [ | LBRC | { | LCBR |
| ] | RBRC | } | RCBR |
| \ | BSLS | PIPE | PIPE |
| ; | SCLN | : | COLN |
| ' | QUOT | DQUO | DQUO |
| , | COMM | < | LT |
| "." | DOT | > | GT |
| / | SLSH | ? | QUES |
| 1 | 1 | ! | EXLM |
| 2 | 2 | @ | AT |
| 3 | 3 | # | HASH |
| 4 | 4 | $ | DLR |
| 5 | 5 | % | PERC |
| 6 | 6 | ^ | CIRC |
| 7 | 7 | & | AMPR |
| 8 | 8 | * | ASTR |
| 9 | 9 | ( | LPRN |
| 0 | 0 | ) | RPRN |
*** mods
Modifiers usable in hold table. Need to have the same name for ~KC_~ and ~_T~
versions.
#+NAME: mods
| LSFT | LCTL | LALT | LGUI | ALGR |
*** nonkp
Keycodes that match any of these prefixes will not have ~KC_~ automatically
prepended.
#+NAME: nonkp
| U_ | & |
*** keycode-translation
standard keycode to implementation equivalent
#+NAME: keycode-translation
| 0 | NUM_0 |
| 1 | NUM_1 |
| 2 | NUM_2 |
| 3 | NUM_3 |
| 4 | NUM_4 |
| 5 | NUM_5 |
| 6 | NUM_6 |
| 7 | NUM_7 |
| 8 | NUM_8 |
| 9 | NUM_9 |
| AGIN | K_AGAIN |
| ALGR | RALT |
| AMPR | AMPS |
| APP | K_APP |
| ASTR | ASTRK |
| AT | AT |
| BSLS | BSLH |
| BSPC | BSPC |
| BTN1 | KP_SLASH |
| BTN2 | U_NU |
| BTN3 | U_NU |
| CAPS | |
| CIRC | CRRT |
| COLN | COLON |
| COMM | COMMA |
| COPY | K_COPY |
| CUT | K_CUT |
| DEL | |
| DLR | DLLR |
| DOT | |
| DOWN | |
| DQUO | DQT |
| END | |
| ENT | RET |
| EQL | |
| ESC | |
| EXLM | EXCL |
| F1 | |
| F10 | |
| F11 | |
| F12 | |
| F2 | |
| F3 | |
| F4 | |
| F5 | |
| F6 | |
| F7 | |
| F8 | |
| F9 | |
| GRV | GRAVE |
| GT | |
| HASH | |
| HOME | |
| INS | |
| LALT | |
| LBRC | LBKT |
| LCBR | LBRC |
| LCTL | LCTRL |
| LEFT | |
| LGUI | |
| LPRN | LPAR |
| LSFT | LSHFT |
| LT | |
| MINS | MINUS |
| MNXT | K_NEXT |
| MPLY | K_PP |
| MPRV | K_PREV |
| MS_D | KP_N2 |
| MS_L | KP_N4 |
| MS_R | KP_N6 |
| MSTP | K_STOP2 |
| MS_U | KP_N8 |
| MUTE | K_MUTE |
| PAUS | PAUSE_BREAK |
| PERC | PRCT |
| PGDN | PG_DN |
| PGUP | PG_UP |
| PIPE | |
| PLUS | |
| PSCR | PSCRN |
| PSTE | K_PASTE |
| QUES | QMARK |
| QUOT | SQT |
| RBRC | RBKT |
| RCBR | RBRC |
| RESET | &bootloader |
| RGB_HUI | &rgb_ug RGB_HUI |
| RGB_MOD | &rgb_ug RGB_EFF |
| RGB_SAI | &rgb_ug RGB_SAI |
| RGB_TOG | &rgb_ug RGB_TOG |
| RGB_VAI | &rgb_ug RGB_BRI |
| RGHT | RIGHT |
| RPRN | RPAR |
| SCLN | SEMI |
| SLCK | |
| SLSH | SLASH |
| SPC | |
| TAB | |
| TILD | TILDE |
| UNDO | K_UNDO |
| UNDS | UNDER |
| UP | |
| VOLD | K_VOL_DN |
| VOLU | K_VOL_UP |
| WH_D | U_NU |
| WH_L | U_NU |
| WH_R | U_NU |
| WH_U | U_NU |
| S(KC_INS) | LS(INS) |
| C(KC_INS) | LC(INS) |
| S(KC_DEL) | LS(DEL) |
| SCMD(KC_Z) | LS(LCMD(Z)) |
| LCMD(KC_V) | LCMD(V) |
| LCMD(KC_C) | LCMD(C) |
| LCMD(KC_X) | LCMD(X) |
| LCMD(KC_Z) | LCMD(Z) |
| C(KC_Y) | LC(Y) |
| C(KC_V) | LC(V) |
| C(KC_C) | LC(C) |
| C(KC_X) | LC(X) |
| C(KC_Z) | LC(Z) |
| DF(TAP) | &tog TAP |
*** header
Header for tangled source files.
#+NAME: header
#+BEGIN_SRC C :tangle no
generated from miryoku_zmk.org -*- buffer-read-only: t -*-
#+END_SRC
* Subset Mapping
The keymap, build options, and configuration are shared between keyboards. The
layout is mapped onto keyboards with different physical layouts as a subset.
** mappings
*** [[split_3x5_3.h]]
#+BEGIN_SRC C :noweb yes :padline no :tangle split_3x5_3.h
// <<header>>
#define XXX &none
#define MIRYOKU_SUBMAP(\
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \
N30, N31, K32, K33, K34, K35, K36, K37, N38, N39\
)\
K00 K01 K02 K03 K04 K05 K06 K07 K08 K09 \
K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 \
K20 K21 K22 K23 K24 K25 K26 K27 K28 K29 \
K32 K33 K34 K35 K36 K37
#define MIRYOKU_SUPERMAP MIRYOKU_SUBMAP
#+END_SRC
*** [[split_3x6_3.h]]
#+BEGIN_SRC C :noweb yes :padline no :tangle split_3x6_3.h
// <<header>>
#define XXX &none
#define MIRYOKU_SUBMAP(\
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \
N30, N31, K32, K33, K34, K35, K36, K37, N38, N39\
)\
XXX K00 K01 K02 K03 K04 K05 K06 K07 K08 K09 XXX \
XXX K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 XXX \
XXX K20 K21 K22 K23 K24 K25 K26 K27 K28 K29 XXX \
K32 K33 K34 K35 K36 K37
#define MIRYOKU_SUPERMAP(\
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \
N30, N31, K32, K33, K34, K35, K36, K37, N38, N39\
)\
&kp LALT K00 K01 K02 K03 K04 K05 K06 K07 K08 K09 &kp LGUI \
&kp LCTRL K10 K11 K12 K13 K14 K15 K16 K17 K18 K19 &kp RCTRL \
&kp LSHFT K20 K21 K22 K23 K24 K25 K26 K27 K28 K29 &kp RSHFT \
K32 K33 K34 K35 K36 K37
#+END_SRC
*** [[ortho_4x12.h]]
#+BEGIN_SRC C :noweb yes :padline no :tangle ortho_4x12.h
// <<header>>
#define XXX &none
#define MIRYOKU_SUBMAP(\
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \
N30, N31, K32, K33, K34, K35, K36, K37, N38, N39\
)\
K00 K01 K02 K03 K04 XXX XXX K05 K06 K07 K08 K09 \
K10 K11 K12 K13 K14 XXX XXX K15 K16 K17 K18 K19 \
K20 K21 K22 K23 K24 XXX XXX K25 K26 K27 K28 K29 \
XXX XXX K32 K33 K34 XXX XXX K35 K36 K37 XXX XXX
#define MIRYOKU_SUPERMAP(\
K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, \
K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, \
K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, \
N30, N31, K32, K33, K34, K35, K36, K37, N38, N39 \
)\
K00 K01 K02 K03 K04 &kp NUM_8 &kp NUM_7 K05 K06 K07 K08 K09 \
K10 K11 K12 K13 K14 &kp NUM_6 &kp NUM_5 K15 K16 K17 K18 K19 \
K20 K21 K22 K23 K24 &kp NUM_4 &kp NUM_3 K25 K26 K27 K28 K29 \
&kp LSHFT &kp LCTRL K32 K33 K34 &kp NUM_2 &kp NUM_1 K35 K36 K37 &kp LALT &kp LGUI
#+END_SRC
** miryoku include
*** [[miryoku.dtsi]]
#+BEGIN_SRC C :noweb yes :padline no :tangle miryoku.dtsi
// <<header>>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/rgb.h>
#include <dt-bindings/zmk/outputs.h>
<<table-layer-defines()>>
#define U_NP &none // key is not present
#define U_NA &none // present but not available for use
#define U_NU &none // available but not used
#if defined MIRYOKU_CLIPBOARD_FUN
<<table-keycode-mappings(table=clipboard-fun)>>
#elif defined MIRYOKU_CLIPBOARD_MAC
<<table-keycode-mappings(table=clipboard-mac)>>
#elif defined MIRYOKU_CLIPBOARD_WIN
<<table-keycode-mappings(table=clipboard-win)>>
#else
<<table-keycode-mappings(table=clipboard)>>
#endif
/ {
behaviors {
hm: homerow_mods {
compatible = "zmk,behavior-hold-tap";
label = "HOMEROW_MODS";
#binding-cells = <2>;
tapping_term_ms = <200>;
flavor = "tap-preferred";
bindings = <&kp>, <&kp>;
};
};
keymap {
compatible = "zmk,keymap";
BASE_layer {
bindings = <
#if defined MIRYOKU_ALPHAS_COLEMAK
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=colemak)>>
)
#elif defined MIRYOKU_ALPHAS_COLEMAKDH
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=colemakdh)>>
)
#elif defined MIRYOKU_ALPHAS_DVORAK
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=dvorak)>>
)
#elif defined MIRYOKU_ALPHAS_HALMAK
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=halmak)>>
)
#elif defined MIRYOKU_ALPHAS_WORKMAN
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=workman)>>
)
#elif defined MIRYOKU_ALPHAS_QWERTY
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=qwerty)>>
)
#else
MIRYOKU_SUBMAP(
<<table-map-taphold(tap_table=colemakdhm)>>
)
#endif
>;
};
TAP_layer {
bindings = <
#if defined MIRYOKU_ALPHAS_COLEMAK
MIRYOKU_SUPERMAP(
<<table-map-full(table=colemak)>>
)
#elif defined MIRYOKU_ALPHAS_COLEMAKDH
MIRYOKU_SUPERMAP(
<<table-map-full(table=colemakdh)>>
)
#elif defined MIRYOKU_ALPHAS_DVORAK
MIRYOKU_SUPERMAP(
<<table-map-full(table=dvorak)>>
)
#elif defined MIRYOKU_ALPHAS_HALMAK
MIRYOKU_SUPERMAP(
<<table-map-full(table=halmak)>>
)
#elif defined MIRYOKU_ALPHAS_WORKMAN
MIRYOKU_SUPERMAP(
<<table-map-full(table=workman)>>
)
#elif defined MIRYOKU_ALPHAS_QWERTY
MIRYOKU_SUPERMAP(
<<table-map-full(table=qwerty)>>
)
#else
MIRYOKU_SUPERMAP(
<<table-map-full(table=colemakdhm)>>
)
#endif
>;
};
MBO_layer {
bindings = <
MIRYOKU_SUBMAP(
<<table-map-full(table=mbo)>>
)
>;
};
NAVR_layer {
bindings = <
#if defined MIRYOKU_NAV_VI
MIRYOKU_SUBMAP(
<<table-map-half(mode="r", half_table=navr-vi)>>
)
#else
MIRYOKU_SUBMAP(
<<table-map-half(mode="r", half_table=navr)>>
)
#endif
>;
};
MOUR_layer {
bindings = <
#if defined MIRYOKU_NAV_VI
MIRYOKU_SUBMAP(
<<table-map-half(mode="r", half_table=mour-vi)>>
)
#else
MIRYOKU_SUBMAP(
<<table-map-half(mode="r", half_table=mour)>>
)
#endif
>;
};
MEDR_layer {
bindings = <
#if defined MIRYOKU_NAV_VI
MIRYOKU_SUBMAP(
<<table-map-half(mode="r", half_table=medr-vi)>>
)
#else
MIRYOKU_SUBMAP(
<<table-map-half(mode="r", half_table=medr)>>
)
#endif
>;
};
NSL_layer {
bindings = <
MIRYOKU_SUBMAP(
<<table-map-half(mode="l", half_table=nsl)>>
)
>;
};
NSSL_layer {
bindings = <
MIRYOKU_SUBMAP(
<<table-map-half(mode="l", half_table=nssl)>>
)
>;
};
FUNL_layer {
bindings = <
MIRYOKU_SUBMAP(
<<table-map-half(mode="l", half_table=funl)>>
)
>;
};
};
};
#+END_SRC
* Documentation :noexport_1:
** ZMK
-
** Org Mode
- https://orgmode.org/
- https://orgmode.org/manual/Tables.html
- https://orgmode.org/manual/Working-with-Source-Code.html
* Contact
[[https://github.com/manna-harbour][https://raw.githubusercontent.com/manna-harbour/miryoku/master/data/logos/manna-harbour-boa-32.png]]