Major enhancements to spidey3 keymaps and userspace (#9261)

* Add Chrome OS specific keys to 75_ansi/spidey3

* Clean up duplicative settings in rules.mk

* Refactor spidey3 userspace to use rgb layer blink

* Blink green on wakeup

* Improve _FN layer indicator

* Glyph transformation modes: wide, script, fraktur, and enclosed characters

* Add spider unicode glyph

* Fix compile error when NO_ACTION_ONESHOT

* Add a few more emoji

* Further refinement of lighting layer usage

* Fix reversed yes/no ack

* Lighting layers override RGB off

* Fix missing wide and incorrect script numbers

* Add LOL and surprise emoji

* Add missing break in switch statement

* Trim firmware size

* Use usage ID definitions in report.h

* Some minor whitespace cleanup

* Disable some unused features to reduce firmware size

* Print version on startup

* Seed rand() on first keystroke

* Add a key to immediately sleep CrOS

* Switch to Bootmagic Lite

* Trim down firmware size a little bit more

* Make RGBLIGHT_MODE_TWINKLE+4 my default

* Scan rate debug / fix version printing

Delay printing version on startup (console may not be ready)
Better scan rate reporting

* Disable locking caps, etc. to save more space

* Enable LTO

* Better seed for rand()

* Set MAX_LAYER for some performance improvement

* Another scan rate improvement

* Set manufacturer

* New startup animation

* Add GUI lock for F-keys (for CrOS)

* Add visual indication for glyph replacement and F-keys GUI lock

* Some cleanup; run cformat on spidey3 userspace

* Cycle between debug verbosity options

* Fix disable RGB Lighting after wakeup on Mac
This commit is contained in:
Joshua Diamond 2020-06-05 05:01:47 -04:00 committed by GitHub
parent c12e429da2
commit d03bc3a9c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 588 additions and 183 deletions

View file

@ -0,0 +1,9 @@
#pragma once
#define NO_ACTION_ONESHOT
#define NO_ACTION_MACRO
#define NO_ACTION_FUNCTION
#undef LOCKING_SUPPORT_ENABLE
#define LAYER_STATE_8BIT
#define MAX_LAYER 4

View file

@ -1,6 +1,5 @@
#include "spidey3.h" #include "spidey3.h"
#define CH_MENU A(S(KC_S))
#define OSX_PSC G(S(KC_4)) #define OSX_PSC G(S(KC_4))
#define FN_MENU LT(_FN,KC_APP) #define FN_MENU LT(_FN,KC_APP)
@ -34,11 +33,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
), ),
// FN // FN
[_FN] = LAYOUT_75_ansi( [_FN] = LAYOUT_75_ansi(
RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_SLEP, KC_WAKE, KC_PWR, RESET, SPI_NORMAL, SPI_WIDE, SPI_SCRIPT, SPI_BLOCKS, SPI_CIRCLE, SPI_SQUARE, SPI_PARENS, SPI_FRAKTR, _______, _______, _______, SPI_GFLOCK, KC_SLEP, KC_WAKE, KC_PWR,
EEP_RST, _______, _______, _______, _______, _______, _______, _______, X_BUL, KC_MPRV, KC_MNXT, X_DASH, _______, KC_PAUS, KC_SLCK, EEP_RST, X(SAD), X(MEH), X(HAPPY), X(ANGRY), X(THUMBDN), X(THUMBUP), X(SPIDER), X_BUL, X(LOL), X(SURPRISE),X_DASH, _______, KC_PAUS, KC_SLCK,
_______, RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, RGB_SPD, RGB_SPI, VLK_TOG, _______, _______, KC_BRIU, _______, RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, RGB_SPD, RGB_SPI, VLK_TOG, _______, _______, KC_BRIU,
_______, 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_BRID, _______, 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_BRID,
_______, SPI_GLO, _______, SPI_WIN, _______, NK_TOGG, TG(_NUMPAD),SPI_OSX, X(LARR), X(RARR), DEBUG, _______, KC_VOLU, KC_MUTE, _______, SPI_GLO, CH_SUSP, SPI_WIN, _______, NK_TOGG, TG(_NUMPAD),SPI_OSX, X(LARR), X(RARR), DEBUG, _______, KC_VOLU, KC_MUTE,
_______, _______, _______, KC_MPLY, KC_APP, _______, CH_MENU, KC_MPRV, KC_VOLD, KC_MNXT _______, _______, _______, KC_MPLY, CH_ASST, _______, CH_CPNL, KC_MPRV, KC_VOLD, KC_MNXT
) )
}; };

