From 06f196c589b3c8c70c6cda6e95db6d1a2bf6e80b Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Sat, 21 Oct 2017 11:44:11 -1000 Subject: Creates a userspace for keymaps (#1559) * create a user space * adds example * document, add readme.md * jackhumbert userspace, ergodox keymap --- build_keyboard.mk | 5 + docs/_summary.md | 1 + docs/feature_userspace.md | 33 +++++++ layouts/community/ergodox/jack/config.h | 17 ---- layouts/community/ergodox/jack/keymap.c | 128 ------------------------- layouts/community/ergodox/jackhumbert/config.h | 17 ++++ layouts/community/ergodox/jackhumbert/keymap.c | 128 +++++++++++++++++++++++++ users/_example/_example.c | 5 + users/_example/_example.h | 8 ++ users/_example/readme.md | 14 +++ users/_example/rules.mk | 1 + users/jackhumbert/jackhumbert.c | 1 + users/jackhumbert/jackhumbert.h | 6 ++ users/jackhumbert/readme.md | 14 +++ users/jackhumbert/rules.mk | 1 + users/readme.md | 3 + 16 files changed, 237 insertions(+), 145 deletions(-) create mode 100644 docs/feature_userspace.md delete mode 100644 layouts/community/ergodox/jack/config.h delete mode 100644 layouts/community/ergodox/jack/keymap.c create mode 100644 layouts/community/ergodox/jackhumbert/config.h create mode 100644 layouts/community/ergodox/jackhumbert/keymap.c create mode 100644 users/_example/_example.c create mode 100644 users/_example/_example.h create mode 100644 users/_example/readme.md create mode 100644 users/_example/rules.mk create mode 100644 users/jackhumbert/jackhumbert.c create mode 100644 users/jackhumbert/jackhumbert.h create mode 100644 users/jackhumbert/readme.md create mode 100644 users/jackhumbert/rules.mk create mode 100644 users/readme.md diff --git a/build_keyboard.mk b/build_keyboard.mk index 4502078502..2c86fe55ef 100644 --- a/build_keyboard.mk +++ b/build_keyboard.mk @@ -183,6 +183,10 @@ else # this state should never be reached endif +# User space stuff +USER_PATH := users/$(KEYMAP) +-include $(USER_PATH)/rules.mk + # Object files directory # To put object files in current directory, use a dot (.), do NOT make # this an empty or blank macro! @@ -204,6 +208,7 @@ SRC += $(KEYBOARD_SRC) \ VPATH += $(KEYMAP_PATH) VPATH += $(KEYBOARD_PATHS) VPATH += $(COMMON_VPATH) +VPATH += $(USER_PATH) include common_features.mk include $(TMK_PATH)/protocol.mk diff --git a/docs/_summary.md b/docs/_summary.md index edbf04c1a4..55cfd2ab3d 100644 --- a/docs/_summary.md +++ b/docs/_summary.md @@ -15,6 +15,7 @@ * [Features](features.md) * [Layouts](feature_layouts.md) * [Common Shortcuts](feature_common_shortcuts.md) + * [Userspace](feature_userspace.md) * [Backlight](feature_backlight.md) * [Bootmagic](feature_bootmagic.md) * [Dynamic Macros](dynamic_macros.md) diff --git a/docs/feature_userspace.md b/docs/feature_userspace.md new file mode 100644 index 0000000000..edc9f6e32e --- /dev/null +++ b/docs/feature_userspace.md @@ -0,0 +1,33 @@ +# Userspace: sharing code between keymaps + +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, ``) with the following structure: + +* `/users//` (added to the path automatically) + * `readme.md` + * `rules.mk` (included automatically) + * `.h` (optional) + * `.c` (optional) + +`.c` will need to be added to the SRC in `rules.mk` like this: + + SRC += .c + +Additional files may be added in the same way - it's recommended you have one named ``.c/.h though. + +All this only happens when you build a keymap named ``, like this: + + make planck: + +For example, + + make planck:jack + +Will include the `/users/jack/` folder in the path, along with `/users/jack/rules.mk`. + +## Readme + +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). + +## Example + +For a brief example, checkout `/users/_example/` until we have more reasonable and useful examples. \ No newline at end of file diff --git a/layouts/community/ergodox/jack/config.h b/layouts/community/ergodox/jack/config.h deleted file mode 100644 index 04bbed611a..0000000000 --- a/layouts/community/ergodox/jack/config.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef CONFIG_USER_H -#define CONFIG_USER_H - -#include QMK_KEYBOARD_CONFIG_H - -/* ws2812 RGB LED */ -#define RGB_DI_PIN D7 -#define RGBLIGHT_ANIMATIONS -#define RGBLED_NUM 15 // Number of LEDs -#define RGBLIGHT_HUE_STEP 12 -#define RGBLIGHT_SAT_STEP 255 -#define RGBLIGHT_VAL_STEP 12 - -#define RGB_MIDI -#define RGBW_BB_TWI - -#endif \ No newline at end of file diff --git a/layouts/community/ergodox/jack/keymap.c b/layouts/community/ergodox/jack/keymap.c deleted file mode 100644 index 6a00ffa293..0000000000 --- a/layouts/community/ergodox/jack/keymap.c +++ /dev/null @@ -1,128 +0,0 @@ -#include QMK_KEYBOARD_H -#include "debug.h" -#include "action_layer.h" - -// TODO: Define layer names that make sense for the ErgoDox EZ. -#define BASE 0 // default layer -#define SYMB 1 // symbols -#define MDIA 2 // media keys - -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -[BASE] = LAYOUT_ergodox( // layer 0 : default - // left hand - KC_NO, KC_1, KC_2, KC_3, KC_4, KC_5, KC_NO, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_NO, - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_NO, - KC_NO, KC_LCTL, KC_LALT,KC_LGUI, MO(2), - ALT_T(KC_APP), KC_LGUI, - KC_HOME, - KC_SPC,KC_SPC,KC_END, - // right hand - KC_NO, M(1), KC_7, KC_8, KC_9, KC_0, KC_NO, - KC_NO, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, KC_P, KC_BSPC, - RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_SCLN, KC_QUOT, - KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT, - MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, - RGB_TOG, RGB_HUI, - RGB_MOD, - M(2), KC_SPC,KC_SPC - ), -[SYMB] = LAYOUT_ergodox( - // left hand - KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, - KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_TRNS, - KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, - KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,KC_TRNS, - KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, - KC_TRNS,KC_TRNS, - KC_TRNS, - KC_TRNS,KC_TRNS,KC_TRNS, - // right hand - KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, - KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, - KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, - KC_TRNS, KC_F12, KC_NO, KC_NO, KC_NO, RESET, KC_TRNS, - KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, - KC_TRNS, KC_TRNS, - KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS -), -[MDIA] = LAYOUT_ergodox( - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TRNS, - KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, - KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, - KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, - // right hand - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, - KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, - KC_TRNS, KC_F12, KC_NO, KC_NO, KC_NO, RESET, KC_TRNS, - KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, - KC_TRNS, KC_TRNS, - KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS -), -}; - -const uint16_t PROGMEM fn_actions[] = { - [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) -}; - -const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) -{ - // MACRODOWN only works in this function - switch(id) { - case 0: - if (record->event.pressed) { - register_code(KC_RSFT); - } else { - unregister_code(KC_RSFT); - } - break; - case 1: - if (record->event.pressed) { // For resetting EEPROM - eeconfig_init(); - } - break; - case 2: - if (record->event.pressed) { // For resetting EEPROM - api_send_unicode(0x0CA0); - } - break; - } - return MACRO_NONE; -}; - -// Runs just one time when the keyboard initializes. -void matrix_init_user(void) { - -}; - -// Runs constantly in the background, in a loop. -void matrix_scan_user(void) { - - uint8_t layer = biton32(layer_state); - - ergodox_board_led_off(); - ergodox_right_led_1_off(); - ergodox_right_led_2_off(); - ergodox_right_led_3_off(); - switch (layer) { - // TODO: Make this relevant to the ErgoDox EZ. - case 1: - ergodox_right_led_1_on(); - break; - case 2: - ergodox_right_led_2_on(); - break; - default: - // none - break; - } - -}; diff --git a/layouts/community/ergodox/jackhumbert/config.h b/layouts/community/ergodox/jackhumbert/config.h new file mode 100644 index 0000000000..04bbed611a --- /dev/null +++ b/layouts/community/ergodox/jackhumbert/config.h @@ -0,0 +1,17 @@ +#ifndef CONFIG_USER_H +#define CONFIG_USER_H + +#include QMK_KEYBOARD_CONFIG_H + +/* ws2812 RGB LED */ +#define RGB_DI_PIN D7 +#define RGBLIGHT_ANIMATIONS +#define RGBLED_NUM 15 // Number of LEDs +#define RGBLIGHT_HUE_STEP 12 +#define RGBLIGHT_SAT_STEP 255 +#define RGBLIGHT_VAL_STEP 12 + +#define RGB_MIDI +#define RGBW_BB_TWI + +#endif \ No newline at end of file diff --git a/layouts/community/ergodox/jackhumbert/keymap.c b/layouts/community/ergodox/jackhumbert/keymap.c new file mode 100644 index 0000000000..6a00ffa293 --- /dev/null +++ b/layouts/community/ergodox/jackhumbert/keymap.c @@ -0,0 +1,128 @@ +#include QMK_KEYBOARD_H +#include "debug.h" +#include "action_layer.h" + +// TODO: Define layer names that make sense for the ErgoDox EZ. +#define BASE 0 // default layer +#define SYMB 1 // symbols +#define MDIA 2 // media keys + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[BASE] = LAYOUT_ergodox( // layer 0 : default + // left hand + KC_NO, KC_1, KC_2, KC_3, KC_4, KC_5, KC_NO, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_NO, + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_NO, + KC_NO, KC_LCTL, KC_LALT,KC_LGUI, MO(2), + ALT_T(KC_APP), KC_LGUI, + KC_HOME, + KC_SPC,KC_SPC,KC_END, + // right hand + KC_NO, M(1), KC_7, KC_8, KC_9, KC_0, KC_NO, + KC_NO, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, KC_P, KC_BSPC, + RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, KC_SCLN, KC_QUOT, + KC_NO, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH, KC_ENT, + MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT, + RGB_TOG, RGB_HUI, + RGB_MOD, + M(2), KC_SPC,KC_SPC + ), +[SYMB] = LAYOUT_ergodox( + // left hand + KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_TRNS, + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS, + KC_TRNS,KC_TRNS, + KC_TRNS, + KC_TRNS,KC_TRNS,KC_TRNS, + // right hand + KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, + KC_TRNS, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, + KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, + KC_TRNS, KC_F12, KC_NO, KC_NO, KC_NO, RESET, KC_TRNS, + KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +[MDIA] = LAYOUT_ergodox( + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_TRNS, + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, + KC_TRNS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, + // right hand + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, + KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, + KC_TRNS, KC_F12, KC_NO, KC_NO, KC_NO, RESET, KC_TRNS, + KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, + KC_TRNS, KC_TRNS, + KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS +), +}; + +const uint16_t PROGMEM fn_actions[] = { + [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) +{ + // MACRODOWN only works in this function + switch(id) { + case 0: + if (record->event.pressed) { + register_code(KC_RSFT); + } else { + unregister_code(KC_RSFT); + } + break; + case 1: + if (record->event.pressed) { // For resetting EEPROM + eeconfig_init(); + } + break; + case 2: + if (record->event.pressed) { // For resetting EEPROM + api_send_unicode(0x0CA0); + } + break; + } + return MACRO_NONE; +}; + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + +}; + +// Runs constantly in the background, in a loop. +void matrix_scan_user(void) { + + uint8_t layer = biton32(layer_state); + + ergodox_board_led_off(); + ergodox_right_led_1_off(); + ergodox_right_led_2_off(); + ergodox_right_led_3_off(); + switch (layer) { + // TODO: Make this relevant to the ErgoDox EZ. + case 1: + ergodox_right_led_1_on(); + break; + case 2: + ergodox_right_led_2_on(); + break; + default: + // none + break; + } + +}; diff --git a/users/_example/_example.c b/users/_example/_example.c new file mode 100644 index 0000000000..8e0778b122 --- /dev/null +++ b/users/_example/_example.c @@ -0,0 +1,5 @@ +#include "_example.h" + +void my_custom_function(void) { + +} \ No newline at end of file diff --git a/users/_example/_example.h b/users/_example/_example.h new file mode 100644 index 0000000000..f7c7990257 --- /dev/null +++ b/users/_example/_example.h @@ -0,0 +1,8 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" + +void my_custom_function(void); + +#endif \ No newline at end of file diff --git a/users/_example/readme.md b/users/_example/readme.md new file mode 100644 index 0000000000..fdea33b67a --- /dev/null +++ b/users/_example/readme.md @@ -0,0 +1,14 @@ +Copyright @ + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . \ No newline at end of file diff --git a/users/_example/rules.mk b/users/_example/rules.mk new file mode 100644 index 0000000000..250adc3d0d --- /dev/null +++ b/users/_example/rules.mk @@ -0,0 +1 @@ +SRC += _example.c \ No newline at end of file diff --git a/users/jackhumbert/jackhumbert.c b/users/jackhumbert/jackhumbert.c new file mode 100644 index 0000000000..011e0efb8f --- /dev/null +++ b/users/jackhumbert/jackhumbert.c @@ -0,0 +1 @@ +#include "jackhumbert.h" \ No newline at end of file diff --git a/users/jackhumbert/jackhumbert.h b/users/jackhumbert/jackhumbert.h new file mode 100644 index 0000000000..69cfa67451 --- /dev/null +++ b/users/jackhumbert/jackhumbert.h @@ -0,0 +1,6 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" + +#endif \ No newline at end of file diff --git a/users/jackhumbert/readme.md b/users/jackhumbert/readme.md new file mode 100644 index 0000000000..479a64140a --- /dev/null +++ b/users/jackhumbert/readme.md @@ -0,0 +1,14 @@ +Copyright 2017 Jack Humbert @jackhumbert + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . \ No newline at end of file diff --git a/users/jackhumbert/rules.mk b/users/jackhumbert/rules.mk new file mode 100644 index 0000000000..f2981bb786 --- /dev/null +++ b/users/jackhumbert/rules.mk @@ -0,0 +1 @@ +SRC += jackhumbert.c \ No newline at end of file diff --git a/users/readme.md b/users/readme.md new file mode 100644 index 0000000000..d8f14d8beb --- /dev/null +++ b/users/readme.md @@ -0,0 +1,3 @@ +# User space + +This is a place for users to put code that they might use between keyboards. If you build the keymap `mine`, `/users/mine/rules.mk` will be included in your build, and `/users/mine/` will be in your path - keep these things in mind when naming your files and referencing them from other places. \ No newline at end of file -- cgit v1.2.1