Some refinements of 75_ansi/spidey3 layout (#8581)
* First cut at Josh Diamond's KBD75 customizations. Includes: * My unique keymap with ChromeOS specific keys * Use RGB underglow to indicate Caps Lock * Some unicode bindings * Some changes to make debugging easier * Updated spidey3 to be applicable to all 75_ansi boards * Sadly, ChromeOS doesn't pay attention to most consumer codes * Add mac layer; fix flakeyness in CAPS_LOCK underglow. * Make layers.json match the keymap (to the extent possible) * Major cleanup; fix broken debug persistence * Cleanup some whitespace issues * Fix incorrect log message. * Rework layer indication to user RGBLIGHT_LAYERS * Update layouts/community/75_ansi/spidey3/keymap.c Co-Authored-By: Drashna Jaelre <drashna@live.com> * Rename users/spidey3/rgblight.c to layer_rgb.c per suggestion * Refactor to use set_single_persistant_default_layer(). * Use dprint/f to make logging more elegant. * Update users/spidey3/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update users/spidey3/config.h Co-Authored-By: Drashna Jaelre <drashna@live.com> * Update layouts/community/75_ansi/spidey3/rules.mk Co-Authored-By: Ryan <fauxpark@gmail.com> * Update users/spidey3/spidey3.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update users/spidey3/layer_rgb.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update users/spidey3/init.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Changes from code review * Numpad layer, various keys for 75_ansi/spidey3 * Add Fn-B to toggle NKRO * Blink rgb to acknowledge some setting changes * Updated media control & reset key location * Minor cleanup Co-authored-by: Joshua Diamond <jdiamond@Deep-Thought.local> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com>
This commit is contained in:
parent
c3c3943432
commit
e4cc642a79
|
@ -1,33 +1,44 @@
|
|||
#include "spidey3.h"
|
||||
|
||||
#define SETTINGS A(S(KC_S))
|
||||
#define CH_MENU A(S(KC_S))
|
||||
#define OSX_PSC G(S(KC_4))
|
||||
#define FN_MENU LT(_FN,KC_APP)
|
||||
|
||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||
// Linux / Win layout
|
||||
[_BASE] = LAYOUT_75_ansi(
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, SETTINGS, KC_INS, KC_DEL,
|
||||
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, KC_DEL,
|
||||
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME,
|
||||
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_PGUP,
|
||||
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGDN,
|
||||
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_END,
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
|
||||
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, FN_MENU, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
|
||||
),
|
||||
// OSX layout
|
||||
[_OSX] = LAYOUT_75_ansi(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_EJCT, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, OSX_PSC, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
|
||||
_______, KC_LALT, KC_LGUI, _______, _______, _______, _______, _______, _______, _______
|
||||
),
|
||||
// Numpad
|
||||
[_NUMPAD] = LAYOUT_75_ansi(
|
||||
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NUMLOCK, KC_PEQL, KC_PSLS, KC_PAST, XXXXXXX, XXXXXXX, _______, _______, _______,
|
||||
XXXXXXX, XXXXXXX, XXXXXXX, KC_NUMLOCK, XXXXXXX, XXXXXXX, XXXXXXX, KC_KP_7, KC_KP_8, KC_KP_9, KC_PSLS, KC_PMNS, KC_PEQL, _______, _______,
|
||||
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_KP_4, KC_KP_5, KC_KP_6, KC_PAST, _______, _______, _______, _______,
|
||||
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_KP_1, KC_KP_2, KC_KP_3, KC_PMNS, KC_SCLN, KC_PENT, _______,
|
||||
_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_KP_0, KC_PDOT, KC_PCMM, KC_PPLS, _______, _______, _______,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______
|
||||
),
|
||||
// FN
|
||||
[_FN] = LAYOUT_75_ansi(
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PWR,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, X_BUL, _______, _______, X_DASH, _______, RESET, EEP_RST,
|
||||
_______, RGB_TOG, RGB_MOD, RGB_HUD, RGB_HUI, RGB_SAD, RGB_SAI, RGB_VAD, RGB_VAI, RGB_SPD, RGB_SPI, VLK_TOG, _______, _______, KC_VOLU,
|
||||
_______, RGB_M_P, RGB_M_B, RGB_M_R, RGB_M_SW, RGB_M_SN, RGB_M_K, RGB_M_G, RGB_M_T, SPI_LNX, _______, _______, _______, KC_VOLD,
|
||||
_______, SPI_GLO, _______, SPI_WIN, _______, _______, _______, SPI_OSX, X(LARR), X(RARR), DEBUG, _______, KC_BRIU, KC_MUTE,
|
||||
_______, _______, _______, _______, _______, _______, _______, _______, KC_BRID, _______
|
||||
RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_SLEP, KC_WAKE, KC_PWR,
|
||||
EEP_RST, _______, _______, _______, _______, _______, _______, _______, X_BUL, KC_MPRV, KC_MNXT, 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_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,
|
||||
_______, _______, _______, KC_MPLY, KC_APP, _______, CH_MENU, KC_MPRV, KC_VOLD, KC_MNXT
|
||||
)
|
||||
};
|
||||
|
|
|
@ -13,3 +13,6 @@ AUDIO_ENABLE = no
|
|||
RGBLIGHT_ENABLE = yes
|
||||
UNICODEMAP_ENABLE = yes
|
||||
VELOCIKEY_ENABLE = yes
|
||||
|
||||
# The following disabled to save space
|
||||
SPACE_CADET_ENABLE = no
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
#include "spidey3.h"
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
print("SPIDEY3: keyboard_post_init_user\n");
|
||||
uprintf(" debug_enable=%u\n", debug_enable);
|
||||
print("keyboard_post_init_user\n");
|
||||
uprintf("\tdebug_enable=%u\n", debug_enable);
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
keyboard_post_init_user_rgb();
|
||||
#endif
|
||||
}
|
||||
|
||||
void eeconfig_init_user(void) {
|
||||
print("SPIDEY3: eeconfig_init_user\n");
|
||||
print("eeconfig_init_user\n");
|
||||
set_single_persistent_default_layer(_BASE);
|
||||
#ifdef UNICODEMAP_ENABLE
|
||||
eeconfig_init_user_unicode();
|
||||
|
@ -19,3 +19,12 @@ void eeconfig_init_user(void) {
|
|||
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);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ uint8_t rgb_val;
|
|||
bool rgb_saved = 0;
|
||||
|
||||
void spidey_swirl(void) {
|
||||
dprint("SPIDEY3: Setting Spidey Swirl!\n");
|
||||
dprint("Setting Spidey Swirl!\n");
|
||||
rgblight_enable();
|
||||
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
|
||||
rgblight_sethsv(213, 255, 128);
|
||||
|
@ -27,54 +27,104 @@ void eeconfig_init_user_rgb(void)
|
|||
|
||||
const rgblight_segment_t PROGMEM _capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS( {0, 2, HSV_AZURE}, {14, 2, HSV_AZURE} );
|
||||
const rgblight_segment_t PROGMEM _layer1_layer[] = RGBLIGHT_LAYER_SEGMENTS( {7, 1, HSV_PURPLE} );
|
||||
const rgblight_segment_t PROGMEM _layer2_layer[] = RGBLIGHT_LAYER_SEGMENTS( {9, 2, HSV_GREEN} );
|
||||
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} );
|
||||
|
||||
// Now define the array of layers. Later layers take precedence
|
||||
const rgblight_segment_t* const PROGMEM _rgb_layers[] = RGBLIGHT_LAYERS_LIST( _capslock_layer, _layer1_layer, _layer2_layer );
|
||||
const 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++) {
|
||||
rgblight_set_layer_state(i, false);
|
||||
}
|
||||
}
|
||||
|
||||
void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) {
|
||||
dprint("SPIDEY3: do_rgb_layers()\n");
|
||||
dprint("do_rgb_layers()\n");
|
||||
for (uint8_t i=start; i<end; i++) {
|
||||
bool is_on = layer_state_cmp(state, i);
|
||||
dprintf(" layer[%d]=%u\n", i, is_on);
|
||||
dprintf("\tlayer[%d]=%u\n", i, is_on);
|
||||
rgblight_set_layer_state(i, is_on);
|
||||
}
|
||||
}
|
||||
|
||||
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, _n_rgb_layers);
|
||||
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;
|
||||
}
|
||||
|
||||
layer_state_t default_layer_state_set_user_rgb(layer_state_t state) {
|
||||
dprint("SPIDEY3: default_layer_state_set_user_rgb()\n");
|
||||
dprint("default_layer_state_set_user_rgb()\n");
|
||||
do_rgb_layers(state, 1u, RGB_LAYER_BASE_REGULAR);
|
||||
return state;
|
||||
}
|
||||
|
||||
layer_state_t layer_state_set_user_rgb(layer_state_t state) {
|
||||
dprint("SPIDEY3: layer_state_set_user_rgb()\n");
|
||||
do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, _n_rgb_layers);
|
||||
dprint("layer_state_set_user_rgb()\n");
|
||||
do_rgb_layers(state, RGB_LAYER_BASE_REGULAR, RGB_LAYER_BASE_ACKS);
|
||||
return state;
|
||||
}
|
||||
|
||||
bool led_update_user_rgb(led_t led_state) {
|
||||
dprintf("SPIDEY3: caps_lock=%u\n", led_state.caps_lock);
|
||||
dprintf("caps_lock=%u\n", led_state.caps_lock);
|
||||
rgblight_set_layer_state(0, led_state.caps_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);
|
||||
}
|
||||
|
||||
extern keymap_config_t keymap_config;
|
||||
|
||||
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
|
||||
bool pressed = record->event.pressed;
|
||||
|
||||
switch (keycode) {
|
||||
case SPI_GLO:
|
||||
if (record->event.pressed) {
|
||||
if (pressed) {
|
||||
spidey_swirl();
|
||||
}
|
||||
break;
|
||||
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.
|
||||
|
||||
#ifdef VELOCIKEY_ENABLE
|
||||
case VLK_TOG:
|
||||
rgb_layer_ack(pressed != velocikey_enabled(), pressed);
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#ifdef NKRO_ENABLE
|
||||
case NK_TOGG:
|
||||
case NK_ON:
|
||||
case NK_OFF:
|
||||
rgb_layer_ack(pressed != keymap_config.nkro, pressed);
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -20,39 +20,39 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
eeconfig_update_debug(debug_config.raw);
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
case SPI_LNX:
|
||||
dprint("SPIDEY3: SPI_LNX\n");
|
||||
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);
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
case SPI_OSX:
|
||||
dprint("SPIDEY3: SPI_OSX\n");
|
||||
dprint("SPI_OSX\n");
|
||||
set_single_persistent_default_layer(_OSX);
|
||||
#if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE)
|
||||
set_unicode_input_mode(UC_OSX);
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
case SPI_WIN:
|
||||
dprint("SPIDEY3: SPI_WIN\n");
|
||||
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);
|
||||
#endif
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef RGBLIGHT_ENABLE
|
||||
bool res = process_record_user_rgb(keycode, record);
|
||||
if (!res) return false;
|
||||
if (res) return true;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
layer_state_t default_layer_state_set_user(layer_state_t state) {
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
enum userspace_layers {
|
||||
_BASE = 0,
|
||||
_OSX,
|
||||
_NUMPAD,
|
||||
_FN,
|
||||
};
|
||||
|
||||
enum rgb_base_layer {
|
||||
RGB_LAYER_BASE_DEFAULT = _BASE,
|
||||
RGB_LAYER_BASE_REGULAR = _FN,
|
||||
RGB_LAYER_BASE_REGULAR = _NUMPAD,
|
||||
RGB_LAYER_BASE_ACKS = _FN+1,
|
||||
};
|
||||
|
||||
enum custom_keycodes {
|
||||
|
@ -32,6 +34,7 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record);
|
|||
layer_state_t layer_state_set_user_rgb(layer_state_t state);
|
||||
layer_state_t default_layer_state_set_user_rgb(layer_state_t state);
|
||||
bool led_update_user_rgb(led_t led_state);
|
||||
void clear_rgb_layers(void);
|
||||
#endif
|
||||
|
||||
#ifdef UNICODEMAP_ENABLE
|
||||
|
|
Loading…
Reference in a new issue