diff options
Diffstat (limited to 'users')
| -rw-r--r-- | users/spidey3/config.h | 5 | ||||
| -rw-r--r-- | users/spidey3/init.c | 21 | ||||
| -rw-r--r-- | users/spidey3/layer_rgb.c | 81 | ||||
| -rw-r--r-- | users/spidey3/readme.md | 14 | ||||
| -rw-r--r-- | users/spidey3/rules.mk | 10 | ||||
| -rw-r--r-- | users/spidey3/spidey3.c | 80 | ||||
| -rw-r--r-- | users/spidey3/spidey3.h | 40 | ||||
| -rw-r--r-- | users/spidey3/unicode.c | 19 | ||||
| -rw-r--r-- | users/spidey3/unicode.h | 19 |
9 files changed, 289 insertions, 0 deletions
diff --git a/users/spidey3/config.h b/users/spidey3/config.h new file mode 100644 index 000000000..9da7f5530 --- /dev/null +++ b/users/spidey3/config.h | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #define LED_DISABLE_WHEN_USB_SUSPENDED true | ||
| 4 | #define RGB_DISABLE_WHEN_USB_SUSPENDED true | ||
| 5 | #define RGBLIGHT_LAYERS | ||
diff --git a/users/spidey3/init.c b/users/spidey3/init.c new file mode 100644 index 000000000..a4be6113f --- /dev/null +++ b/users/spidey3/init.c | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | #include "spidey3.h" | ||
| 2 | |||
| 3 | void keyboard_post_init_user(void) { | ||
| 4 | print("SPIDEY3: keyboard_post_init_user\n"); | ||
| 5 | uprintf(" debug_enable=%u\n", debug_enable); | ||
| 6 | #ifdef RGBLIGHT_ENABLE | ||
| 7 | keyboard_post_init_user_rgb(); | ||
| 8 | #endif | ||
| 9 | } | ||
| 10 | |||
| 11 | void eeconfig_init_user(void) { | ||
| 12 | print("SPIDEY3: eeconfig_init_user\n"); | ||
| 13 | set_single_persistent_default_layer(_BASE); | ||
| 14 | #ifdef UNICODEMAP_ENABLE | ||
| 15 | eeconfig_init_user_unicode(); | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #ifdef RGBLIGHT_ENABLE | ||
| 19 | eeconfig_init_user_rgb(); | ||
| 20 | #endif | ||
| 21 | } | ||
diff --git a/users/spidey3/layer_rgb.c b/users/spidey3/layer_rgb.c new file mode 100644 index 000000000..d80eb20a3 --- /dev/null +++ b/users/spidey3/layer_rgb.c | |||
| @@ -0,0 +1,81 @@ | |||
| 1 | #include QMK_KEYBOARD_H | ||
| 2 | |||
| 3 | #include "spidey3.h" | ||
| 4 | #include "velocikey.h" | ||
| 5 | |||
| 6 | uint32_t rgb_mode; | ||
| 7 | uint16_t rgb_hue; | ||
| 8 | uint8_t rgb_sat; | ||
| 9 | uint8_t rgb_val; | ||
| 10 | bool rgb_saved = 0; | ||
| 11 | |||
| 12 | void spidey_swirl(void) { | ||
| 13 | dprint("SPIDEY3: Setting Spidey Swirl!\n"); | ||
| 14 | rgblight_enable(); | ||
| 15 | rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); | ||
| 16 | rgblight_sethsv(213, 255, 128); | ||
| 17 | #ifdef VELOCIKEY_ENABLE | ||
| 18 | if (!velocikey_enabled()) | ||
| 19 | velocikey_toggle(); | ||
| 20 | #endif | ||
| 21 | } | ||
| 22 | |||
| 23 | void eeconfig_init_user_rgb(void) | ||
| 24 | { | ||
| 25 | spidey_swirl(); | ||
| 26 | } | ||
| 27 | |||
| 28 | const rgblight_segment_t PROGMEM _capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS( {0, 2, HSV_AZURE}, {14, 2, HSV_AZURE} ); | ||
| 29 | const rgblight_segment_t PROGMEM _layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS( {7, 1, HSV_PURPLE} ); | ||
| 30 | const rgblight_segment_t PROGMEM _layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 2, HSV_GREEN} ); | ||
| 31 | |||
| 32 | // Now define the array of layers. Later layers take precedence | ||
| 33 | const rgblight_segment_t* const PROGMEM _rgb_layers[] = RGBLIGHT_LAYERS_LIST( _capslock_layer, _layer1_layer, _layer2_layer ); | ||
| 34 | const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1; | ||
| 35 | |||
| 36 | void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) { | ||
| 37 | dprint("SPIDEY3: do_rgb_layers()\n"); | ||
| 38 | for (uint8_t i=start; i<end; i++) { | ||
| 39 | bool is_on = layer_state_cmp(state, i); | ||
| 40 | dprintf(" layer[%d]=%u\n", i, is_on); | ||
| 41 | rgblight_set_layer_state(i, is_on); | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | void keyboard_post_init_user_rgb(void) { | ||
| 46 | do_rgb_layers(default_layer_state, 1u, RGB_LAYER_BASE_REGULAR); | ||
| 47 | do_rgb_layers(layer_state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers); | ||
| 48 | // Enable the LED layers | ||
| 49 | rgblight_layers = _rgb_layers; | ||
| 50 | } | ||
| 51 | |||
| 52 | layer_state_t default_layer_state_set_user_rgb(layer_state_t state) { | ||
| 53 | dprint("SPIDEY3: default_layer_state_set_user_rgb()\n"); | ||
| 54 | do_rgb_layers(state, 1u, RGB_LAYER_BASE_REGULAR); | ||
| 55 | return state; | ||
| 56 | } | ||
| 57 | |||
| 58 | layer_state_t layer_state_set_user_rgb(layer_state_t state) { | ||
| 59 | dprint("SPIDEY3: layer_state_set_user_rgb()\n"); | ||
| 60 | do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers); | ||
| 61 | return state; | ||
| 62 | } | ||
| 63 | |||
| 64 | bool led_update_user_rgb(led_t led_state) { | ||
| 65 | dprintf("SPIDEY3: caps_lock=%u\n", led_state.caps_lock); | ||
| 66 | rgblight_set_layer_state(0, led_state.caps_lock); | ||
| 67 | return true; | ||
| 68 | } | ||
| 69 | |||
| 70 | bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { | ||
| 71 | |||
| 72 | switch (keycode) { | ||
| 73 | case SPI_GLO: | ||
| 74 | if (record->event.pressed) { | ||
| 75 | spidey_swirl(); | ||
| 76 | } | ||
| 77 | break; | ||
| 78 | } | ||
| 79 | |||
| 80 | return true; | ||
| 81 | } | ||
diff --git a/users/spidey3/readme.md b/users/spidey3/readme.md new file mode 100644 index 000000000..409d6e5f8 --- /dev/null +++ b/users/spidey3/readme.md | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | Copyright 2020 Joshua Diamond josh@windowoffire.com @spidey3 | ||
| 2 | |||
| 3 | This program is free software: you can redistribute it and/or modify | ||
| 4 | it under the terms of the GNU General Public License as published by | ||
| 5 | the Free Software Foundation, either version 2 of the License, or | ||
| 6 | (at your option) any later version. | ||
| 7 | |||
| 8 | This program is distributed in the hope that it will be useful, | ||
| 9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | GNU General Public License for more details. | ||
| 12 | |||
| 13 | You should have received a copy of the GNU General Public License | ||
| 14 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
diff --git a/users/spidey3/rules.mk b/users/spidey3/rules.mk new file mode 100644 index 000000000..0a77d2bfc --- /dev/null +++ b/users/spidey3/rules.mk | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | |||
| 2 | SRC += init.c | ||
| 3 | SRC += spidey3.c | ||
| 4 | |||
| 5 | ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) | ||
| 6 | SRC += layer_rgb.c | ||
| 7 | endif | ||
| 8 | ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) | ||
| 9 | SRC += unicode.c | ||
| 10 | endif | ||
diff --git a/users/spidey3/spidey3.c b/users/spidey3/spidey3.c new file mode 100644 index 000000000..d0b794704 --- /dev/null +++ b/users/spidey3/spidey3.c | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | #include QMK_KEYBOARD_H | ||
| 2 | |||
| 3 | #include "spidey3.h" | ||
| 4 | |||
| 5 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 6 | |||
| 7 | // If console is enabled, it will print the matrix position and status of each key pressed | ||
| 8 | // dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); | ||
| 9 | |||
| 10 | if (record->event.pressed) { | ||
| 11 | switch (keycode) { | ||
| 12 | #ifndef NO_DEBUG | ||
| 13 | // Re-implement this here, but fix the persistence! | ||
| 14 | case DEBUG: | ||
| 15 | debug_enable ^= 1; | ||
| 16 | if (debug_enable) { | ||
| 17 | print("DEBUG: enabled.\n"); | ||
| 18 | } else { | ||
| 19 | print("DEBUG: disabled.\n"); | ||
| 20 | } | ||
| 21 | eeconfig_update_debug(debug_config.raw); | ||
| 22 | #endif | ||
| 23 | return false; | ||
| 24 | case SPI_LNX: | ||
| 25 | dprint("SPIDEY3: SPI_LNX\n"); | ||
| 26 | set_single_persistent_default_layer(_BASE); | ||
| 27 | layer_off(_OSX); | ||
| 28 | #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) | ||
| 29 | set_unicode_input_mode(UC_LNX); | ||
| 30 | #endif | ||
| 31 | return false; | ||
| 32 | case SPI_OSX: | ||
| 33 | dprint("SPIDEY3: SPI_OSX\n"); | ||
| 34 | set_single_persistent_default_layer(_OSX); | ||
| 35 | #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) | ||
| 36 | set_unicode_input_mode(UC_OSX); | ||
| 37 | #endif | ||
| 38 | return false; | ||
| 39 | case SPI_WIN: | ||
| 40 | dprint("SPIDEY3: SPI_WIN\n"); | ||
| 41 | set_single_persistent_default_layer(_BASE); | ||
| 42 | layer_off(_OSX); | ||
| 43 | #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) | ||
| 44 | set_unicode_input_mode(UC_WINC); | ||
| 45 | #endif | ||
| 46 | return false; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | #ifdef RGBLIGHT_ENABLE | ||
| 51 | bool res = process_record_user_rgb(keycode, record); | ||
| 52 | if (!res) return false; | ||
| 53 | #endif | ||
| 54 | |||
| 55 | return true; | ||
| 56 | } | ||
| 57 | |||
| 58 | layer_state_t default_layer_state_set_user(layer_state_t state) { | ||
| 59 | #ifdef RGBLIGHT_ENABLE | ||
| 60 | return default_layer_state_set_user_rgb(state); | ||
| 61 | #else | ||
| 62 | return state; | ||
| 63 | #endif | ||
| 64 | } | ||
| 65 | |||
| 66 | layer_state_t layer_state_set_user(layer_state_t state) { | ||
| 67 | #ifdef RGBLIGHT_ENABLE | ||
| 68 | return layer_state_set_user_rgb(state); | ||
| 69 | #else | ||
| 70 | return state; | ||
| 71 | #endif | ||
| 72 | } | ||
| 73 | |||
| 74 | bool led_update_user(led_t led_state) { | ||
| 75 | #ifdef RGBLIGHT_ENABLE | ||
| 76 | return led_update_user_rgb(led_state); | ||
| 77 | #else | ||
| 78 | return true; | ||
| 79 | #endif | ||
| 80 | } | ||
diff --git a/users/spidey3/spidey3.h b/users/spidey3/spidey3.h new file mode 100644 index 000000000..125f70a9a --- /dev/null +++ b/users/spidey3/spidey3.h | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include QMK_KEYBOARD_H | ||
| 4 | |||
| 5 | #ifdef UNICODEMAP_ENABLE | ||
| 6 | #include "unicode.h" | ||
| 7 | #endif | ||
| 8 | |||
| 9 | enum userspace_layers { | ||
| 10 | _BASE = 0, | ||
| 11 | _OSX, | ||
| 12 | _FN, | ||
| 13 | }; | ||
| 14 | |||
| 15 | enum rgb_base_layer { | ||
| 16 | RGB_LAYER_BASE_DEFAULT = _BASE, | ||
| 17 | RGB_LAYER_BASE_REGULAR = _FN, | ||
| 18 | }; | ||
| 19 | |||
| 20 | enum custom_keycodes { | ||
| 21 | SPI_GLO = SAFE_RANGE, | ||
| 22 | SPI_LNX, | ||
| 23 | SPI_OSX, | ||
| 24 | SPI_WIN, | ||
| 25 | }; | ||
| 26 | |||
| 27 | #ifdef RGBLIGHT_ENABLE | ||
| 28 | void eeconfig_init_user_rgb(void); | ||
| 29 | void matrix_init_user_rgb(void); | ||
| 30 | void keyboard_post_init_user_rgb(void); | ||
| 31 | bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record); | ||
| 32 | layer_state_t layer_state_set_user_rgb(layer_state_t state); | ||
| 33 | layer_state_t default_layer_state_set_user_rgb(layer_state_t state); | ||
| 34 | bool led_update_user_rgb(led_t led_state); | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #ifdef UNICODEMAP_ENABLE | ||
| 38 | void eeconfig_init_user_unicode(void); | ||
| 39 | #endif | ||
| 40 | |||
diff --git a/users/spidey3/unicode.c b/users/spidey3/unicode.c new file mode 100644 index 000000000..41ceef837 --- /dev/null +++ b/users/spidey3/unicode.c | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | |||
| 2 | #include "unicode.h" | ||
| 3 | |||
| 4 | const uint32_t PROGMEM unicode_map[] = { | ||
| 5 | [BUL1] = 0x2022, // • | ||
| 6 | [BUL2] = 0x25E6, // ◦ | ||
| 7 | [LARR] = 0x2190, // ← | ||
| 8 | [RARR] = 0x2192, // → | ||
| 9 | [ENDASH] = 0x2013, // – | ||
| 10 | [EMDASH] = 0x2014, // — | ||
| 11 | }; | ||
| 12 | |||
| 13 | void eeconfig_init_user_unicode(void) | ||
| 14 | { | ||
| 15 | // Default to Linux style | ||
| 16 | set_unicode_input_mode(UC_LNX); | ||
| 17 | } | ||
| 18 | |||
| 19 | |||
diff --git a/users/spidey3/unicode.h b/users/spidey3/unicode.h new file mode 100644 index 000000000..72a91e8a8 --- /dev/null +++ b/users/spidey3/unicode.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include QMK_KEYBOARD_H | ||
| 4 | |||
| 5 | #ifdef UNICODEMAP_ENABLE | ||
| 6 | |||
| 7 | enum unicode_names { | ||
| 8 | BUL1, | ||
| 9 | BUL2, | ||
| 10 | LARR, | ||
| 11 | RARR, | ||
| 12 | ENDASH, | ||
| 13 | EMDASH, | ||
| 14 | }; | ||
| 15 | |||
| 16 | #define X_BUL (XP(BUL1, BUL2)) | ||
| 17 | #define X_DASH (XP(ENDASH, EMDASH)) | ||
| 18 | |||
| 19 | #endif | ||
