diff options
| -rw-r--r-- | build_keyboard.mk | 4 | ||||
| -rw-r--r-- | docs/feature_userspace.md | 24 | ||||
| -rw-r--r-- | users/drashna/readme.md | 27 | ||||
| -rw-r--r-- | users/drashna/rules.mk | 6 |
4 files changed, 27 insertions, 34 deletions
diff --git a/build_keyboard.mk b/build_keyboard.mk index 921159a5d..5a82abd31 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk | |||
| @@ -204,6 +204,10 @@ endif | |||
| 204 | # User space stuff | 204 | # User space stuff |
| 205 | USER_PATH := users/$(KEYMAP) | 205 | USER_PATH := users/$(KEYMAP) |
| 206 | -include $(USER_PATH)/rules.mk | 206 | -include $(USER_PATH)/rules.mk |
| 207 | ifneq ("$(wildcard users/$(KEYMAP)/config.h)","") | ||
| 208 | CONFIG_H += users/$(KEYMAP)/config.h | ||
| 209 | endif | ||
| 210 | |||
| 207 | 211 | ||
| 208 | # Object files directory | 212 | # Object files directory |
| 209 | # To put object files in current directory, use a dot (.), do NOT make | 213 | # To put object files in current directory, use a dot (.), do NOT make |
diff --git a/docs/feature_userspace.md b/docs/feature_userspace.md index 950377423..454481cb2 100644 --- a/docs/feature_userspace.md +++ b/docs/feature_userspace.md | |||
| @@ -3,10 +3,11 @@ | |||
| 3 | If you use more than one keyboard with a similar keymap, you might see the benefit in being able to share code between them. Create your own folder in `users/` named the same as your keymap (ideally your github username, `<name>`) with the following structure: | 3 | If you use more than one keyboard with a similar keymap, you might see the benefit in being able to share code between them. Create your own folder in `users/` named the same as your keymap (ideally your github username, `<name>`) with the following structure: |
| 4 | 4 | ||
| 5 | * `/users/<name>/` (added to the path automatically) | 5 | * `/users/<name>/` (added to the path automatically) |
| 6 | * `readme.md` | 6 | * `readme.md` (optional, recommended) |
| 7 | * `rules.mk` (included automatically) | 7 | * `rules.mk` (included automatically) |
| 8 | * `<name>.h` (optional) | 8 | * `<name>.h` (optional) |
| 9 | * `<name>.c` (optional) | 9 | * `<name>.c` (optional) |
| 10 | * `config.h` (optional) | ||
| 10 | 11 | ||
| 11 | `<name>.c` will need to be added to the SRC in `rules.mk` like this: | 12 | `<name>.c` will need to be added to the SRC in `rules.mk` like this: |
| 12 | 13 | ||
| @@ -24,10 +25,31 @@ For example, | |||
| 24 | 25 | ||
| 25 | Will include the `/users/jack/` folder in the path, along with `/users/jack/rules.mk`. | 26 | Will include the `/users/jack/` folder in the path, along with `/users/jack/rules.mk`. |
| 26 | 27 | ||
| 28 | Additionally, `config.h` here will be processed like the same file in your keymap folder. This is handled separately from the `<name>.h` file. | ||
| 29 | |||
| 30 | The reason for this, is that `<name>.h` won't be added in time to add settings (such as `#define TAPPING_TERM 100`), and including the `<name.h>` file in any `config.h` files will result in compile issues. | ||
| 31 | |||
| 32 | So you should use the `config.h` for QMK settings, and the `<name>.h` file for user or keymap specific settings. | ||
| 33 | |||
| 27 | ## Readme | 34 | ## Readme |
| 28 | 35 | ||
| 29 | Please include authorship (your name, github username, email), and optionally [a license that's GPL compatible](https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses). | 36 | Please include authorship (your name, github username, email), and optionally [a license that's GPL compatible](https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses). |
| 30 | 37 | ||
| 38 | ## `Config.h` | ||
| 39 | |||
| 40 | If you do add a `config,h` file, you want to make sure that it only gets processed once. So you may want to start off with something like this: | ||
| 41 | |||
| 42 | ```c | ||
| 43 | #ifndef USERSPACE_CONFIG_H | ||
| 44 | #define USERSPACE_CONFIG_H | ||
| 45 | |||
| 46 | // Put normal config.h settings here: | ||
| 47 | |||
| 48 | #endif // !USERSPACE_CONFIG_H | ||
| 49 | ``` | ||
| 50 | |||
| 51 | You can use any option hre that you could use in your keymap's `config.h` file. You can find a list of vales [here](config_options.md). | ||
| 52 | |||
| 31 | ## Example | 53 | ## Example |
| 32 | 54 | ||
| 33 | For a brief example, checkout `/users/_example/` , or for a more detailed examples check out [`template.h`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.h) and [`template.c`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.c) in `/users/drashna/` . | 55 | For a brief example, checkout `/users/_example/` , or for a more detailed examples check out [`template.h`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.h) and [`template.c`](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/template.c) in `/users/drashna/` . |
diff --git a/users/drashna/readme.md b/users/drashna/readme.md index e3e5d399d..c4e305e15 100644 --- a/users/drashna/readme.md +++ b/users/drashna/readme.md | |||
| @@ -3,33 +3,6 @@ Overview | |||
| 3 | 3 | ||
| 4 | This is my personal userspace file. Most of my code exists here, as it's heavily shared. | 4 | This is my personal userspace file. Most of my code exists here, as it's heavily shared. |
| 5 | 5 | ||
| 6 | Userspace Config.h | ||
| 7 | ------------------ | ||
| 8 | |||
| 9 | By default, the userspace feature doesn't include a `config.h` file the way that that keyboards, revisions, keymaps and layouts handle them. This means that if you want global configurations via userspace, it's very difficult to implement. | ||
| 10 | |||
| 11 | The reason for using seperate files here is that the `drashna.h` file doesn't get called in such a way that will actually define QMK settings. Additionally, attempting to add it to the `config.h` files has issues. Namely, the `drashna.h` file requires the `quantum.h` file... but including this to the `config.h` attemps to redefines a bunch of settings and breaks the firmare. Removing the `quantum.h` include means that a number of data structures no longer get added, and the `SAFE_RANGE` value is no longer defined, as well. So we need both a `config.h` for global config, and we need a seperate h file for local settings. | ||
| 12 | |||
| 13 | However, the `rules.mk` file is included when building the firmware. So we can hijack that process to "manually" add a `config.h`. To do so, you would need to add the following to the `rules.mk` in your userspace: | ||
| 14 | |||
| 15 | ```c | ||
| 16 | ifneq ("$(wildcard users/$(KEYMAP)/config.h)","") | ||
| 17 | CONFIG_H += users/$(KEYMAP)/config.h | ||
| 18 | endif | ||
| 19 | ``` | ||
| 20 | |||
| 21 | You can replace `$(KEYMAP)` with your name, but it's not necessary. This checks for the existence of `/users/<name>/config.h`, and if it exists, includes it like every other `config.h` file, allowing you to make global `config.h` settings. | ||
| 22 | |||
| 23 | As for the `config.h` file, you want to make sure that it has an "ifdef" in it to make sure it's only used once. So you want something like this: | ||
| 24 | |||
| 25 | ```c | ||
| 26 | #ifndef USERSPACE_CONFIG_H | ||
| 27 | #define USERSPACE_CONFIG_H | ||
| 28 | |||
| 29 | // put stuff here | ||
| 30 | |||
| 31 | #endif | ||
| 32 | ``` | ||
| 33 | 6 | ||
| 34 | Custom userspace handlers | 7 | Custom userspace handlers |
| 35 | ------------------------- | 8 | ------------------------- |
diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index 53e5da43d..062ecd3c4 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk | |||
| @@ -2,10 +2,4 @@ | |||
| 2 | SRC += drashna.c | 2 | SRC += drashna.c |
| 3 | EXTRAFLAGS += -flto | 3 | EXTRAFLAGS += -flto |
| 4 | 4 | ||
| 5 | ifneq ("$(wildcard users/$(KEYMAP)/config.h)","") | ||
| 6 | CONFIG_H += users/$(KEYMAP)/config.h | ||
| 7 | endif | ||
| 8 | 5 | ||
| 9 | ifeq ($(strip $(NO_SECRETS)), yes) | ||
| 10 | OPT_DEFS += -DNO_SECRETS | ||
| 11 | endif | ||
