Skip to content

Commit 3cd4224

Browse files
committed
Fix module to be in-line with zmk-documentation
1 parent 81b805c commit 3cd4224

File tree

7 files changed

+103
-54
lines changed

7 files changed

+103
-54
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,63 +13,58 @@ They are partly based on the amazing work by [Sunaku](https://github.com/sunaku)
1313

1414
### Installation
1515

16-
To use `zmk-keymap-utils`, you need to add it as a module to your west configuration with its required modules:
16+
To use `zmk-keymap-utils`, you need to add it as a module to your west configuration:
1717

1818
```yaml
1919
manifests:
2020
remotes:
21-
# zmk and other remotes might be configured
21+
# zmk and other remotes might be also configured
2222
- name: magicDGS
2323
url-base: https://github.com/magicDGS
24-
- name: urob
25-
url-base: https://github.com/urob
2624
projects:
27-
# zmk and other projects might be configured
28-
- name: zmk-helpers
29-
remote-name: urob
30-
# pin version of the module
31-
revision: v0.1
3225
- name: zmk-keymap-utils
33-
remote-name: magicDGS
26+
remote: magicDGS
3427
# pin version of the module
3528
revision: v0.3
29+
# import required modules (i.e., urob/zmk-helpers)
30+
import: west.yml
3631
```
3732
3833
> [!TIP]
39-
> We recommend to pin the version of the modules as shown in the example above.
34+
> We recommend to pin the version of the module as shown in the example above.
4035
> Nevertheless, you can also use directly `main`.
4136

37+
To override the required modules, please check the [documentation page].
38+
4239
To build locally, check the [ZMK documentation to build with external modules](https://zmk.dev/docs/development/local-toolchain/build-flash#building-with-external-modules).
4340

4441
### Basic usage
4542

4643
> [!NOTE]
47-
> The full documentation can be found on the [documentation page](https://github.com/magicDGS/zmk-keymap-utils/blob/main/docs/README.md).
44+
> The full documentation can be found on the [documentation page].
4845

4946
Define the `OPERATING_SYSTEM` variable with the operating system you intend to use with this keymap: `L` for Linux (default if not provided), `W` for Windows, `M` for MacOS.
5047

5148
- `#define OPERATING_SYSTEM "L"` for Linux (default if none provided)
5249
- `#define OPERATING_SYSTEM "W"` for Windows
5350
- `#define OPERATING_SYSTEM "M"` for MacOS
5451

55-
Source the `init.h` header before using any of the features of the `zmk-keymap-utils` module on your `.keymap` file to provide the initial keycodes and shortcuts for the specified OS.
52+
Source the `shortcuts.h` header before using any of the features of the `zmk-keymap-utils` module on your `.keymap` file to provide the initial keycodes and shortcuts for the specified OS.
5653

5754
```c
5855
// #define OPERATING_SYSTEM "L" // Linux (default) - uncomment to override with explicit values: L, W, M
59-
#include <zmk-keymap-utils/init.h>
56+
#include <zmk-keymap-utils/shortcuts.h>
6057
```
6158

6259
Then include any extra functionality you need:
6360

6461
```c
6562
// select-word macros based on the Sunaku's implementation of Pascal Getreuer's Select Word macro from QMK
66-
#include <zmk-keymap-utils/select_word.dtsi>
63+
#include <behaviors/select_word.dtsi>
6764
// timeless home-row mods based on urob's implementation
68-
#include <zmk-keymap-utils/hrm/timeless.dtsi>
65+
#include <zmk-keymap-utils/hrm/timeless.h>
6966
```
7067

71-
## Inspiration
72-
7368
# License
7469

7570
This project is released under the [ISC License](LICENSE).
@@ -84,3 +79,7 @@ It also contains copied or modified code from other Open Sourcethird-party proje
8479
In adition to the projects mentioned in the License, this project is inspired by other zmk-config projects and their configuration:
8580

8681
- [urob/zmk-config](https://github.com/urob/zmk-config), where it was firs described the configuration to implement [Timeless homerow mods](https://github.com/urob/zmk-config?tab=readme-ov-file#timeless-homerow-mods).
82+
83+
<!-- Links: -->
84+
85+
[documentation page]: https://github.com/magicDGS/zmk-keymap-utils/blob/main/docs/README.md

docs/README.md

Lines changed: 55 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,27 @@ This is a collection of helper utilities to simplify the configuration of ZMK ke
44

55
## Requirements
66

7-
To use `zmk-keymap-utils`, you need to add it as a module to your west configuration with its required modules:
7+
To use `zmk-keymap-utils`, you need to add it as a module to your west configuration importing the required modules from west:
88

9-
- This module itself or a compatible fork
10-
- [zmk-helpers](https://github.com/urob/zmk-helpers) (Version 2) or a compatible fork
9+
```yaml
10+
manifests:
11+
remotes:
12+
# zmk and other remotes might be configured
13+
- name: magicDGS
14+
url-base: https://github.com/magicDGS
15+
projects:
16+
# zmk and other projects might be configured
17+
- name: zmk-keymap-utils
18+
remote: magicDGS
19+
# pin version of the module
20+
revision: v0.3
21+
# import required modules (i.e., urob/zmk-helpers)
22+
import: west.yml
23+
```
24+
25+
You can also import it with a different version, remote or path for the required modules.
26+
For example, a west configuration with the main version of the module and its [zmk-helpers](https://github.com/urob/zmk-helpers) (Version 2) requirement
27+
that is located on the `modules` path:
1128

1229
```yaml
1330
manifests:
@@ -20,13 +37,11 @@ manifests:
2037
projects:
2138
# zmk and other projects might be configured
2239
- name: zmk-helpers
23-
remote-name: urob
24-
# pin version of the module
25-
revision: v0.1
40+
remote: urob
41+
path: modules/zmk-helpers
2642
- name: zmk-keymap-utils
27-
remote-name: magicDGS
28-
# pin version of the module
29-
revision: v0.3
43+
remote: magicDGS
44+
path: modules/zmk-keymap-utils
3045
```
3146

3247
> [!TIP]
@@ -41,25 +56,23 @@ Define the `OPERATING_SYSTEM` variable with the operating system you intend to u
4156
- `#define OPERATING_SYSTEM "W"` for Windows
4257
- `#define OPERATING_SYSTEM "M"` for MacOS
4358

44-
Source the `init.h` header before using any of the features of the `zmk-keymap-utils` module on your `.keymap` file to provide the initial keycodes and shortcuts for the specified OS.
59+
It is important to define the `OPERATING_SYSTEM` before including any of the features from the `zmk-keymap-utils` module to have the proper configuration for your operating system.
4560

46-
```c
47-
#include "zmk-keymap-utils/init.h"
48-
```
49-
50-
> [!CAUTION]
51-
> Including the `init.h` header includes also the `zmk-helpers` module.
52-
> Please, check the [README](https://github.com/urob/zmk-helpers/blob/main/README.md) of the `zmk-helpers` module for more information.
61+
## Shortcuts and modifiers
5362

54-
## Definitions and behaviors
63+
The shortcuts and modifieres are provided with the `shortcuts.h` header, which can be used with `&kp` or any other behaviors.
64+
They are implemented on an OS-agnostic way, by either adding aliases for keycodes or using shortcuts/macros (if keycodes are not available).
5565

56-
The `zmk-keymap-utils` module provides definitions and behaviors that can be used on an OS-agnostic way to configure the keymap, by adding aliases for the keycodes or using shortcuts/macros if they are not possible.
66+
To use this definitions, source the shortcuts.h header:
5767

58-
Nevertheless, some behaviors are not available on all OS, and will be marked in the tables below with `❌` or `❓` to indicate that they are not available or they are unknown.
68+
```c
69+
#include <zmk-keymap-utils/shortcuts.h>
70+
```
5971

60-
### Core definitions
72+
> [!TIP]
73+
> We recommend to import the shortcuts before any other behavior, as some of them would use them. They would be imported by default if not provided.
6174

62-
The core definitions are provided by default by the intial setup (including the `init.h` header on the `.keymap` file), which can be used with `&kp` or any other behavior:
75+
Provided shortcuts include (note that `❌` or `❓` indicates that the shortcut is no available or has unknown behavior on the OS):
6376

6477
| Shortcut | Description | L | W | M |
6578
| ---------------- | ------------------------------ | --- | --- | --- |
@@ -101,24 +114,32 @@ Other definitons might be used on different behaviors and are not intended to be
101114

102115
## Select Word
103116

104-
The `select_word.dtsi` include file provides support for extend/select behaviors for for the specified OS.
117+
The `select_word.dtsi` behaviors dtsi file provides support for extend/select behaviors for for the specified OS.
105118
They are based on the [Pascal Getreuer's Select Word macro from QMK](https://getreuer.info/posts/keyboards/select-word/index.html) implementation for ZMK by [Sunaku](https://github.com/sunaku/glove80-keymaps).
106119

107120
To use the default configuration, import with:
108121

109122
```c
110123
// select-word macros based on the Sunaku's implementation of Pascal Getreuer's Select Word macro from QMK
111-
#include "zmk-keymap-utils/select_word.h"
124+
#include <behaviors/select_word.h>
112125
```
113126

127+
> [!CAUTION]
128+
> Including the `select_word.h` behavior includes also `zmk-helpers` module.
129+
> Please, check the [README](https://github.com/urob/zmk-helpers/blob/main/README.md) of the `zmk-helpers` module for more information.
130+
131+
> [!CAUTION]
132+
> The `select_word.h` behavior would source, if not already included, the `shortcuts.h` header.
133+
> We recommend to import it beforehand to ensure that the the configuration is explicit.
134+
114135
To use a different delay, the `SELECT_WORD_DELAY` property can be used before import (default is `1`).
115136
This configuration defines how long the macro waits (in ms) after moving the cursor before it selects a word.
116137
A larger delay may allow th"macro to move to the next word upon each invocation.
117138
For example:
118139

119140
```c
120141
#define SELECT_WORD_DELAY 50
121-
#include "zmk-keymap-utils/select_word.h"
142+
#include <zmk-keymap-utils/select_word.h>
122143
```
123144

124145
The behaviors provided after import are the following:
@@ -133,7 +154,7 @@ The behaviors provided after import are the following:
133154
| `&extend_line` | Extend current selection by one line |
134155

135156
> [!TIP]
136-
> The behaviors are implemented in such a way that using them with the shift modifier active selects/extends in the t
157+
> The behaviors are implemented in such a way that using them with the shift modifier active selects/extends in the oposite direction.
137158

138159
## Home-Row Mods
139160

@@ -159,17 +180,21 @@ Here we provide a basic function to define your HRM behaviors with ease.
159180
To use the default configuration, import with:
160181

161182
```c
162-
// select-word macros based on the Sunaku's implementation of Pascal Getreuer's Select Word macro from QMK
163-
#include "zmk-keymap-utils/hrm/timeless.dtsi.h"
183+
// timeless home-row mods based on urob's implementation
184+
#include <zmk-keymap-utils/hrm/timeless.h>
164185
```
165186

187+
> [!CAUTION]
188+
> Including the `hrm/timeless.h` header includes also the `zmk-helpers` module.
189+
> Please, check the [README](https://github.com/urob/zmk-helpers/blob/main/README.md) of the `zmk-helpers` module for more information.
190+
166191
To use a different `tapping-term-ms`, the `TIMELESS_HRM_QUICK_TAP_MS` property can be used before import (default is `175`).
167192
This configuration can be tweak to support mod+alpha combinations in the same hand, and modifier press without other keys.
168193
For example:
169194

170195
```c
171196
#define TIMELESS_HRM_QUICK_TAP_MS 280
172-
#include "zmk-keymap-utils/hrm/timeless.dtsi.h"
197+
#include <zmk-keymap-utils/hrm/timeless.h>
173198
```
174199

175200
After import, you can define your HRMs using the `MAKE_TIMELESS_HRM` function.
@@ -189,7 +214,7 @@ A clear example on how to use this function is a refactor of the [Urob's Persona
189214
> This snippet uses the standard key-labels from `urob/zmk-helpers` (see [its README](https://github.com/urob/zmk-helpers?tab=readme-ov-file#key-labels-collection) for more details).
190215

191216
```c
192-
#include "zmk-helpers/key-labels/36.h" // Source key-labels.
217+
#include <zmk-helpers/key-labels/36.h> // Source key-labels.
193218
#define KEYS_L LT0 LT1 LT2 LT3 LT4 LM0 LM1 LM2 LM3 LM4 LB0 LB1 LB2 LB3 LB4 // Left-hand keys.
194219
#define KEYS_R RT0 RT1 RT2 RT3 RT4 RM0 RM1 RM2 RM3 RM4 RB0 RB1 RB2 RB3 RB4 // Right-hand keys.
195220
#define THUMBS LH2 LH1 LH0 RH0 RH1 RH2 // Thumb keys.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
/* Original code copied from Sunaku's Keymap modified to use zmk-helpers - https://github.com/sunaku/glove80-keymaps */
22

3+
/* Include helpers here as they are required for the behavior.
4+
5+
NOTE: all usages of ZMK_ functions are overriden from this point on,
6+
so only include modules/functions working with them
7+
*/
8+
#include <zmk-helpers/helper.h>
9+
10+
/* Include the shortcuts.h if not included yet */
11+
#ifndef _ZMK_KEYMAP_UTILS_SHORTCUTS_IMPORT
12+
#include <zmk-keymap-utils/shortcuts.h>
13+
#endif
14+
315
//////////////////////////////////////////////////////////////////////////
416
//
517
// Approximation of Pascal Getreuer's Select Word macro from QMK

include/zmk-keymap-utils/hrm/timeless.dtsi renamed to include/zmk-keymap-utils/hrm/timeless.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
* Adapted from urob's zmk-config repo: https://github.com/urob/zmk-config/
33
*/
44

5+
/* Include helpers here as they are required for the behavior.
6+
7+
NOTE: all usages of ZMK_ functions are overriden from this point on,
8+
so only include modules/functions working with them
9+
*/
10+
#include <zmk-helpers/helper.h>
11+
512
// defines the quick-tap to be used on timeless-homerow-mods
613
#ifndef TIMELESS_HRM_QUICK_TAP_MS
714
#define TIMELESS_HRM_QUICK_TAP_MS 175
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,5 @@
6161
#define _HYPER LS(LC(LA(LGUI)))
6262
#define _H(key) LS(LC(LA(LG(key)))
6363

64-
/* Include helpers here
65-
NOTE: all usages of ZMK_ functions are overriden from this point on,
66-
so only include modules/functions working with them
67-
*/
68-
#include <zmk-helpers/helper.h>
64+
// define that the shorcuts import worked with the operating system
65+
#define _ZMK_KEYMAP_UTILS_SHORTCUTS_IMPORT OPERATING_SYSTEM

west.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
manifest:
2+
remotes:
3+
- name: urob
4+
url-base: https://github.com/urob
5+
6+
projects:
7+
- name: zmk-helpers
8+
remote: urob
9+
revision: v0.1

zephyr/module.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: zmk-keymap-utils
1+
name: zmk-feature-keymap-utils
22
build:
33
depends:
44
- zmk-helpers

0 commit comments

Comments
 (0)