View file

@ -1,18 +1,12 @@
# Build Options # Build Options
# comment out to disable the options. # comment out to disable the options.
# #
BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration
MOUSEKEY_ENABLE = no # Mouse keys MOUSEKEY_ENABLE = no # Mouse keys
EXTRAKEY_ENABLE = yes # Audio control and System control
CONSOLE_ENABLE = yes # Console for debug 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 BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
AUDIO_ENABLE = no
RGBLIGHT_ENABLE = yes
UNICODEMAP_ENABLE = yes UNICODEMAP_ENABLE = yes
VELOCIKEY_ENABLE = yes VELOCIKEY_ENABLE = yes
GRAVE_ESC_ENABLE = no
# The following disabled to save space # The following disabled to save space
SPACE_CADET_ENABLE = no SPACE_CADET_ENABLE = no

View file

@ -3,3 +3,21 @@
#define LED_DISABLE_WHEN_USB_SUSPENDED true #define LED_DISABLE_WHEN_USB_SUSPENDED true
#define RGB_DISABLE_WHEN_USB_SUSPENDED true #define RGB_DISABLE_WHEN_USB_SUSPENDED true
#define RGBLIGHT_LAYERS #define RGBLIGHT_LAYERS
#define RGBLIGHT_MAX_LAYERS 16
#define RGBLIGHT_LAYER_BLINK
#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
#undef RGBLIGHT_ANIMATIONS
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_SNAKE
#define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_ALTERNATING
#define RGBLIGHT_EFFECT_TWINKLE
#define SPI_DEBUG_SCAN_RATE
#undef MANUFACTURER
#define MANUFACTURER Window of Fire

View file

