diff --git a/layouts/community/75_ansi/spidey3/keymap.c b/layouts/community/75_ansi/spidey3/keymap.c new file mode 100644 index 0000000000..511fea28d8 --- /dev/null +++ b/layouts/community/75_ansi/spidey3/keymap.c @@ -0,0 +1,33 @@ +#include "spidey3.h" + +#define SETTINGS A(S(KC_S)) + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + // Linux / Win layout + [_BASE] = LAYOUT_75_ansi( + KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, SETTINGS, KC_INS, KC_DEL, + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + // OSX layout + [_OSX] = LAYOUT_75_ansi( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_EJCT, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, KC_LALT, KC_LGUI, _______, _______, _______, _______, _______, _______, _______ + ), + // FN + [_FN] = LAYOUT_75_ansi( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PWR, + _______, _______, _______, _______, _______, _______, _______, _______, X_BUL, _______, _______, X_DASH, _______, RESET, EEP_RST, + _______, RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, RGB_SPD, RGB_SPI, VLK_TOG, _______, _______, KC_VOLU, + _______, RGB_M_P, RGB_M_B, RGB_M_R, RGB_M_SW, RGB_M_SN, RGB_M_K, RGB_M_G, RGB_M_T, SPI_LNX, _______, _______, _______, KC_VOLD, + _______, SPI_GLO, _______, SPI_WIN, _______, _______, _______, SPI_OSX, X(LARR), X(RARR), DEBUG, _______, KC_BRIU, KC_MUTE, + _______, _______, _______, _______, _______, _______, _______, _______, KC_BRID, _______ + ) +}; diff --git a/layouts/community/75_ansi/spidey3/readme.md b/layouts/community/75_ansi/spidey3/readme.md new file mode 100644 index 0000000000..409d6e5f81 --- /dev/null +++ b/layouts/community/75_ansi/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 . diff --git a/layouts/community/75_ansi/spidey3/rules.mk b/layouts/community/75_ansi/spidey3/rules.mk new file mode 100644 index 0000000000..d9ac1126ce --- /dev/null +++ b/layouts/community/75_ansi/spidey3/rules.mk @@ -0,0 +1,15 @@ +# Build Options +# comment out to disable the options. +# +BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration +MOUSEKEY_ENABLE = no # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +AUDIO_ENABLE = no +RGBLIGHT_ENABLE = yes +UNICODEMAP_ENABLE = yes +VELOCIKEY_ENABLE = yes 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; ievent.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 . 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