aboutsummaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
Diffstat (limited to 'users')
-rw-r--r--users/spidey3/config.h18
-rw-r--r--users/spidey3/init.c20
-rw-r--r--users/spidey3/layer_rgb.c311
-rw-r--r--users/spidey3/rules.mk2
-rw-r--r--users/spidey3/spidey3.c271
-rw-r--r--users/spidey3/spidey3.h72
-rw-r--r--users/spidey3/unicode.c30
-rw-r--r--users/spidey3/unicode.h13
8 files changed, 570 insertions, 167 deletions
diff --git a/users/spidey3/config.h b/users/spidey3/config.h
index 9da7f5530..053240718 100644
--- a/users/spidey3/config.h
+++ b/users/spidey3/config.h
@@ -3,3 +3,21 @@
#define LED_DISABLE_WHEN_USB_SUSPENDED true
#define RGB_DISABLE_WHEN_USB_SUSPENDED true
#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
diff --git a/users/spidey3/init.c b/users/spidey3/init.c
index b92394609..273c2b289 100644
--- a/users/spidey3/init.c
+++ b/users/spidey3/init.c
@@ -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
}
diff --git a/users/spidey3/layer_rgb.c b/users/spidey3/layer_rgb.c
index 75e66384e..160cc4317 100644
--- a/users/spidey3/layer_rgb.c
+++ b/users/spidey3/layer_rgb.c
@@ -5,127 +5,280 @@
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("Setting Spidey Swirl!\n");
- rgblight_enable();
- rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
- rgblight_sethsv(213, 255, 128);
+uint8_t rgb_sat;
+uint8_t rgb_val;
+bool rgb_saved = 0;
+
+void spidey_glow(void) {
+ rgblight_enable();
+ rgblight_mode(RGBLIGHT_MODE_TWINKLE + 4);
+ rgblight_sethsv(213, 255, 128);
#ifdef VELOCIKEY_ENABLE
- if (!velocikey_enabled())
- velocikey_toggle();
+ if (velocikey_enabled()) velocikey_toggle();
#endif
}
-void eeconfig_init_user_rgb(void)
-{
- spidey_swirl();
-}
+void eeconfig_init_user_rgb(void) { spidey_glow(); }
+
+// clang-format off
+
+// Convenience macros
+#define CORNER_BL(color) { 0, 1, color }
+#define CORNER_BR(color) { RGBLED_NUM / 2 - 1, 1, color }
+#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,
-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( {10, 3, HSV_MAGENTA} );
-const rgblight_segment_t PROGMEM _layer3_layer[] = RGBLIGHT_LAYER_SEGMENTS( {10, 1, HSV_GREEN} );
-const rgblight_segment_t PROGMEM _yes_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 6, HSV_GREEN} );
-const rgblight_segment_t PROGMEM _no_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 6, HSV_RED} );
+ [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;
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);
}
}
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++) {
- bool is_on = layer_state_cmp(state, i);
- dprintf("\tlayer[%d]=%u\n", i, is_on);
- rgblight_set_layer_state(i, is_on);
+ for (uint8_t i = start; i < end; i++) {
+ bool is_on = layer_state_cmp(state, i);
+ dprintf("layer[%u]=%u\n", 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) {
- 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
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) {
- dprint("default_layer_state_set_user_rgb()\n");
- do_rgb_layers(state, 1u, RGB_LAYER_BASE_REGULAR);
+ do_rgb_layers(state, 1u, LAYER_BASE_REGULAR);
return state;
}
layer_state_t layer_state_set_user_rgb(layer_state_t state) {
- dprint("layer_state_set_user_rgb()\n");
- do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, RGB_LAYER_BASE_ACKS);
+ do_rgb_layers(state, LAYER_BASE_REGULAR, LAYER_BASE_END);
return state;
}
bool led_update_user_rgb(led_t led_state) {
- dprintf("caps_lock=%u\n", led_state.caps_lock);
- rgblight_set_layer_state(0, 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(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;
}
-void rgb_layer_ack(bool yn, bool pressed) {
- uint8_t layer = RGB_LAYER_BASE_ACKS + (yn ? 0 : 1);
- rgblight_set_layer_state(layer, pressed);
+void rgb_layer_ack_yn(bool yn) { rgb_layer_ack(yn ? ACK_YES : ACK_NO); }
+
+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 pressed = record->event.pressed;
-
- switch (keycode) {
- case SPI_GLO:
- if (pressed) {
- spidey_swirl();
- }
- return false;
-
- // Acks follow...
- case DEBUG:
- rgb_layer_ack(debug_enable, pressed);
- return false;
-
- case SPI_LNX:
- case SPI_OSX:
- case SPI_WIN:
- rgb_layer_ack(true, pressed);
- return false;
-
- // Tricky!
- // For these, on press the toggle hasn't happened yet,
- // so we need a little logic to invert, assuming that
- // on key press the flag WILL be toggled, and on key
- // release the flag has already been toggled.
+ if (record->event.pressed) {
+ switch (keycode) {
+ case SPI_GLO:
+ spidey_glow();
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void post_process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ // Acks follow...
+ case DEBUG:
+ rgb_layer_ack_yn(debug_enable);
+ break;
+
+ case SPI_LNX:
+ case SPI_OSX:
+ case SPI_WIN:
+ rgb_layer_ack(ACK_MEH);
+ break;
+
+ case SPI_GFLOCK:
+ rgb_layer_ack_yn(spi_gflock);
+ rgblight_set_layer_state(MISC_OFFSET + 0, spi_gflock);
+ break;
+
+ 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
- case VLK_TOG:
- rgb_layer_ack(pressed != velocikey_enabled(), pressed);
- return true;
+ case VLK_TOG:
+ rgb_layer_ack_yn(velocikey_enabled());
+ break;
#endif
#ifdef NKRO_ENABLE
- case NK_TOGG:
- case NK_ON:
- case NK_OFF:
- rgb_layer_ack(pressed != keymap_config.nkro, pressed);
- return true;
+ case NK_TOGG:
+ case NK_ON:
+ case NK_OFF:
+ rgb_layer_ack_yn(keymap_config.nkro);
+ break;
#endif
- }
-
- return true;
+ }
}
diff --git a/users/spidey3/rules.mk b/users/spidey3/rules.mk
index 0a77d2bfc..2d4da2294 100644
--- a/users/spidey3/rules.mk
+++ b/users/spidey3/rules.mk
@@ -1,3 +1,5 @@
+BOOTMAGIC_ENABLE = lite
+LTO_ENABLE = yes
SRC += init.c
SRC += spidey3.c
diff --git a/users/spidey3/spidey3.c b/users/spidey3/spidey3.c
index 8be99dea0..9d696494f 100644
--- a/users/spidey3/spidey3.c
+++ b/users/spidey3/spidey3.c
@@ -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
}
diff --git a/users/spidey3/spidey3.h b/users/spidey3/spidey3.h
index 224858391..5bfba4e59 100644
--- a/users/spidey3/spidey3.h
+++ b/users/spidey3/spidey3.h
@@ -3,41 +3,71 @@
#include QMK_KEYBOARD_H
#ifdef UNICODEMAP_ENABLE
-#include "unicode.h"
+# include "unicode.h"
#endif
enum userspace_layers {
- _BASE = 0,
- _OSX,
- _NUMPAD,
- _FN,
-};
-
-enum rgb_base_layer {
- RGB_LAYER_BASE_DEFAULT = _BASE,
- RGB_LAYER_BASE_REGULAR = _NUMPAD,
- RGB_LAYER_BASE_ACKS = _FN+1,
+ _BASE = 0,
+ _OSX,
+ _NUMPAD,
+ _FN,
};
enum custom_keycodes {
- SPI_GLO = SAFE_RANGE,
- SPI_LNX,
- SPI_OSX,
- SPI_WIN,
+ SPI_GLO = SAFE_RANGE,
+ SPI_LNX, // Mode: Linux
+ SPI_OSX, // Mode: Mac
+ 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
-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);
+
+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 matrix_init_user_rgb(void);
+void keyboard_post_init_user_rgb(void);
+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 default_layer_state_set_user_rgb(layer_state_t state);
-bool led_update_user_rgb(led_t led_state);
-void clear_rgb_layers(void);
+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);
#endif
#ifdef UNICODEMAP_ENABLE
void eeconfig_init_user_unicode(void);
#endif
+#ifdef SPI_DEBUG_SCAN_RATE
+# ifndef SPI_SCAN_RATE_INTERVAL
+# define SPI_SCAN_RATE_INTERVAL 10
+# endif
+#endif
diff --git a/users/spidey3/unicode.c b/users/spidey3/unicode.c
index 41ceef837..39a990674 100644
--- a/users/spidey3/unicode.c
+++ b/users/spidey3/unicode.c
@@ -2,18 +2,24 @@
#include "unicode.h"
const uint32_t PROGMEM unicode_map[] = {
- [BUL1] = 0x2022, // •
- [BUL2] = 0x25E6, // ◦
- [LARR] = 0x2190, // ←
- [RARR] = 0x2192, // →
- [ENDASH] = 0x2013, // –
- [EMDASH] = 0x2014, // —
+ [BUL1] = 0x2022, // •
+ [BUL2] = 0x25E6, // ◦
+ [LARR] = 0x2190, // ←
+ [RARR] = 0x2192, // →
+ [ENDASH] = 0x2013, // –
+ [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)
-{
- // Default to Linux style
- set_unicode_input_mode(UC_LNX);
+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
index 72a91e8a8..db7824983 100644
--- a/users/spidey3/unicode.h
+++ b/users/spidey3/unicode.h
@@ -11,9 +11,18 @@ enum unicode_names {
RARR,
ENDASH,
EMDASH,
+ SPIDER,
+ SAD,
+ MEH,
+ HAPPY,
+ ANGRY,
+ THUMBUP,
+ THUMBDN,
+ LOL,
+ SURPRISE,
};
-#define X_BUL (XP(BUL1, BUL2))
-#define X_DASH (XP(ENDASH, EMDASH))
+# define X_BUL (XP(BUL1, BUL2))
+# define X_DASH (XP(ENDASH, EMDASH))
#endif