summaryrefslogtreecommitdiff
path: root/users/spidey3
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-09-25 16:02:54 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-09-25 16:02:54 +0200
commit6afdd9d74da250e47ac64d6690bd19d037045e99 (patch)
tree661f6cfb244c02bcd1fbfe8fb9b2bd9242a91394 /users/spidey3
parent93a55e61b59d20f7cd842cce02e5b18a63a23612 (diff)
parent1bdf4cdc22ae57d111efb2f7d71e405e5c7b3f11 (diff)
downloadqmk_firmware-6afdd9d74da250e47ac64d6690bd19d037045e99.tar.gz
qmk_firmware-6afdd9d74da250e47ac64d6690bd19d037045e99.zip
Merge branch 'master' into taamas
Diffstat (limited to 'users/spidey3')
-rw-r--r--users/spidey3/config.h59
-rw-r--r--users/spidey3/init.c8
-rw-r--r--users/spidey3/layer_rgb.c180
-rw-r--r--users/spidey3/rules.mk1
-rw-r--r--users/spidey3/spidey3.c98
-rw-r--r--users/spidey3/spidey3.h18
-rw-r--r--users/spidey3/unicode.c3
-rw-r--r--users/spidey3/unicode.h3
8 files changed, 216 insertions, 154 deletions
diff --git a/users/spidey3/config.h b/users/spidey3/config.h
index f5f5e07f0f..91bcf910ee 100644
--- a/users/spidey3/config.h
+++ b/users/spidey3/config.h
@@ -1,26 +1,51 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#pragma once
#define LED_DISABLE_WHEN_USB_SUSPENDED
#define RGB_DISABLE_WHEN_USB_SUSPENDED
-#define RGBLIGHT_LAYERS
-#define RGBLIGHT_MAX_LAYERS 17
-#define RGBLIGHT_LAYER_BLINK
-#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
-#define RGBLIGHT_STARTUP_ANIMATION
-
-#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 UNICODE_SELECTED_MODES UC_MAC, UC_LNX, UC_WINC
+
+#ifdef RGBLIGHT_ENABLE
+
+# define RGBLIGHT_LAYERS
+# define RGBLIGHT_MAX_LAYERS 18
+# define RGBLIGHT_LAYER_BLINK
+# define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
+# define RGBLIGHT_STARTUP_ANIMATION
+
+# 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_TWINKLE
+
+# define RGBLIGHT_DEFAULT_HUE 213
+# define RGBLIGHT_DEFAULT_SAT UINT8_MAX
+# define RGBLIGHT_DEFAULT_VAL RGBLIGHT_LIMIT_VAL / 2
+
+# if defined(RGBLIGHT_EFFECT_TWINKLE)
+# define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_TWINKLE
+# elif defined(RGBLIGHT_EFFECT_RAINBOW_MOOD)
+# define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_RAINBOW_MOOD
+# else
+# define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_LIGHT
+# endif
+
+#endif
+
+#define UNICODE_SELECTED_MODES UC_MAC, UC_LNX, UC_WINC, UC_EMACS
#define SPI_DEBUG_SCAN_RATE
#undef MANUFACTURER
#define MANUFACTURER Window of Fire
+
+// Some keyboards enable BACKLIGHT_CAPS_LOCK without checking if backlight is enabled.
+// Undef as appropriate to avoid compiler warnings in that case.
+#ifndef BACKLIGHT_ENABLE
+#undef BACKLIGHT_CAPS_LOCK
+#endif
diff --git a/users/spidey3/init.c b/users/spidey3/init.c
index 8db41a5f4c..bd6ea5cac9 100644
--- a/users/spidey3/init.c
+++ b/users/spidey3/init.c
@@ -1,3 +1,6 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#include "spidey3.h"
void keyboard_post_init_user(void) {
@@ -7,15 +10,10 @@ void keyboard_post_init_user(void) {
}
void eeconfig_init_user(void) {
- print("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
}
#ifdef RGBLIGHT_ENABLE
diff --git a/users/spidey3/layer_rgb.c b/users/spidey3/layer_rgb.c
index 37e59579cf..c867468194 100644
--- a/users/spidey3/layer_rgb.c
+++ b/users/spidey3/layer_rgb.c
@@ -1,3 +1,6 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#include QMK_KEYBOARD_H
#include "spidey3.h"
@@ -13,21 +16,15 @@ bool rgb_saved = 0;
extern bool spi_gflock;
extern uint16_t spi_replace_mode;
-void spidey_glow(void) {
+static void set_rgb_default(void) {
rgblight_enable();
- rgblight_sethsv(213, 255, 128);
- if ((RGBLIGHT_MODE_TWINKLE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_TWINKLE_end)) {
- rgblight_step();
- } else {
- rgblight_mode(RGBLIGHT_MODE_TWINKLE);
- }
+ rgblight_sethsv(RGBLIGHT_DEFAULT_HUE, RGBLIGHT_DEFAULT_SAT, RGBLIGHT_DEFAULT_VAL);
+ rgblight_mode(RGBLIGHT_DEFAULT_MODE);
#ifdef VELOCIKEY_ENABLE
if (velocikey_enabled()) velocikey_toggle();
#endif
}
-void eeconfig_init_user_rgb(void) { spidey_glow(); }
-
// clang-format off
// Convenience macros
@@ -68,6 +65,7 @@ const rgblight_segment_t PROGMEM _uc_mac_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORN
// UC_WIN disabled in config.h
// UC_BSD not implemented
const rgblight_segment_t PROGMEM _uc_winc_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNER_BR(HSV_CYAN));
+const rgblight_segment_t PROGMEM _uc_emacs_layer[] = RGBLIGHT_LAYER_SEGMENTS(CORNER_BR(HSV_GREEN));
// Now define the array of layers. Higher numbered layers take precedence.
const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
@@ -92,6 +90,7 @@ const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
[UNICODE_OFFSET + UC_WIN] = _none,
[UNICODE_OFFSET + UC_BSD] = _none,
[UNICODE_OFFSET + UC_WINC] = _uc_winc_layer,
+ [UNICODE_OFFSET + UC_EMACS] = _uc_emacs_layer,
[UNICODE_OFFSET + UC__COUNT] = NULL
};
@@ -101,7 +100,6 @@ const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1;
void clear_rgb_layers() {
- dprint("clear_rgb_layers()\n");
for (uint8_t i = 0; i < _n_rgb_layers; i++) {
rgblight_set_layer_state(i, false);
}
@@ -110,7 +108,6 @@ void clear_rgb_layers() {
void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) {
for (uint8_t i = start; i < end; i++) {
bool is_on = layer_state_cmp(state, i);
- dprintf("layer[%u]=rl[%u]=%u\n", i, LAYER_OFFSET + i, is_on);
rgblight_set_layer_state(LAYER_OFFSET + i, is_on);
}
}
@@ -119,7 +116,6 @@ void do_rgb_unicode(void) {
uint8_t uc_mode = get_unicode_input_mode();
for (uint8_t i = 0; i < UC__COUNT; i++) {
bool is_on = i == uc_mode;
- dprintf("unicode[%u]=rl[%u]=%u\n", i, UNICODE_OFFSET + i, is_on);
rgblight_set_layer_state(UNICODE_OFFSET + i, is_on);
}
}
@@ -138,7 +134,7 @@ int8_t change_sat = 0;
int8_t change_val = 0;
// timer to control color change speed
-uint16_t change_timer = 0;
+uint16_t change_timer = 0;
const uint16_t change_tick = 15;
extern rgblight_config_t rgblight_config;
@@ -146,14 +142,15 @@ extern rgblight_status_t rgblight_status;
#if defined(RGBLIGHT_STARTUP_ANIMATION)
-#define STARTUP_ANIMATION_SATURATION 200
-#define STARTUP_ANIMATION_VALUE 255
-#define STARTUP_ANIMATION_FADE_STEP 5
-#define STARTUP_ANIMATION_CYCLE_STEP 2
-#define STARTUP_ANIMATION_RAMP_TO_STEPS 70
-#define STARTUP_ANIMATION_STEP_TIME 10
-#define STARTUP_ANIMATION_INITIAL_DELAY 0 // milliseconds, must be < 255 * STEP_TIME
+# define STARTUP_ANIMATION_SATURATION 200
+# define STARTUP_ANIMATION_VALUE 255
+# define STARTUP_ANIMATION_FADE_STEP 5
+# define STARTUP_ANIMATION_CYCLE_STEP 2
+# define STARTUP_ANIMATION_RAMP_TO_STEPS 70
+# define STARTUP_ANIMATION_STEP_TIME 10
+# define STARTUP_ANIMATION_INITIAL_DELAY 0 // milliseconds, must be < 255 * STEP_TIME
+// clang-format off
typedef enum {
DISABLED,
WAITING,
@@ -167,18 +164,18 @@ typedef enum {
CLEAN_UP,
DONE
} startup_animation_state_t;
+// clang-format on
-static rgblight_config_t old_config;
-static uint8_t old_base_mode;
+static rgblight_config_t old_config;
+static uint8_t old_base_mode;
static startup_animation_state_t startup_animation_state = DISABLED;
-static uint16_t rgblight_startup_loop_timer;
+static uint16_t rgblight_startup_loop_timer;
void startup_animation_init(void) {
old_config.raw = rgblight_config.raw;
old_base_mode = rgblight_status.base_mode;
- if (!old_config.enable)
- rgblight_enable_noeeprom();
+ if (!old_config.enable) rgblight_enable_noeeprom();
}
#endif
@@ -202,9 +199,9 @@ void matrix_scan_user_rgb(void) {
switch (startup_animation_state) {
case WAITING:
-#ifdef STARTUP_ANIMATION_DEBUG
+# ifdef STARTUP_ANIMATION_DEBUG
dprintf("sua WAITING counter=%u\n", counter);
-#endif
+# endif
if (counter < STARTUP_ANIMATION_INITIAL_DELAY / STARTUP_ANIMATION_STEP_TIME) {
counter++;
} else {
@@ -213,83 +210,87 @@ void matrix_scan_user_rgb(void) {
break;
case RESTART:
+# ifdef STARTUP_ANIMATION_DEBUG
dprintln("sua RESTART");
+# endif
startup_animation_init();
case START:
+# ifdef STARTUP_ANIMATION_DEBUG
dprintln("sua START");
+# endif
startup_animation_state = FADE_OLD;
- counter = old_config.val;
+ counter = old_config.val;
// No break! Just roll into FADE_OLD in the same iteration...
case FADE_OLD:
-#ifdef STARTUP_ANIMATION_DEBUG
+# ifdef STARTUP_ANIMATION_DEBUG
dprintf("sua FADE_OLD counter=%u\n", counter);
-#endif
+# endif
if (counter >= STARTUP_ANIMATION_FADE_STEP) {
rgblight_sethsv_noeeprom(old_config.hue, old_config.sat, counter);
counter -= STARTUP_ANIMATION_FADE_STEP;
} else {
- counter = 0;
+ counter = 0;
startup_animation_state = FADE_IN;
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
}
break;
case FADE_IN:
-#ifdef STARTUP_ANIMATION_DEBUG
+# ifdef STARTUP_ANIMATION_DEBUG
dprintf("sua FADE_IN counter=%u\n", counter);
-#endif
+# endif
if (counter < STARTUP_ANIMATION_VALUE) {
rgblight_sethsv_noeeprom(old_config.hue, STARTUP_ANIMATION_SATURATION, counter);
counter += STARTUP_ANIMATION_FADE_STEP;
} else {
- counter = 255;
+ counter = 255;
startup_animation_state = CYCLE;
}
break;
case CYCLE:
-#ifdef STARTUP_ANIMATION_DEBUG
+# ifdef STARTUP_ANIMATION_DEBUG
dprintf("sua CYCLE counter=%u\n", counter);
-#endif
+# endif
if (counter >= STARTUP_ANIMATION_CYCLE_STEP) {
rgblight_sethsv_noeeprom((counter + old_config.hue) % 255, STARTUP_ANIMATION_SATURATION, STARTUP_ANIMATION_VALUE);
counter -= STARTUP_ANIMATION_CYCLE_STEP;
} else {
if (
-#ifdef RGBLIGHT_EFFECT_BREATHING
+# ifdef RGBLIGHT_EFFECT_BREATHING
(old_base_mode == RGBLIGHT_MODE_BREATHING) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_SNAKE
+# endif
+# ifdef RGBLIGHT_EFFECT_SNAKE
(old_base_mode == RGBLIGHT_MODE_SNAKE) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_KNIGHT
+# endif
+# ifdef RGBLIGHT_EFFECT_KNIGHT
(old_base_mode == RGBLIGHT_MODE_KNIGHT) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_TWINKLE
+# endif
+# ifdef RGBLIGHT_EFFECT_TWINKLE
(old_base_mode == RGBLIGHT_MODE_TWINKLE) ||
-#endif
+# endif
!old_config.enable) {
- counter = STARTUP_ANIMATION_VALUE;
+ counter = STARTUP_ANIMATION_VALUE;
startup_animation_state = RAMP_DOWN;
} else if (
-#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
+# ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
(old_base_mode == RGBLIGHT_MODE_STATIC_GRADIENT) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
(old_base_mode == RGBLIGHT_MODE_RAINBOW_MOOD) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
(old_base_mode == RGBLIGHT_MODE_RAINBOW_SWIRL) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_RAINBOW_CHRISTMAS
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_CHRISTMAS
(old_base_mode == RGBLIGHT_MODE_CHRISTMAS) ||
-#endif
-#ifdef RGBLIGHT_EFFECT_RAINBOW_RGB_TEST_
+# endif
+# ifdef RGBLIGHT_EFFECT_RAINBOW_RGB_TEST
(old_base_mode == RGBLIGHT_MODE_RGB_TEST) ||
-#endif
+# endif
(old_base_mode == RGBLIGHT_MODE_STATIC_LIGHT)) {
- counter = 0;
+ counter = 0;
startup_animation_state = RAMP_TO;
} else {
startup_animation_state = CLEAN_UP;
@@ -298,39 +299,41 @@ void matrix_scan_user_rgb(void) {
break;
case RAMP_DOWN:
-#ifdef STARTUP_ANIMATION_DEBUG
+# ifdef STARTUP_ANIMATION_DEBUG
dprintf("sua RAMP_DOWN counter=%u\n", counter);
-#endif
+# endif
+ rgblight_sethsv_noeeprom(old_config.hue, STARTUP_ANIMATION_SATURATION, counter);
if (counter >= STARTUP_ANIMATION_FADE_STEP) {
- rgblight_sethsv_noeeprom(old_config.hue, STARTUP_ANIMATION_SATURATION, counter);
counter -= STARTUP_ANIMATION_FADE_STEP;
} else {
startup_animation_state = CLEAN_UP;
}
break;
- case RAMP_TO:
- {
-#ifdef STARTUP_ANIMATION_DEBUG
- dprintf("sua RAMP_TO s=%u, v=%u, counter=%u\n", old_config.sat, old_config.val, counter);
-#endif
- uint8_t steps = STARTUP_ANIMATION_RAMP_TO_STEPS;
- if (counter < steps) {
- uint8_t s = STARTUP_ANIMATION_SATURATION + counter * (((float)old_config.sat - STARTUP_ANIMATION_SATURATION) / (float)steps);
- uint8_t v = STARTUP_ANIMATION_VALUE + counter * (((float)old_config.val - STARTUP_ANIMATION_VALUE) / (float)steps);
- rgblight_sethsv_noeeprom(old_config.hue, s, v);
- counter++;
- } else {
- startup_animation_state = CLEAN_UP;
- }
+ case RAMP_TO: {
+# ifdef STARTUP_ANIMATION_DEBUG
+ dprintf("sua RAMP_TO s=%u, v=%u, counter=%u\n", old_config.sat, old_config.val, counter);
+# endif
+ uint8_t steps = STARTUP_ANIMATION_RAMP_TO_STEPS;
+ if (counter < steps) {
+ uint8_t s = STARTUP_ANIMATION_SATURATION + counter * (((float)old_config.sat - STARTUP_ANIMATION_SATURATION) / (float)steps);
+ uint8_t v = STARTUP_ANIMATION_VALUE + counter * (((float)old_config.val - STARTUP_ANIMATION_VALUE) / (float)steps);
+ rgblight_sethsv_noeeprom(old_config.hue, s, v);
+ counter++;
+ } else {
+ startup_animation_state = CLEAN_UP;
}
- break;
+ } break;
case CLEAN_UP:
+# ifdef STARTUP_ANIMATION_DEBUG
dprintln("sua CLEAN_UP");
+# endif
rgblight_reload_from_eeprom();
startup_animation_state = DONE;
+# ifdef STARTUP_ANIMATION_DEBUG
dprintln("sua DONE");
+# endif
break;
default:
@@ -344,8 +347,8 @@ void matrix_scan_user_rgb(void) {
if (timer_elapsed(change_timer) > change_tick) {
HSV hsv = rgblight_get_hsv();
hsv.h += change_hue;
- hsv.s = change_sat > 0 ? qadd8(hsv.s, (uint8_t) change_sat) : qsub8(hsv.s, (uint8_t) -change_sat);
- hsv.v = change_val > 0 ? qadd8(hsv.v, (uint8_t) change_val) : qsub8(hsv.v, (uint8_t) -change_val);
+ hsv.s = change_sat > 0 ? qadd8(hsv.s, (uint8_t)change_sat) : qsub8(hsv.s, (uint8_t)-change_sat);
+ hsv.v = change_val > 0 ? qadd8(hsv.v, (uint8_t)change_val) : qsub8(hsv.v, (uint8_t)-change_val);
rgblight_sethsv_noeeprom(hsv.h, hsv.s, hsv.v);
change_timer = timer_read();
}
@@ -372,8 +375,6 @@ layer_state_t layer_state_set_user_rgb(layer_state_t state) {
}
bool led_update_user_rgb(led_t led_state) {
- 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);
@@ -385,7 +386,6 @@ 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);
}
@@ -395,11 +395,9 @@ extern rgblight_config_t rgblight_config;
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
- case SPI_GLO:
- spidey_glow();
- return false;
-
// clang-format off
+ case SPI_GLO: set_rgb_default(); return false;
+
case RGB_HUI: change_timer = timer_read(); change_hue = 1; return false;
case RGB_HUD: change_timer = timer_read(); change_hue = -1; return false;
case RGB_SAI: change_timer = timer_read(); change_sat = 1; return false;
@@ -460,7 +458,9 @@ void post_process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
break;
case RGB_TOG:
- rgb_layer_ack_yn(rgblight_config.enable);
+ // Hack - we only get called on the press for RGB_TOG,
+ // but the flag is only flipped on the release...
+ rgb_layer_ack_yn(!rgblight_config.enable);
break;
#ifdef VELOCIKEY_ENABLE
@@ -477,10 +477,14 @@ void post_process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
break;
#endif
-#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
- case SPI_LNX:
- case SPI_OSX:
- case SPI_WIN:
+#if defined(UNICODE_COMMON_ENABLE)
+ case UC_M_MA:
+ case UC_M_LN:
+ case UC_M_WI:
+ case UC_M_BS:
+ case UC_M_WC:
+ case UC_M_EM:
+
case UC_MOD:
case UC_RMOD:
rgb_layer_ack(ACK_MEH);
diff --git a/users/spidey3/rules.mk b/users/spidey3/rules.mk
index de8ed113e7..c95582e176 100644
--- a/users/spidey3/rules.mk
+++ b/users/spidey3/rules.mk
@@ -1,6 +1,7 @@
BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite
CONSOLE_ENABLE = yes # Console for debug
BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
+NKRO_ENABLE = yes
LTO_ENABLE = yes
SRC += init.c
diff --git a/users/spidey3/spidey3.c b/users/spidey3/spidey3.c
index df73c903d0..842bb465f7 100644
--- a/users/spidey3/spidey3.c
+++ b/users/spidey3/spidey3.c
@@ -1,3 +1,6 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#include QMK_KEYBOARD_H
#include "spidey3.h"
@@ -18,7 +21,7 @@ static uint32_t matrix_timer = 0;
# endif
void report_version(void) {
- uprintln(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE);
+ uprintln(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION " - " QMK_BUILDDATE);
reported_version = true;
}
#endif
@@ -51,8 +54,42 @@ void matrix_scan_user(void) {
#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, uint8_t temp_osm) {
+static uint32_t math_glyph_exceptions(const uint16_t keycode, const bool shifted) {
+ bool caps = host_keyboard_led_state().caps_lock;
+ if (shifted != caps) {
+ switch (keycode) {
+ // clang-format off
+ case KC_C: return 0x2102;
+ case KC_H: return 0x210D;
+ case KC_N: return 0x2115;
+ case KC_P: return 0x2119;
+ case KC_Q: return 0x211A;
+ case KC_R: return 0x211D;
+ case KC_Z: return 0x2124;
+ // clang-format on
+ }
+ }
+ return 0;
+}
+
+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, uint32_t (*exceptions)(const uint16_t keycode, const bool shifted), uint8_t temp_mod, uint8_t temp_osm) {
+ void _register(uint32_t codepoint) {
+ unicode_input_start();
+ register_hex32(codepoint);
+ unicode_input_finish();
+ }
+
if ((((temp_mod | temp_osm) & (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI))) == 0) {
+ bool shifted = ((temp_mod | temp_osm) & MOD_MASK_SHIFT);
+ if (exceptions) {
+ uint32_t res = exceptions(keycode, shifted);
+ if (res) {
+ if (record->event.pressed) {
+ _register(res);
+ }
+ return false;
+ }
+ }
switch (keycode) {
case KC_A ... KC_Z:
if (record->event.pressed) {
@@ -61,39 +98,31 @@ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, uin
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();
-
+ bool caps = host_keyboard_led_state().caps_lock;
+ uint32_t base = ((shifted == caps) ? baseAlphaLower : baseAlphaUpper);
+ _register(base + (keycode - KC_A));
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.
+ if (shifted) { // 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();
+ _register(zeroGlyph);
}
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.
+ if (shifted) { // 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();
+ _register(baseNumberOne + (keycode - KC_1));
}
return false;
case KC_SPACE:
if (record->event.pressed) {
- unicode_input_start();
- register_hex32(spaceGlyph); // em space
- unicode_input_finish();
+ _register(spaceGlyph); // em space
}
return false;
}
@@ -163,7 +192,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
debug_keyboard = 0;
debug_matrix = 0;
}
- uprintf("DEBUG: enable=%u, keyboard=%u, matrix=%u\n", debug_enable, debug_keyboard, debug_matrix);
+ uprintf("DEBUG: enable=%u, kb=%u, matrix=%u\n", debug_enable, debug_keyboard, debug_matrix);
eeconfig_update_debug(debug_config.raw);
return false;
#endif
@@ -174,21 +203,14 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case CH_ASST: host_consumer_send(AL_ASSISTANT); return false;
case CH_SUSP: tap_code16(LGUI(LSFT(KC_L))); return true;
-#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)
- case SPI_LNX: set_unicode_input_mode(UC_LNX); break;
- case SPI_OSX: set_unicode_input_mode(UC_OSX); break;
- case SPI_WIN: set_unicode_input_mode(UC_WINC); break;
-#endif
// clang-format on
- case SPI_NORMAL ... SPI_FRAKTR:
+ case SPI_NORMAL ... SPI_MATH:
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;
case SPI_KP_00:
@@ -279,19 +301,23 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
case KC_SPACE:
switch (spi_replace_mode) {
case SPI_WIDE:
- return process_record_glyph_replacement(keycode, record, 0xFF41, 0xFF21, 0xFF10, 0xFF11, 0x2003, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0xFF41, 0xFF21, 0xFF10, 0xFF11, 0x2003, NULL, mods, osm);
case SPI_SCRIPT:
- return process_record_glyph_replacement(keycode, record, 0x1D4EA, 0x1D4D0, 0x1D7CE, 0x1D7CF, 0x2002, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0x1D4EA, 0x1D4D0, 0x1D7CE, 0x1D7CF, 0x2002, NULL, mods, osm);
case SPI_BLOCKS:
- return process_record_glyph_replacement(keycode, record, 0x1F170, 0x1F170, '0', '1', 0x2002, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0x1F170, 0x1F170, '0', '1', 0x2002, NULL, mods, osm);
case SPI_CIRCLE:
- return process_record_glyph_replacement(keycode, record, 0x1F150, 0x1F150, '0', '1', 0x2002, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0x1F150, 0x1F150, '0', '1', 0x2002, NULL, mods, osm);
case SPI_SQUARE:
- return process_record_glyph_replacement(keycode, record, 0x1F130, 0x1F130, '0', '1', 0x2002, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0x1F130, 0x1F130, '0', '1', 0x2002, NULL, mods, osm);
case SPI_PARENS:
- return process_record_glyph_replacement(keycode, record, 0x1F110, 0x1F110, '0', '1', 0x2002, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0x1F110, 0x1F110, '0', '1', 0x2002, NULL, mods, osm);
case SPI_FRAKTR:
- return process_record_glyph_replacement(keycode, record, 0x1D586, 0x1D56C, '0', '1', 0x2002, mods, osm);
+ return process_record_glyph_replacement(keycode, record, 0x1D586, 0x1D56C, '0', '1', 0x2002, NULL, mods, osm);
+ case SPI_BOLD:
+ return process_record_glyph_replacement(keycode, record, 0x1D41A, 0x1D400, '0', '1', 0x2002, NULL, mods, osm);
+ case SPI_MATH:
+ return process_record_glyph_replacement(keycode, record, 0x1D552, 0x1D538, '0', '1', 0x2002, &math_glyph_exceptions, mods, osm);
}
break;
@@ -304,9 +330,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
if ((mods | osm) & MOD_MASK_SHIFT) {
del_mods(MOD_MASK_SHIFT);
-#ifndef NO_ACTION_ONESHOT
+# ifndef NO_ACTION_ONESHOT
clear_oneshot_mods();
-#endif
+# endif
register_code(KC_DEL);
delkey_registered = true;
set_mods(mods);
diff --git a/users/spidey3/spidey3.h b/users/spidey3/spidey3.h
index d018e5defb..e91b299e55 100644
--- a/users/spidey3/spidey3.h
+++ b/users/spidey3/spidey3.h
@@ -1,3 +1,6 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#pragma once
#include QMK_KEYBOARD_H
@@ -10,16 +13,13 @@ enum userspace_layers {
_BASE = 0,
_NUMPAD,
_FN,
+ _GLYPH,
};
enum custom_keycodes {
- 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
+ CH_CPNL = SAFE_RANGE, // AL Control Panel
+ CH_ASST, // AL Context-aware Desktop Assistant
+ CH_SUSP, // Suspend
SPI_NORMAL,
SPI_WIDE,
@@ -29,8 +29,11 @@ enum custom_keycodes {
SPI_SQUARE,
SPI_PARENS,
SPI_FRAKTR,
+ SPI_BOLD,
+ SPI_MATH,
SPI_GFLOCK,
SPI_KP_00,
+ SPI_GLO,
};
#ifdef RGBLIGHT_ENABLE
@@ -50,7 +53,6 @@ typedef enum layer_ack {
# define RGB_LAYER_ACK_DURATION 500
-void eeconfig_init_user_rgb(void);
void matrix_init_user_rgb(void);
void matrix_scan_user_rgb(void);
void keyboard_post_init_user_rgb(void);
diff --git a/users/spidey3/unicode.c b/users/spidey3/unicode.c
index 39a990674c..5292b0809b 100644
--- a/users/spidey3/unicode.c
+++ b/users/spidey3/unicode.c
@@ -1,3 +1,6 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#include "unicode.h"
diff --git a/users/spidey3/unicode.h b/users/spidey3/unicode.h
index 6182669fb0..ee8e00056c 100644
--- a/users/spidey3/unicode.h
+++ b/users/spidey3/unicode.h
@@ -1,3 +1,6 @@
+// Copyright 2022 Joshua Diamond josh@windowoffire.com (@spidey3)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
#pragma once
#include QMK_KEYBOARD_H