diff options
author | spidey3 <josh@windowoffire.com> | 2020-03-23 00:11:41 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-22 21:11:41 -0700 |
commit | 7e0dc5376f2d57a1b24831c4e25699a2cf2326af (patch) | |
tree | 141dd6fdbd2c9fac18b6d10c823187bd2a04b497 /users/spidey3 | |
parent | 6d1af6384227c941d817fee6f7e49537fc78cf2d (diff) | |
download | qmk_firmware-7e0dc5376f2d57a1b24831c4e25699a2cf2326af.tar.gz qmk_firmware-7e0dc5376f2d57a1b24831c4e25699a2cf2326af.zip |
[Keymap] Add spidey3 keymap for 75_ansi, and a spidey3 userspace (#8470)
* First cut at Josh Diamond's KBD75 customizations.
Includes:
* My unique keymap with ChromeOS specific keys
* Use RGB underglow to indicate Caps Lock
* Some unicode bindings
* Some changes to make debugging easier
* Updated spidey3 to be applicable to all 75_ansi boards
* Sadly, ChromeOS doesn't pay attention to most consumer codes
* Add mac layer; fix flakeyness in CAPS_LOCK underglow.
* Make layers.json match the keymap (to the extent possible)
* Major cleanup; fix broken debug persistence
* Cleanup some whitespace issues
* Fix incorrect log message.
* Rework layer indication to user RGBLIGHT_LAYERS
* Update layouts/community/75_ansi/spidey3/keymap.c
Co-Authored-By: Drashna Jaelre <drashna@live.com>
* Rename users/spidey3/rgblight.c to layer_rgb.c per suggestion
* Refactor to use set_single_persistant_default_layer().
* Use dprint/f to make logging more elegant.
* Update users/spidey3/config.h
Co-Authored-By: Drashna Jaelre <drashna@live.com>
* Update users/spidey3/config.h
Co-Authored-By: Drashna Jaelre <drashna@live.com>
* Update layouts/community/75_ansi/spidey3/rules.mk
Co-Authored-By: Ryan <fauxpark@gmail.com>
* Update users/spidey3/spidey3.c
Co-Authored-By: Ryan <fauxpark@gmail.com>
* Update users/spidey3/layer_rgb.c
Co-Authored-By: Ryan <fauxpark@gmail.com>
* Update users/spidey3/init.c
Co-Authored-By: Ryan <fauxpark@gmail.com>
* Changes from code review
Co-authored-by: Joshua Diamond <jdiamond@Deep-Thought.local>
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Ryan <fauxpark@gmail.com>
Diffstat (limited to 'users/spidey3')
-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 0000000000..9da7f55302 --- /dev/null +++ b/users/spidey3/config.h @@ -0,0 +1,5 @@ +#pragma once + +#define LED_DISABLE_WHEN_USB_SUSPENDED true +#define RGB_DISABLE_WHEN_USB_SUSPENDED true +#define RGBLIGHT_LAYERS diff --git a/users/spidey3/init.c b/users/spidey3/init.c new file mode 100644 index 0000000000..a4be6113f4 --- /dev/null +++ b/users/spidey3/init.c @@ -0,0 +1,21 @@ +#include "spidey3.h" + +void keyboard_post_init_user(void) { + print("SPIDEY3: keyboard_post_init_user\n"); + uprintf(" debug_enable=%u\n", debug_enable); +#ifdef RGBLIGHT_ENABLE + keyboard_post_init_user_rgb(); +#endif +} + +void eeconfig_init_user(void) { + print("SPIDEY3: eeconfig_init_user\n"); + set_single_persistent_default_layer(_BASE); +#ifdef UNICODEMAP_ENABLE + eeconfig_init_user_unicode(); +#endif + +#ifdef RGBLIGHT_ENABLE + eeconfig_init_user_rgb(); +#endif +} diff --git a/users/spidey3/layer_rgb.c b/users/spidey3/layer_rgb.c new file mode 100644 index 0000000000..d80eb20a31 --- /dev/null +++ b/users/spidey3/layer_rgb.c @@ -0,0 +1,81 @@ +#include QMK_KEYBOARD_H + +#include "spidey3.h" +#include "velocikey.h" + +uint32_t rgb_mode; +uint16_t rgb_hue; +uint8_t rgb_sat; +uint8_t rgb_val; +bool rgb_saved = 0; + +void spidey_swirl(void) { + dprint("SPIDEY3: Setting Spidey Swirl!\n"); + rgblight_enable(); + rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); + rgblight_sethsv(213, 255, 128); +#ifdef VELOCIKEY_ENABLE + if (!velocikey_enabled()) + velocikey_toggle(); +#endif +} + +void eeconfig_init_user_rgb(void) +{ + spidey_swirl(); +} + +const rgblight_segment_t PROGMEM _capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS( {0, 2, HSV_AZURE}, {14, 2, HSV_AZURE} ); +const rgblight_segment_t PROGMEM _layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS( {7, 1, HSV_PURPLE} ); +const rgblight_segment_t PROGMEM _layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 2, HSV_GREEN} ); + +// Now define the array of layers. Later layers take precedence +const rgblight_segment_t* const PROGMEM _rgb_layers[] = RGBLIGHT_LAYERS_LIST( _capslock_layer, _layer1_layer, _layer2_layer ); +const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1; + +void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) { + dprint("SPIDEY3: do_rgb_layers()\n"); + for (uint8_t i=start; i<end; i++) { + bool is_on = layer_state_cmp(state, i); + dprintf(" layer[%d]=%u\n", i, is_on); + rgblight_set_layer_state(i, is_on); + } +} + +void keyboard_post_init_user_rgb(void) { + do_rgb_layers(default_layer_state, 1u, RGB_LAYER_BASE_REGULAR); + do_rgb_layers(layer_state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers); + // Enable the LED layers + rgblight_layers = _rgb_layers; +} + +layer_state_t default_layer_state_set_user_rgb(layer_state_t state) { + dprint("SPIDEY3: default_layer_state_set_user_rgb()\n"); + do_rgb_layers(state, 1u, RGB_LAYER_BASE_REGULAR); + return state; +} + +layer_state_t layer_state_set_user_rgb(layer_state_t state) { + dprint("SPIDEY3: layer_state_set_user_rgb()\n"); + do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers); + return state; +} + +bool led_update_user_rgb(led_t led_state) { + dprintf("SPIDEY3: caps_lock=%u\n", led_state.caps_lock); + rgblight_set_layer_state(0, led_state.caps_lock); + return true; +} + +bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { + + switch (keycode) { + case SPI_GLO: + if (record->event.pressed) { + spidey_swirl(); + } + break; + } + + return true; +} diff --git a/users/spidey3/readme.md b/users/spidey3/readme.md new file mode 100644 index 0000000000..409d6e5f81 --- /dev/null +++ b/users/spidey3/readme.md @@ -0,0 +1,14 @@ +Copyright 2020 Joshua Diamond josh@windowoffire.com @spidey3 + +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 <http://www.gnu.org/licenses/>. diff --git a/users/spidey3/rules.mk b/users/spidey3/rules.mk new file mode 100644 index 0000000000..0a77d2bfc7 --- /dev/null +++ b/users/spidey3/rules.mk @@ -0,0 +1,10 @@ + +SRC += init.c +SRC += spidey3.c + +ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) + SRC += layer_rgb.c +endif +ifeq ($(strip $(UNICODEMAP_ENABLE)), yes) + SRC += unicode.c +endif diff --git a/users/spidey3/spidey3.c b/users/spidey3/spidey3.c new file mode 100644 index 0000000000..d0b7947043 --- /dev/null +++ b/users/spidey3/spidey3.c @@ -0,0 +1,80 @@ +#include QMK_KEYBOARD_H + +#include "spidey3.h" + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + +// If console is enabled, it will print the matrix position and status of each key pressed +// dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); + + if (record->event.pressed) { + switch (keycode) { +#ifndef NO_DEBUG + // Re-implement this here, but fix the persistence! + case DEBUG: + debug_enable ^= 1; + if (debug_enable) { + print("DEBUG: enabled.\n"); + } else { + print("DEBUG: disabled.\n"); + } + eeconfig_update_debug(debug_config.raw); +#endif + return false; + case SPI_LNX: + dprint("SPIDEY3: SPI_LNX\n"); + set_single_persistent_default_layer(_BASE); + layer_off(_OSX); +#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) + set_unicode_input_mode(UC_LNX); +#endif + return false; + case SPI_OSX: + dprint("SPIDEY3: SPI_OSX\n"); + set_single_persistent_default_layer(_OSX); +#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) + set_unicode_input_mode(UC_OSX); +#endif + return false; + case SPI_WIN: + dprint("SPIDEY3: SPI_WIN\n"); + set_single_persistent_default_layer(_BASE); + layer_off(_OSX); +#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) + set_unicode_input_mode(UC_WINC); +#endif + return false; + } + } + +#ifdef RGBLIGHT_ENABLE + bool res = process_record_user_rgb(keycode, record); + if (!res) return false; +#endif + + return true; +} + +layer_state_t default_layer_state_set_user(layer_state_t state) { +#ifdef RGBLIGHT_ENABLE + return default_layer_state_set_user_rgb(state); +#else + return state; +#endif +} + +layer_state_t layer_state_set_user(layer_state_t state) { +#ifdef RGBLIGHT_ENABLE + return layer_state_set_user_rgb(state); +#else + return state; +#endif +} + +bool led_update_user(led_t led_state) { +#ifdef RGBLIGHT_ENABLE + return led_update_user_rgb(led_state); +#else + return true; +#endif +} diff --git a/users/spidey3/spidey3.h b/users/spidey3/spidey3.h new file mode 100644 index 0000000000..125f70a9ac --- /dev/null +++ b/users/spidey3/spidey3.h @@ -0,0 +1,40 @@ +#pragma once + +#include QMK_KEYBOARD_H + +#ifdef UNICODEMAP_ENABLE +#include "unicode.h" +#endif + +enum userspace_layers { + _BASE = 0, + _OSX, + _FN, +}; + +enum rgb_base_layer { + RGB_LAYER_BASE_DEFAULT = _BASE, + RGB_LAYER_BASE_REGULAR = _FN, +}; + +enum custom_keycodes { + SPI_GLO = SAFE_RANGE, + SPI_LNX, + SPI_OSX, + SPI_WIN, +}; + +#ifdef RGBLIGHT_ENABLE +void eeconfig_init_user_rgb(void); +void matrix_init_user_rgb(void); +void keyboard_post_init_user_rgb(void); +bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record); +layer_state_t layer_state_set_user_rgb(layer_state_t state); +layer_state_t default_layer_state_set_user_rgb(layer_state_t state); +bool led_update_user_rgb(led_t led_state); +#endif + +#ifdef UNICODEMAP_ENABLE +void eeconfig_init_user_unicode(void); +#endif + diff --git a/users/spidey3/unicode.c b/users/spidey3/unicode.c new file mode 100644 index 0000000000..41ceef8375 --- /dev/null +++ b/users/spidey3/unicode.c @@ -0,0 +1,19 @@ + +#include "unicode.h" + +const uint32_t PROGMEM unicode_map[] = { + [BUL1] = 0x2022, // • + [BUL2] = 0x25E6, // ◦ + [LARR] = 0x2190, // ← + [RARR] = 0x2192, // → + [ENDASH] = 0x2013, // – + [EMDASH] = 0x2014, // — +}; + +void eeconfig_init_user_unicode(void) +{ + // Default to Linux style + set_unicode_input_mode(UC_LNX); +} + + diff --git a/users/spidey3/unicode.h b/users/spidey3/unicode.h new file mode 100644 index 0000000000..72a91e8a80 --- /dev/null +++ b/users/spidey3/unicode.h @@ -0,0 +1,19 @@ +#pragma once + +#include QMK_KEYBOARD_H + +#ifdef UNICODEMAP_ENABLE + +enum unicode_names { + BUL1, + BUL2, + LARR, + RARR, + ENDASH, + EMDASH, +}; + +#define X_BUL (XP(BUL1, BUL2)) +#define X_DASH (XP(ENDASH, EMDASH)) + +#endif |