@ -1,8 +1,6 @@
#include "spidey3.h" #include "spidey3.h"
void keyboard_post_init_user(void) { void keyboard_post_init_user(void) {
print("keyboard_post_init_user\n");
uprintf("\tdebug_enable=%u\n", debug_enable);
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
keyboard_post_init_user_rgb(); keyboard_post_init_user_rgb();
#endif #endif

View file

@ -9,123 +9,276 @@ uint8_t rgb_sat;
uint8_t rgb_val; uint8_t rgb_val;
bool rgb_saved = 0; bool rgb_saved = 0;
void spidey_swirl(void) { void spidey_glow(void) {
dprint("Setting Spidey Swirl!\n");
rgblight_enable(); rgblight_enable();
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); rgblight_mode(RGBLIGHT_MODE_TWINKLE + 4);
rgblight_sethsv(213, 255, 128); rgblight_sethsv(213, 255, 128);
#ifdef VELOCIKEY_ENABLE #ifdef VELOCIKEY_ENABLE
if (!velocikey_enabled()) if (velocikey_enabled()) velocikey_toggle();
velocikey_toggle();
#endif #endif
} }
void eeconfig_init_user_rgb(void) void eeconfig_init_user_rgb(void) { spidey_glow(); }
{
spidey_swirl();
}
const rgblight_segment_t PROGMEM _capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS( {0, 2, HSV_AZURE}, {14, 2, HSV_AZURE} ); // clang-format off
const rgblight_segment_t PROGMEM _layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS( {7, 1, HSV_PURPLE} );
const rgblight_segment_t PROGMEM _layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS( {10, 3, HSV_MAGENTA} ); // Convenience macros
const rgblight_segment_t PROGMEM _layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS( {10, 1, HSV_GREEN} ); #define CORNER_BL(color) { 0, 1, color }
const rgblight_segment_t PROGMEM _yes_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 6, HSV_GREEN} ); #define CORNER_BR(color) { RGBLED_NUM / 2 - 1, 1, color }
const rgblight_segment_t PROGMEM _no_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 6, HSV_RED} ); #define CORNER_FR(color) { RGBLED_NUM / 2, 1, color }
#define CORNER_FL(color) { RGBLED_NUM - 1, 1, color }
#define CORNERS(color) {0, 1, color}, {RGBLED_NUM / 2 - 1, 2, color}, { RGBLED_NUM - 1, 1, color }
#define FRONT(inset, color) { RGBLED_NUM / 2 + inset, RGBLED_NUM / 2 - 2 * inset, color }
#define BACK(inset, color) { inset, RGBLED_NUM / 2 - 2 * inset, color }
#define LAYER_OFFSET 0
const rgblight_segment_t PROGMEM _layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNER_BR(HSV_PURPLE));
const rgblight_segment_t PROGMEM _layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNERS(HSV_MAGENTA));
const rgblight_segment_t PROGMEM _layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNERS(HSV_GREEN));
#define LOCK_OFFSET 3
const rgblight_segment_t PROGMEM _numlock_layer[] = RGBLIGHT_LAYER_SEGMENTS(FRONT(3, HSV_YELLOW));
const rgblight_segment_t PROGMEM _capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNER_FL(HSV_AZURE));
const rgblight_segment_t PROGMEM _scrolllock_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNER_FR(HSV_ORANGE));
#define MISC_OFFSET 6
const rgblight_segment_t PROGMEM _gflock_layer[] = RGBLIGHT_LAYER_SEGMENTS(BACK(1, HSV_ORANGE));
const rgblight_segment_t PROGMEM _glyphreplace_layer[] = RGBLIGHT_LAYER_SEGMENTS(FRONT(1, HSV_ORANGE));
#define ACK_OFFSET 8
const rgblight_segment_t PROGMEM _no_layer[] = RGBLIGHT_LAYER_SEGMENTS(FRONT(1, HSV_RED));
const rgblight_segment_t PROGMEM _yes_layer[] = RGBLIGHT_LAYER_SEGMENTS(FRONT(1, HSV_GREEN));
const rgblight_segment_t PROGMEM _meh_layer[] = RGBLIGHT_LAYER_SEGMENTS(FRONT(1, HSV_YELLOW));
// Now define the array of layers. Higher numbered layers take precedence.
const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
[LAYER_OFFSET + 0] = _layer1_layer,
[LAYER_OFFSET + 1] = _layer2_layer,
[LAYER_OFFSET + 2] = _layer3_layer,
[LOCK_OFFSET + USB_LED_NUM_LOCK] = _numlock_layer,
[LOCK_OFFSET + USB_LED_CAPS_LOCK] = _capslock_layer,
[LOCK_OFFSET + USB_LED_SCROLL_LOCK] = _scrolllock_layer,
[MISC_OFFSET + 0] = _gflock_layer,
[MISC_OFFSET + 1] = _glyphreplace_layer,
[ACK_OFFSET + ACK_NO] = _no_layer,
[ACK_OFFSET + ACK_YES] = _yes_layer,
[ACK_OFFSET + ACK_MEH] = _meh_layer,
[ACK_OFFSET + ACK_MEH + 1] = NULL
};
// clang-format on
// 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, _layer3_layer, _yes_layer, _no_layer );
const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1; const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1;
void clear_rgb_layers() { void clear_rgb_layers() {
for (uint8_t i=0; i<_n_rgb_layers; i++) { dprint("clear_rgb_layers()\n");
for (uint8_t i = 0; i < _n_rgb_layers; i++) {
rgblight_set_layer_state(i, false); rgblight_set_layer_state(i, false);
} }
} }
void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) { void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) {
dprint("do_rgb_layers()\n"); for (uint8_t i = start; i < end; i++) {
for (uint8_t i=start; i<end; i++) {
bool is_on = layer_state_cmp(state, i); bool is_on = layer_state_cmp(state, i);
dprintf("\tlayer[%d]=%u\n", i, is_on); dprintf("layer[%u]=%u\n", i, is_on);
rgblight_set_layer_state(i, is_on); rgblight_set_layer_state(LAYER_OFFSET + i - 1, is_on);
} }
} }
extern rgblight_config_t rgblight_config;
extern rgblight_status_t rgblight_status;
static bool startup_animation_done = false;
void keyboard_post_init_user_rgb(void) { 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, RGB_LAYER_BASE_ACKS);
do_rgb_layers(0, RGB_LAYER_BASE_ACKS, _n_rgb_layers);
// Enable the LED layers // Enable the LED layers
rgblight_layers = _rgb_layers; rgblight_layers = _rgb_layers;
do_rgb_layers(default_layer_state, LAYER_BASE_DEFAULT + 1, LAYER_BASE_REGULAR);
do_rgb_layers(layer_state, LAYER_BASE_REGULAR, LAYER_BASE_END);
// Startup animation
{
bool is_enabled = rgblight_config.enable;
uint8_t old_hue = rgblight_config.hue;
uint8_t old_sat = rgblight_config.sat;
uint8_t old_val = rgblight_config.val;
uint8_t old_mode = rgblight_config.mode;
bool ramp_down =
#ifdef RGBLIGHT_EFFECT_BREATHING
(rgblight_status.base_mode == RGBLIGHT_MODE_BREATHING) ||
#endif
#ifdef RGBLIGHT_EFFECT_SNAKE
(rgblight_status.base_mode == RGBLIGHT_MODE_SNAKE) ||
#endif
#ifdef RGBLIGHT_EFFECT_KNIGHT
(rgblight_status.base_mode == RGBLIGHT_MODE_KNIGHT) ||
#endif
#ifdef RGBLIGHT_EFFECT_TWINKLE
(rgblight_status.base_mode == RGBLIGHT_MODE_TWINKLE) ||
#endif
!is_enabled;
bool ramp_to =
#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
(rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) ||
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
(rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) ||
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
(rgblight_status.base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) ||
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_CHRISTMAS
(rgblight_status.base_mode == RGBLIGHT_MODE_CHRISTMAS) ||
#endif
#ifdef RGBLIGHT_EFFECT_RAINBOW_RGB_TEST_
(rgblight_status.base_mode == RGBLIGHT_MODE_RGB_TEST) ||
#endif
(rgblight_status.base_mode == RGBLIGHT_MODE_STATIC_LIGHT);
#define STARTUP_ANIMATION_SATURATION 200
#define STARTUP_ANIMATION_VALUE 255
#define STARTUP_ANIMATION_STEP 5
rgblight_enable_noeeprom();
if (rgblight_config.enable) {
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
for (uint8_t i = 0; i < STARTUP_ANIMATION_VALUE; i += STARTUP_ANIMATION_STEP) {
rgblight_sethsv_noeeprom(old_hue, STARTUP_ANIMATION_SATURATION, i);
matrix_scan();
wait_ms(10);
}
for (uint8_t i = 255; i > 0; i -= STARTUP_ANIMATION_STEP) {
rgblight_sethsv_noeeprom((i + old_hue) % 255, STARTUP_ANIMATION_SATURATION, STARTUP_ANIMATION_VALUE);
matrix_scan();
wait_ms(10);
}
if (ramp_down) {
dprintln("ramp_down");
for (uint8_t i = STARTUP_ANIMATION_VALUE; i > 0; i -= STARTUP_ANIMATION_STEP) {
rgblight_sethsv_noeeprom(old_hue, STARTUP_ANIMATION_SATURATION, i);
matrix_scan();
wait_ms(10);
}
} else if (ramp_to) {
dprintf("ramp_to s=%u, v=%u\n", old_sat, old_val);
uint8_t steps = 50;
for (uint8_t i = 0; i < steps; i++) {
uint8_t s = STARTUP_ANIMATION_SATURATION + i * (((float)old_sat - STARTUP_ANIMATION_SATURATION) / (float)steps);
uint8_t v = STARTUP_ANIMATION_VALUE + i * (((float)old_val - STARTUP_ANIMATION_VALUE) / (float)steps);
rgblight_sethsv_noeeprom(old_hue, s, v);
matrix_scan();
wait_ms(10);
}
}
rgblight_mode_noeeprom(old_mode);
}
if (is_enabled) {
rgblight_sethsv_noeeprom(old_hue, old_sat, old_val);
} else {
rgblight_disable_noeeprom();
// Hack!
// rgblight_sethsv_noeeprom() doesn't update these if rgblight is disabled,
// but if do it before disabling we get an ugly flash.
rgblight_config.hue = old_hue;
rgblight_config.sat = old_sat;
rgblight_config.val = old_val;
}
dprint("done\n");
startup_animation_done = true;
}
} }
layer_state_t default_layer_state_set_user_rgb(layer_state_t state) { layer_state_t default_layer_state_set_user_rgb(layer_state_t state) {
dprint("default_layer_state_set_user_rgb()\n"); do_rgb_layers(state, 1u, LAYER_BASE_REGULAR);
do_rgb_layers(state, 1u, RGB_LAYER_BASE_REGULAR);
return state; return state;
} }
layer_state_t layer_state_set_user_rgb(layer_state_t state) { layer_state_t layer_state_set_user_rgb(layer_state_t state) {
dprint("layer_state_set_user_rgb()\n"); do_rgb_layers(state, LAYER_BASE_REGULAR, LAYER_BASE_END);
do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, RGB_LAYER_BASE_ACKS);
return state; return state;
} }
bool led_update_user_rgb(led_t led_state) { bool led_update_user_rgb(led_t led_state) {
dprintf("caps_lock=%u\n", led_state.caps_lock); dprintf("num=%u, cap=%u, scl=%u, cmp=%u, kan=%u\n", led_state.num_lock, led_state.caps_lock, led_state.scroll_lock, led_state.compose, led_state.kana);
rgblight_set_layer_state(0, led_state.caps_lock);
rgblight_set_layer_state(LOCK_OFFSET + USB_LED_NUM_LOCK, led_state.num_lock);
rgblight_set_layer_state(LOCK_OFFSET + USB_LED_CAPS_LOCK, led_state.caps_lock);
rgblight_set_layer_state(LOCK_OFFSET + USB_LED_SCROLL_LOCK, led_state.scroll_lock);
return true; return true;
} }
void rgb_layer_ack(bool yn, bool pressed) { void rgb_layer_ack_yn(bool yn) { rgb_layer_ack(yn ? ACK_YES : ACK_NO); }
uint8_t layer = RGB_LAYER_BASE_ACKS + (yn ? 0 : 1);
rgblight_set_layer_state(layer, pressed); void rgb_layer_ack(layer_ack_t n) {
uint8_t layer = ACK_OFFSET + n;
dprintf("rgb_layer_ack(%u) ==> %u\n", n, layer);
rgblight_blink_layer(layer, RGB_LAYER_ACK_DURATION);
} }
extern keymap_config_t keymap_config; extern keymap_config_t keymap_config;
extern rgblight_config_t rgblight_config;
extern bool spi_gflock;
extern uint16_t spi_replace_mode;
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
bool pressed = record->event.pressed; if (record->event.pressed) {
switch (keycode) { switch (keycode) {
case SPI_GLO: case SPI_GLO:
if (pressed) { spidey_glow();
spidey_swirl();
}
return false; return false;
}
}
return true;
}
void post_process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
// Acks follow... // Acks follow...
case DEBUG: case DEBUG:
rgb_layer_ack(debug_enable, pressed); rgb_layer_ack_yn(debug_enable);
return false; break;
case SPI_LNX: case SPI_LNX:
case SPI_OSX: case SPI_OSX:
case SPI_WIN: case SPI_WIN:
rgb_layer_ack(true, pressed); rgb_layer_ack(ACK_MEH);
return false; break;
// Tricky! case SPI_GFLOCK:
// For these, on press the toggle hasn't happened yet, rgb_layer_ack_yn(spi_gflock);
// so we need a little logic to invert, assuming that rgblight_set_layer_state(MISC_OFFSET + 0, spi_gflock);
// on key press the flag WILL be toggled, and on key break;
// release the flag has already been toggled.
case SPI_NORMAL ... SPI_FRAKTR:
rgb_layer_ack_yn(spi_replace_mode != SPI_NORMAL);
rgblight_set_layer_state(MISC_OFFSET + 1, spi_replace_mode != SPI_NORMAL);
break;
case RGB_TOG:
rgb_layer_ack_yn(rgblight_config.enable);
break;
#ifdef VELOCIKEY_ENABLE #ifdef VELOCIKEY_ENABLE
case VLK_TOG: case VLK_TOG:
rgb_layer_ack(pressed != velocikey_enabled(), pressed); rgb_layer_ack_yn(velocikey_enabled());
return true; break;
#endif #endif
#ifdef NKRO_ENABLE #ifdef NKRO_ENABLE
case NK_TOGG: case NK_TOGG:
case NK_ON: case NK_ON:
case NK_OFF: case NK_OFF:
rgb_layer_ack(pressed != keymap_config.nkro, pressed); rgb_layer_ack_yn(keymap_config.nkro);
return true; break;
#endif #endif
} }
return true;
} }

