1
0
Fork 0

[Keymap] Add spidey3 keymap for 75_ansi, and a spidey3 userspace (#8470)

* 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

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:
spidey3 2020-03-23 00:11:41 -04:00 committed by GitHub
parent 6d1af63842
commit 7e0dc5376f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 351 additions and 0 deletions

View file

@ -0,0 +1,33 @@
#include "spidey3.h"
#define SETTINGS A(S(KC_S))
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_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
),
// OSX layout
[_OSX] = LAYOUT_75_ansi(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_EJCT, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, KC_LALT, KC_LGUI, _______, _______, _______, _______, _______, _______, _______
),
// 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, _______
)
};

View file

@ -0,0 +1,14 @@
Copyright 2020 Joshua Diamond josh@windowoffire.com @spidey3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

View file

@ -0,0 +1,15 @@
# 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

5
users/spidey3/config.h Normal file
View file

@ -0,0 +1,5 @@
#pragma once
#define LED_DISABLE_WHEN_USB_SUSPENDED true
#define RGB_DISABLE_WHEN_USB_SUSPENDED true
#define RGBLIGHT_LAYERS

21
users/spidey3/init.c Normal file
View file

@ -0,0 +1,21 @@
#include "spidey3.h"
void keyboard_post_init_user(void) {
print("SPIDEY3: keyboard_post_init_user\n");
uprintf(" debug_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");
set_single_persistent_default_layer(_BASE);
#ifdef UNICODEMAP_ENABLE
eeconfig_init_user_unicode();
#endif
#ifdef RGBLIGHT_ENABLE
eeconfig_init_user_rgb();
#endif
}

81
users/spidey3/layer_rgb.c Normal file
View file

@ -0,0 +1,81 @@
#include QMK_KEYBOARD_H
#include "spidey3.h"
#include "velocikey.h"
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("SPIDEY3: Setting Spidey Swirl!\n");
rgblight_enable();
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
rgblight_sethsv(213, 255, 128);
#ifdef VELOCIKEY_ENABLE
if (!velocikey_enabled())
velocikey_toggle();
#endif
}
void eeconfig_init_user_rgb(void)
{
spidey_swirl();
}
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} );
// 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 uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1;
void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) {
dprint("SPIDEY3: 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);
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);
// 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");
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);
return state;
}
bool led_update_user_rgb(led_t led_state) {
dprintf("SPIDEY3: caps_lock=%u\n", led_state.caps_lock);
rgblight_set_layer_state(0, led_state.caps_lock);
return true;
}
bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case SPI_GLO:
if (record->event.pressed) {
spidey_swirl();
}
break;
}
return true;
}

14
users/spidey3/readme.md Normal file
View file

@ -0,0 +1,14 @@
Copyright 2020 Joshua Diamond josh@windowoffire.com @spidey3
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

10
users/spidey3/rules.mk Normal file
View file

@ -0,0 +1,10 @@
SRC += init.c
SRC += spidey3.c
ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
SRC += layer_rgb.c
endif
ifeq ($(strip $(UNICODEMAP_ENABLE)), yes)
SRC += unicode.c
endif

80
users/spidey3/spidey3.c Normal file
View file

@ -0,0 +1,80 @@
#include QMK_KEYBOARD_H
#include "spidey3.h"
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// 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);
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");
}
eeconfig_update_debug(debug_config.raw);
#endif
return false;
case SPI_LNX:
dprint("SPIDEY3: 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;
case SPI_OSX:
dprint("SPIDEY3: 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;
case SPI_WIN:
dprint("SPIDEY3: 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;
}
}
#ifdef RGBLIGHT_ENABLE
bool res = process_record_user_rgb(keycode, record);
if (!res) return false;
#endif
return true;
}
layer_state_t default_layer_state_set_user(layer_state_t state) {
#ifdef RGBLIGHT_ENABLE
return default_layer_state_set_user_rgb(state);
#else
return state;
#endif
}
layer_state_t layer_state_set_user(layer_state_t state) {
#ifdef RGBLIGHT_ENABLE
return layer_state_set_user_rgb(state);
#else
return state;
#endif
}
bool led_update_user(led_t led_state) {
#ifdef RGBLIGHT_ENABLE
return led_update_user_rgb(led_state);
#else
return true;
#endif
}

40
users/spidey3/spidey3.h Normal file
View file

@ -0,0 +1,40 @@
#pragma once
#include QMK_KEYBOARD_H
#ifdef UNICODEMAP_ENABLE
#include "unicode.h"
#endif
enum userspace_layers {
_BASE = 0,
_OSX,
_FN,
};
enum rgb_base_layer {
RGB_LAYER_BASE_DEFAULT = _BASE,
RGB_LAYER_BASE_REGULAR = _FN,
};
enum custom_keycodes {
SPI_GLO = SAFE_RANGE,
SPI_LNX,
SPI_OSX,
SPI_WIN,
};
#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);
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);
#endif
#ifdef UNICODEMAP_ENABLE
void eeconfig_init_user_unicode(void);
#endif

19
users/spidey3/unicode.c Normal file
View file

@ -0,0 +1,19 @@
#include "unicode.h"
const uint32_t PROGMEM unicode_map[] = {
[BUL1] = 0x2022, // •
[BUL2] = 0x25E6, // ◦
[LARR] = 0x2190, // ←
[RARR] = 0x2192, // →
[ENDASH] = 0x2013, //
[EMDASH] = 0x2014, // —
};
void eeconfig_init_user_unicode(void)
{
// Default to Linux style
set_unicode_input_mode(UC_LNX);
}

19
users/spidey3/unicode.h Normal file
View file

@ -0,0 +1,19 @@
#pragma once
#include QMK_KEYBOARD_H
#ifdef UNICODEMAP_ENABLE
enum unicode_names {
BUL1,
BUL2,
LARR,
RARR,
ENDASH,
EMDASH,
};
#define X_BUL (XP(BUL1, BUL2))
#define X_DASH (XP(ENDASH, EMDASH))
#endif