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 Macpre-develop-merge-nov20
parent
c12e429da2
commit
d03bc3a9c1
@ -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 |
@ -1,18 +1,12 @@ |
||||
# 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
|
||||
GRAVE_ESC_ENABLE = no
|
||||
|
||||
# The following disabled to save space
|
||||
SPACE_CADET_ENABLE = no
|
||||
|
@ -1,30 +1,28 @@ |
||||
#include "spidey3.h" |
||||
|
||||
void keyboard_post_init_user(void) { |
||||
print("keyboard_post_init_user\n"); |
||||
uprintf("\tdebug_enable=%u\n", debug_enable); |
||||
#ifdef RGBLIGHT_ENABLE |
||||
keyboard_post_init_user_rgb(); |
||||
keyboard_post_init_user_rgb(); |
||||
#endif |
||||
} |
||||
|
||||
void eeconfig_init_user(void) { |
||||
print("eeconfig_init_user\n"); |
||||
set_single_persistent_default_layer(_BASE); |
||||
print("eeconfig_init_user\n"); |
||||
set_single_persistent_default_layer(_BASE); |
||||
#ifdef UNICODEMAP_ENABLE |
||||
eeconfig_init_user_unicode(); |
||||
eeconfig_init_user_unicode(); |
||||
#endif |
||||
|
||||
#ifdef RGBLIGHT_ENABLE |
||||
eeconfig_init_user_rgb(); |
||||
eeconfig_init_user_rgb(); |
||||
#endif |
||||
} |
||||
|
||||
void shutdown_user() { |
||||
#ifdef RGBLIGHT_ENABLE |
||||
clear_rgb_layers(); |
||||
rgblight_enable(); |
||||
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); |
||||
rgblight_sethsv_noeeprom(HSV_RED); |
||||
clear_rgb_layers(); |
||||
rgblight_enable(); |
||||
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); |
||||
rgblight_sethsv_noeeprom(HSV_RED); |
||||
#endif |
||||
} |
||||
|
@ -1,80 +1,267 @@ |
||||
#include QMK_KEYBOARD_H |
||||
|
||||
#include "spidey3.h" |
||||
#include "version.h" |
||||
#include <stdlib.h> |
||||
|
||||
bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
||||
static bool rand_seeded = false; |
||||
|
||||
// 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);
|
||||
uint16_t spi_replace_mode = SPI_NORMAL; |
||||
bool spi_gflock = false; |
||||
|
||||
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"); |
||||
#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; |
||||
} |
||||
eeconfig_update_debug(debug_config.raw); |
||||
} |
||||
# 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) { |
||||
if (!rand_seeded) { |
||||
srand(record->event.time % keycode); |
||||
rand_seeded = true; |
||||
} |
||||
|
||||
if (record->event.pressed) { |
||||
switch (keycode) { |
||||
#ifndef NO_DEBUG |
||||
// Re-implement this here, but fix the persistence!
|
||||
case DEBUG: |
||||
if (!debug_enable) { |
||||
debug_enable = 1; |
||||
# 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 { |
||||
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); |
||||
return false; |
||||
#endif |
||||
break; |
||||
case SPI_LNX: |
||||
dprint("SPI_LNX\n"); |
||||
set_single_persistent_default_layer(_BASE); |
||||
layer_off(_OSX); |
||||
|
||||
// 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: |
||||
dprint("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); |
||||
set_unicode_input_mode(UC_LNX); |
||||
#endif |
||||
break; |
||||
case SPI_OSX: |
||||
dprint("SPI_OSX\n"); |
||||
set_single_persistent_default_layer(_OSX); |
||||
break; |
||||
case SPI_OSX: |
||||
dprint("SPI_OSX\n"); |
||||
set_single_persistent_default_layer(_OSX); |
||||
#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) |
||||
set_unicode_input_mode(UC_OSX); |
||||
set_unicode_input_mode(UC_OSX); |
||||
#endif |
||||
break; |
||||
case SPI_WIN: |
||||
dprint("SPI_WIN\n"); |
||||
set_single_persistent_default_layer(_BASE); |
||||
layer_off(_OSX); |
||||
break; |
||||
case SPI_WIN: |
||||
dprint("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); |
||||
set_unicode_input_mode(UC_WINC); |
||||
#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 |
||||
bool res = process_record_user_rgb(keycode, record); |
||||
if (res) return true; |
||||
bool res = process_record_user_rgb(keycode, record); |
||||
if (!res) return false; |
||||
#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) { |
||||
#ifdef RGBLIGHT_ENABLE |
||||
return default_layer_state_set_user_rgb(state); |
||||
return default_layer_state_set_user_rgb(state); |
||||
#else |
||||
return state; |
||||
return state; |
||||
#endif |
||||
} |
||||
|
||||
layer_state_t layer_state_set_user(layer_state_t state) { |
||||
#ifdef RGBLIGHT_ENABLE |
||||
return layer_state_set_user_rgb(state); |
||||
return layer_state_set_user_rgb(state); |
||||
#else |
||||
return state; |
||||
return state; |
||||
#endif |
||||
} |
||||
|
||||
bool led_update_user(led_t led_state) { |
||||
#ifdef RGBLIGHT_ENABLE |
||||
return led_update_user_rgb(led_state); |
||||
return led_update_user_rgb(led_state); |
||||
#else |
||||
return true; |
||||
return true; |
||||
#endif |
||||
} |
||||
|
Loading…
Reference in new issue