View file

@ -1,3 +1,5 @@
BOOTMAGIC_ENABLE = lite
LTO_ENABLE = yes
SRC += init.c SRC += init.c
SRC += spidey3.c SRC += spidey3.c

View file

@ -1,26 +1,164 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
#include "spidey3.h" #include "spidey3.h"
#include "version.h"
#include <stdlib.h>
static bool rand_seeded = false;
uint16_t spi_replace_mode = SPI_NORMAL;
bool spi_gflock = false;
#if defined(CONSOLE_ENABLE) && !defined(NO_DEBUG)
static uint32_t matrix_scan_count = 0;
static bool reported_version = false;
# if defined(SPI_DEBUG_SCAN_RATE)
static uint32_t matrix_timer = 0;
static uint32_t last_matrix_scan_count = 0;
# endif
void matrix_scan_user(void) {
# if defined(SPI_DEBUG_SCAN_RATE)
matrix_scan_count++;
if (debug_enable) {
uint32_t timer_now = timer_read32();
if (matrix_timer == 0) {
matrix_timer = timer_now;
last_matrix_scan_count = matrix_scan_count;
matrix_scan_count = 0;
} else if (TIMER_DIFF_32(timer_now, matrix_timer) > SPI_SCAN_RATE_INTERVAL * 1000) {
matrix_timer = timer_now;
last_matrix_scan_count = matrix_scan_count;
matrix_scan_count = 0;
if (!reported_version) {
uprintln(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE);
reported_version = true;
}
uprintf("scan rate: %lu/s\n", last_matrix_scan_count / SPI_SCAN_RATE_INTERVAL);
}
}
# else
if (!reported_version) {
matrix_scan_count++;
if (matrix_scan_count > 300) {
uprintln(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE);
reported_version = true;
}
}
# endif
}
#endif
bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uint32_t baseAlphaLower, uint32_t baseAlphaUpper, uint32_t zeroGlyph, uint32_t baseNumberOne, uint32_t spaceGlyph) {
uint8_t temp_mod = get_mods();
#ifndef NO_ACTION_ONESHOT
uint8_t temp_osm = get_oneshot_mods();
#else
uint8_t temp_osm = 0;
#endif
if ((((temp_mod | temp_osm) & (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI))) == 0) {
switch (keycode) {
case KC_A ... KC_Z:
if (record->event.pressed) {
clear_mods();
#ifndef NO_ACTION_ONESHOT
clear_oneshot_mods();
#endif
unicode_input_start();
uint32_t base = ((temp_mod | temp_osm) & MOD_MASK_SHIFT) ? baseAlphaUpper : baseAlphaLower;
register_hex32(base + (keycode - KC_A));
unicode_input_finish();
set_mods(temp_mod);
}
return false;
case KC_0:
if ((temp_mod | temp_osm) & MOD_MASK_SHIFT) { // skip shifted numbers, so that we can still use symbols etc.
return true;
}
if (record->event.pressed) {
unicode_input_start();
register_hex32(zeroGlyph);
unicode_input_finish();
}
return false;
case KC_1 ... KC_9:
if ((temp_mod | temp_osm) & MOD_MASK_SHIFT) { // skip shifted numbers, so that we can still use symbols etc.
return true;
}
if (record->event.pressed) {
unicode_input_start();
register_hex32(baseNumberOne + (keycode - KC_1));
unicode_input_finish();
}
return false;
case KC_SPACE:
if (record->event.pressed) {
unicode_input_start();
register_hex32(spaceGlyph); // em space
unicode_input_finish();
}
return false;
}
}
return true;
}
bool process_gflock(uint16_t keycode, keyrecord_t *record) {
if (!spi_gflock) {
return true;
}
if (record->event.pressed) {
register_code16(G(keycode));
} else {
unregister_code16(G(keycode));
}
return false;
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!rand_seeded) {
// If console is enabled, it will print the matrix position and status of each key pressed srand(record->event.time % keycode);
// dprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); rand_seeded = true;
}
if (record->event.pressed) { if (record->event.pressed) {
switch (keycode) { switch (keycode) {
#ifndef NO_DEBUG #ifndef NO_DEBUG
// Re-implement this here, but fix the persistence! // Re-implement this here, but fix the persistence!
case DEBUG: case DEBUG:
debug_enable ^= 1; if (!debug_enable) {
if (debug_enable) { debug_enable = 1;
print("DEBUG: enabled.\n"); # if defined(SPI_DEBUG_SCAN_RATE)
matrix_timer = 0;
reported_version = false;
# endif
} else if (!debug_keyboard) {
debug_keyboard = 1;
} else if (!debug_matrix) {
debug_matrix = 1;
} else { } else {
print("DEBUG: disabled.\n"); debug_enable = 0;
debug_keyboard = 0;
debug_matrix = 0;
} }
uprintf("DEBUG: enable=%u, keyboard=%u, matrix=%u\n", debug_enable, debug_keyboard, debug_matrix);
eeconfig_update_debug(debug_config.raw); eeconfig_update_debug(debug_config.raw);
return false;
#endif #endif
break;
// clang-format off
case CH_CPNL: host_consumer_send(AL_CONTROL_PANEL); return false;
case CH_ASST: host_consumer_send(AL_ASSISTANT); return false;
case CH_SUSP: tap_code16(LGUI(LSFT(KC_L))); return true;
// clang-format on
case SPI_LNX: case SPI_LNX:
dprint("SPI_LNX\n"); dprint("SPI_LNX\n");
set_single_persistent_default_layer(_BASE); set_single_persistent_default_layer(_BASE);
@ -44,15 +182,64 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
set_unicode_input_mode(UC_WINC); set_unicode_input_mode(UC_WINC);
#endif #endif
break; break;
case SPI_NORMAL ... SPI_FRAKTR:
spi_replace_mode = (spi_replace_mode == keycode) ? SPI_NORMAL : keycode;
dprintf("spi_replace_mode = %u\n", spi_replace_mode);
break;
case SPI_GFLOCK:
spi_gflock = !spi_gflock;
dprintf("spi_gflock = %u\n", spi_gflock);
break;
} }
} else {
switch (keycode) {
case CH_CPNL:
case CH_ASST:
host_consumer_send(0);
return false;
}
}
switch (keycode) {
case KC_A ... KC_0:
case KC_SPACE:
switch (spi_replace_mode) {
case SPI_WIDE:
return process_record_glyph_replacement(keycode, record, 0xFF41, 0xFF21, 0xFF10, 0xFF11, 0x2003);
case SPI_SCRIPT:
return process_record_glyph_replacement(keycode, record, 0x1D4EA, 0x1D4D0, 0x1D7CE, 0x1D7CF, 0x2002);
case SPI_BLOCKS:
return process_record_glyph_replacement(keycode, record, 0x1F170, 0x1F170, '0', '1', 0x2002);
case SPI_CIRCLE:
return process_record_glyph_replacement(keycode, record, 0x1F150, 0x1F150, '0', '1', 0x2002);
case SPI_SQUARE:
return process_record_glyph_replacement(keycode, record, 0x1F130, 0x1F130, '0', '1', 0x2002);
case SPI_PARENS:
return process_record_glyph_replacement(keycode, record, 0x1F110, 0x1F110, '0', '1', 0x2002);
case SPI_FRAKTR:
return process_record_glyph_replacement(keycode, record, 0x1D586, 0x1D56C, '0', '1', 0x2002);
}
break;
case KC_F1 ... KC_F24:
return process_gflock(keycode, record);
} }
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
bool res = process_record_user_rgb(keycode, record); bool res = process_record_user_rgb(keycode, record);
if (res) return true; if (!res) return false;
#endif #endif
return false; return true;
}
void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
#ifdef RGBLIGHT_ENABLE
post_process_record_user_rgb(keycode, record);
#endif
return;
} }
layer_state_t default_layer_state_set_user(layer_state_t state) { layer_state_t default_layer_state_set_user(layer_state_t state) {

View file

@ -3,7 +3,7 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
#ifdef UNICODEMAP_ENABLE #ifdef UNICODEMAP_ENABLE
#include "unicode.h" # include "unicode.h"
#endif #endif
enum userspace_layers { enum userspace_layers {
@ -13,27 +13,52 @@ enum userspace_layers {
_FN, _FN,
}; };
enum rgb_base_layer {
RGB_LAYER_BASE_DEFAULT = _BASE,
RGB_LAYER_BASE_REGULAR = _NUMPAD,
RGB_LAYER_BASE_ACKS = _FN+1,
};
enum custom_keycodes { enum custom_keycodes {
SPI_GLO = SAFE_RANGE, SPI_GLO = SAFE_RANGE,
SPI_LNX, SPI_LNX, // Mode: Linux
SPI_OSX, SPI_OSX, // Mode: Mac
SPI_WIN, SPI_WIN, // Mode: Windows
CH_CPNL, // AL Control Panel
CH_ASST, // AL Context-aware Desktop Assistant
CH_SUSP, // Suspend
SPI_NORMAL,
SPI_WIDE,
SPI_SCRIPT,
SPI_BLOCKS,
SPI_CIRCLE,
SPI_SQUARE,
SPI_PARENS,
SPI_FRAKTR,
SPI_GFLOCK,
}; };
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
enum layer_base {
LAYER_BASE_DEFAULT = _BASE,
LAYER_BASE_REGULAR = _NUMPAD,
LAYER_BASE_END = _FN + 1,
};
typedef enum layer_ack {
ACK_NO = 0,
ACK_YES,
ACK_MEH,
} layer_ack_t;
# define RGB_LAYER_ACK_DURATION 500
void eeconfig_init_user_rgb(void); void eeconfig_init_user_rgb(void);
void matrix_init_user_rgb(void); void matrix_init_user_rgb(void);
void keyboard_post_init_user_rgb(void); void keyboard_post_init_user_rgb(void);
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record); bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record);
void post_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 layer_state_set_user_rgb(layer_state_t state);
layer_state_t default_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); bool led_update_user_rgb(led_t led_state);
void rgb_layer_ack(layer_ack_t n);
void rgb_layer_ack_yn(bool yn);
void clear_rgb_layers(void); void clear_rgb_layers(void);
#endif #endif
@ -41,3 +66,8 @@ void clear_rgb_layers(void);
void eeconfig_init_user_unicode(void); void eeconfig_init_user_unicode(void);
#endif #endif
#ifdef SPI_DEBUG_SCAN_RATE
# ifndef SPI_SCAN_RATE_INTERVAL
# define SPI_SCAN_RATE_INTERVAL 10
# endif
#endif

View file

@ -8,12 +8,18 @@ const uint32_t PROGMEM unicode_map[] = {
[RARR] = 0x2192, // → [RARR] = 0x2192, // →
[ENDASH] = 0x2013, // [ENDASH] = 0x2013, //
[EMDASH] = 0x2014, // — [EMDASH] = 0x2014, // —
[SPIDER] = 0x1F577, // 🕷
[SAD] = 0x2639, // ☹
[MEH] = 0x1F611, // 😑
[HAPPY] = 0x1F600, // 😀
[ANGRY] = 0x1F620, // 😠
[THUMBUP] = 0x1F44D, // 👍
[THUMBDN] = 0x1F44E, // 👎
[LOL] = 0x1F602, // 😂
[SURPRISE] = 0x1F62E, // 😮
}; };
void eeconfig_init_user_unicode(void) void eeconfig_init_user_unicode(void) {
{
// Default to Linux style // Default to Linux style
set_unicode_input_mode(UC_LNX); set_unicode_input_mode(UC_LNX);
} }

View file

@ -11,9 +11,18 @@ enum unicode_names {
RARR, RARR,
ENDASH, ENDASH,
EMDASH, EMDASH,
SPIDER,
SAD,
MEH,
HAPPY,
ANGRY,
THUMBUP,
THUMBDN,
LOL,
SURPRISE,
}; };
#define X_BUL (XP(BUL1, BUL2)) # define X_BUL (XP(BUL1, BUL2))
#define X_DASH (XP(ENDASH, EMDASH)) # define X_DASH (XP(ENDASH, EMDASH))
#endif #endif