Keymap: update keymap transmogrified (#4241)

* layer locked breathing, layer changed brighter leds

* move config for tapping term into config.h

* Respect LED off even with layer indicators, add readme and update config
to new standard

* update Readme with note about both sides of board being required to flash
pull/4265/head
akrob 6 years ago committed by Drashna Jaelre
parent 9ea0103520
commit 5be438f03d

@ -0,0 +1,9 @@
This layout is an attempt to make switching between the Iris and my laptop keyboard as seemless as possible. I switch caps lock and Ctrl/ESC on my laptop and I am able to adjust well with everything else... I still miss the Iris, but I am able to get work done.
I use the following lighting queues to indicate layer changes.
* Momentary toggled layer : LEDs brighten and dim when layer is released.
* Locked layer : LEDs breath.
* Config layer locked : LEDs off.
NOTE you will need to flash both sides to update the brightness_levels so that breathing works on both sides as expected.

@ -1,5 +1,5 @@
/*
Copyright 2017 Danny Nguyen <danny@keeb.io>
Copyright 2017 Adam Roberts <adam+gh@bikuman.com>
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
@ -15,11 +15,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONFIG_USER_H
#define CONFIG_USER_H
#include "config_common.h"
#pragma once
/* Use I2C or Serial, not both */
@ -27,8 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// #define USE_I2C
/* Select hand configuration */
// #define MASTER_LEFT
//#define MASTER_LEFT
#define MASTER_RIGHT
// #define EE_HANDS
@ -39,4 +34,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_SAT_STEP 8
#define RGBLIGHT_VAL_STEP 8
#endif
#define NO_USB_STARTUP_CHECK //keep both sides on when pc is sleeping.
#define TAPPING_TERM 200
// Remove features i don't use
#define NO_ACTION_ONESHOT
#define NO_ACTION_MACRO
// Override the rev2 config.h BACKLIGHT_LEVELS setting
#undef BACKLIGHT_LEVELS
#define BACKLIGHT_LEVELS 125

@ -2,64 +2,55 @@
#include "action_layer.h"
#include "eeconfig.h"
// config settings
#define TAPPING_TERM 250
#define ONESHOT_TAP_TOGGLE 1
#define ONESHOT_TIMEOUT 10000
extern keymap_config_t keymap_config;
#define _QWERTY 0
#define _COLEMAK 1
#define _DVORAK 2
#define _ONEHANDR 3
#define _ONEHANDL 4
#define _RLAYER 5
#define _LLAYER 6
#define _DUAL 7
#define _CONFIG 8
#define _RLAYER 2
#define _LLAYER 3
#define _DUAL 4
#define _CONFIG 5
enum custom_keycodes {
QWERTY = SAFE_RANGE,
COLEMAK,
DVORAK,
ONEHANDR,
ONEHANDL,
RLAYER,
LLAYER,
RLOCK,
LLOCK,
DUAL,
CONFIG,
QWERTY = SAFE_RANGE, // qwerty base layer
COLEMAK, // colemak base layer
RLAYER, // right layer
LLAYER, // left layer
RLOCK, // right layer LOCK
LLOCK, // left layer LOCK
DUAL, // right and left combo layer
CONFIG, // config layer
LEDUP, // custom LED brightness increase keycode
LEDDOWN, // custom LED brightness decrease keycode
};
/* Tap Dance */
enum {
TD_LGUIAPP,
TD_SHIFTCAPS,
TD_LGUIAPP, // LGUI x1, app/menu x2
TD_SHIFTCAPS, // LSHIFT x1, CAPS x3
TD_CTRLALTDL, // CTRL+ALT+DEL x3
TD_SHIFTCLAT, // LSHIFT x1, LCRTL x2, LALT x3, CTRL+ALT x4
};
/* NOOP Key and Transparent */
#define KC_ KC_TRNS
#define KC_XXXX KC_NO
/* LAYERS */
/* LAYERS / CUSTOM KEYS */
#define KC_LLAY LLAYER
#define KC_RLAY RLAYER
#define KC_RLOK RLOCK
#define KC_LLOK LLOCK
#define KC_QWER QWERTY
#define KC_DVOR DVORAK
#define KC_COLE COLEMAK
#define KC_ONER ONEHANDR
#define KC_ONEL ONEHANDL
#define KC_DUAL DUAL
#define KC_CONF CONFIG
#define KC_BLUP LEDUP
#define KC_BLDN LEDDOWN
/* Custom Shortened Keys */
/* Custom Shortened Keys (4 digits so they fit in my grid) */
#define KC_MCTB LCTL(KC_TAB)
#define KC_MCST LCTL(LSFT(KC_TAB))
#define KC_MCAD LALT(LCTL(KC_DEL))
#define KC_CTEC CTL_T(KC_ESC)
#define KC_SINS LSFT(KC_INS)
#define KC_LGU1 LGUI(KC_1)
@ -72,27 +63,27 @@ enum {
#define KC_LGU8 LGUI(KC_8)
#define KC_LGU9 LGUI(KC_9)
#define KC_LGU0 LGUI(KC_0)
#define KC_BLUP BL_INC
#define KC_BLDN BL_DEC
#define KC_SYSR KC_SYSREQ
#define KC_REST RESET
/* Tap Dance */
#define KC_LGUA TD(TD_LGUIAPP)
#define KC_SHCL TD(TD_SHIFTCAPS)
#define KC_SHCP TD(TD_SHIFTCAPS)
#define KC_CADL TD(TD_CTRLALTDL)
#define KC_SHCA TD(TD_SHIFTCLAT)
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
CADL, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
TAB , Q , W , E , R , T , Y , U , I , O , P ,DEL ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
CTEC, A , S , D , F , G , H , J , K , L ,SCLN,ENT ,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
SHCL, Z , X , C , V , B ,LLOK, RLOK, N , M ,COMM,DOT ,SLSH,RSFT,
SHCP, Z , X , C , V , B ,LLOK, RLOK, N , M ,COMM,DOT ,SLSH,SHCA,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
LALT,LLAY,TAB , SPC ,RLAY,LGUA
// `----+----+----' `----+----+----'
@ -100,60 +91,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_COLEMAK] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
CADL, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,DEL ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
CTEC, A , R , S , T , D , H , N , E , I , O ,ENT ,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
SHCL, Z , X , C , V , B ,LLOK, RLOK, K , M ,COMM,DOT ,SLSH,RSFT,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
LALT,LLAY,TAB , SPC ,RLAY,LGUA
// `----+----+----' `----+----+----'
),
[_DVORAK] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,SLSH,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
CTEC, A , O , E , U , I , D , H , T , N , S ,ENT ,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
SHCL,SCLN, Q , J , K , X ,LLOK, RLOK, B , M , W , V , Z ,EQL ,
SHCP, Z , X , C , V , B ,LLOK, RLOK, K , M ,COMM,DOT ,SLSH,SHCA,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
LALT,LLAY,TAB , SPC ,RLAY,LGUA
// `----+----+----' `----+----+----'
),
[_ONEHANDR] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, 6 , 7 , 8 , 9 , 0 ,BSPC,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, Y , U , I , O , P ,DEL ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, H , J , K , L ,SCLN,QUOT,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,QWER, XXXX, N , M ,COMM,DOT ,SLSH,RSFT,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
XXXX,XXXX,XXXX, SPC ,ONEL,ENT
// `----+----+----' `----+----+----'
),
[_ONEHANDL] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, 5 , 4 , 3 , 2 , 1 ,XXXX,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, T , R , E , W , Q ,TAB ,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, G , F , D , S , A ,ENT ,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX, B , V , C , X , Z ,SHCL,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
XXXX,XXXX,XXXX, SPC ,ONEL,ENT
// `----+----+----' `----+----+----'
),
[_RLAYER] = LAYOUT_kc(
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
,SLCK,SYSR,PSCR,INS ,PAUS, MUTE,VOLD,VOLU,BLDN,BLUP, ,
@ -163,7 +112,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
,EXLM,PIPE,DLR ,LPRN,RPRN, AMPR,LEFT,DOWN,RGHT,MINS,QUOT,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
, AT ,HASH,PERC,LCBR,RCBR, , ,CIRC,END ,UNDS,PGDN,BSLS, ,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
, , , , ,
// `----+----+----' `----+----+----'
),
@ -186,7 +135,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,MS_U,XXXX,XXXX,MCAD,
,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,MS_U,XXXX,XXXX,XXXX,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
,XXXX,XXXX,XXXX,XXXX,XXXX, BTN2,MS_L,MS_D,MS_R,BTN1,XXXX,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
@ -200,9 +149,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
REST,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
XXXX,QWER,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,ONER,XXXX,XXXX,
XXXX,QWER,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
//|----+----+----+----+----+----| |----+----+----+----+----+----|
XXXX,XXXX,XXXX,DVOR,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
XXXX,XXXX,XXXX,COLE,XXXX,XXXX, , ,XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
@ -212,6 +161,26 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
/* VARIABLES */
// Configurable Variables for layer toggled light
int layerBLStep = 20; // change how much the brightness changes when holding layer key
int breathPulse = 5; // timing of the breathing
int breathPulseStall = 3; // time to pause at top and bottom of breath cycle
int blSteps = 6; // blSteps + 1 is the amount of brightness settings when manually adjusting
// Variables needed for layer locked breathing and layer toggling lighting to work
int counter = 0;
bool breathUp = true;
bool resetBL = false;
bool rlocked = false;
bool llocked = false;
bool configOn = false;
int lockedBLLevel;
int momentaryLBLLevel;
int momentaryRBLLevel;
int currentBL;
/* END VARIABLES */
/* TAP DANCE */
void shift_caps_down (qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 3) {
@ -220,7 +189,6 @@ void shift_caps_down (qk_tap_dance_state_t *state, void *user_data) {
register_code (KC_LSFT);
}
}
void shift_caps_up (qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 3) {
unregister_code (KC_CAPS);
@ -228,54 +196,90 @@ void shift_caps_up (qk_tap_dance_state_t *state, void *user_data) {
unregister_code (KC_LSFT);
}
}
void shift_ctrlalt_down (qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 4) {
register_code (KC_LCTL);
register_code (KC_LALT);
} else if (state->count == 3) {
register_code (KC_LALT);
} else if (state->count == 2) {
register_code (KC_LCTL);
} else {
register_code (KC_RSFT);
}
}
void shift_ctlalt_up (qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 4) {
unregister_code (KC_LALT);
unregister_code (KC_LCTL);
} else if (state->count == 3) {
unregister_code (KC_LALT);
} else if (state->count == 2) {
unregister_code (KC_LCTL);
} else {
unregister_code (KC_RSFT);
}
}
void ctrlaltdel_up (qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 3) {
unregister_code (KC_DEL);
unregister_code (KC_LALT);
unregister_code (KC_LCTL);
} else {
}
}
void ctrlaltdel_down (qk_tap_dance_state_t *state, void *user_data) {
if (state->count >= 3) {
register_code (KC_LCTL);
register_code (KC_LALT);
register_code (KC_DEL);
} else {
}
}
qk_tap_dance_action_t tap_dance_actions[] = {
[TD_LGUIAPP] = ACTION_TAP_DANCE_DOUBLE(KC_LGUI, KC_APP),
[TD_SHIFTCAPS] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, shift_caps_down, shift_caps_up)
[TD_SHIFTCAPS] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, shift_caps_down, shift_caps_up),
[TD_SHIFTCLAT] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, shift_ctrlalt_down, shift_ctlalt_up),
[TD_CTRLALTDL] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, ctrlaltdel_down, ctrlaltdel_up)
};
/* END TAP DANCE */
void persistent_default_layer_set(uint16_t default_layer) {
eeconfig_update_default_layer(default_layer);
default_layer_set(default_layer);
}
/* Variables for layer light toggling */
static uint16_t currentBL = 0;
static uint16_t rlocked = 0;
static uint16_t llocked = 0;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case QWERTY:
if (record->event.pressed) {
set_single_persistent_default_layer(_QWERTY);
configOn = false;
if (momentaryRBLLevel != 0 || momentaryLBLLevel != 0){
backlight_toggle();
}
}
return false;
break;
case COLEMAK:
if (record->event.pressed) {
set_single_persistent_default_layer(_COLEMAK);
}
return false;
break;
case ONEHANDR:
if (record->event.pressed) {
set_single_persistent_default_layer(_ONEHANDR);
}
return false;
break;
case DVORAK:
if (record->event.pressed) {
set_single_persistent_default_layer(_DVORAK);
configOn = false;
if (momentaryRBLLevel != 0 || momentaryLBLLevel != 0){
backlight_toggle();
}
}
return false;
break;
case CONFIG:
if (record->event.pressed) {
set_single_persistent_default_layer(_CONFIG);
backlight_toggle();
configOn = true;
if (momentaryRBLLevel != 0 || momentaryLBLLevel != 0){
backlight_toggle();
}
}
return false;
break;
@ -283,22 +287,23 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
layer_on(_RLAYER);
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
/* add logic to toggle backlight change when on a layer */
currentBL = get_backlight_level();
if ( currentBL == 0 || currentBL == 1 ) {
backlight_set(5);
} else {
backlight_set(0);
momentaryRBLLevel = get_backlight_level();
if (momentaryRBLLevel != 0 || momentaryLBLLevel != 0){
for (int i = 0; i < layerBLStep ; i++){
backlight_increase();
}
}
} else {
unregister_code(KC_LGUI);
rlocked = 0;
layer_off(_RLAYER);
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
if ( llocked == 0 ) {
backlight_set(currentBL);
if ( llocked == false && configOn == false ) {
for (int i = 0; i < layerBLStep ; i++){
backlight_decrease();
}
} else {
}
rlocked = false;
}
return false;
break;
@ -306,21 +311,22 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
layer_on(_LLAYER);
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
/* add logic to toggle backlight change when on a layer */
currentBL = get_backlight_level();
if ( currentBL == 0 || currentBL == 1 ) {
backlight_set(5);
} else {
backlight_set(0);
momentaryLBLLevel = get_backlight_level();
if (momentaryRBLLevel != 0 || momentaryLBLLevel != 0){
for (int i = 0; i < layerBLStep ; i++){
backlight_increase();
}
}
} else {
llocked = 0;
layer_off(_LLAYER);
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
if ( rlocked == 0 ) {
backlight_set(currentBL);
if ( rlocked == false && configOn == false ) {
for (int i = 0; i < layerBLStep ; i++){
backlight_decrease();
}
} else {
}
llocked = false;
}
return false;
break;
@ -328,13 +334,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
layer_on(_RLAYER);
/* add logic to toggle backlight change when on a layer */
rlocked = 1;
currentBL = get_backlight_level();
if ( currentBL == 0 || currentBL == 1 ) {
backlight_set(5);
} else {
backlight_set(0);
if (rlocked == false && llocked == false){
lockedBLLevel = get_backlight_level();
}
rlocked = true;
} else {
}
return false;
@ -343,25 +346,76 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
layer_on(_LLAYER);
/* add logic to toggle backlight change when on a layer */
llocked = 1;
currentBL = get_backlight_level();
if ( currentBL == 0 || currentBL == 1 ) {
backlight_set(5);
} else {
backlight_set(0);
if (rlocked == false && llocked == false){
lockedBLLevel = get_backlight_level();
}
llocked = true;
} else {
}
return false;
break;
case LEDUP:
if (record->event.pressed) {
for (int i = 0; i < (BACKLIGHT_LEVELS / blSteps ) ; i++ ){
backlight_increase();
}
} else {
}
return false;
break;
case ONEHANDL:
case LEDDOWN:
if (record->event.pressed) {
layer_on(_ONEHANDL);
for (int i = 0; i < (BACKLIGHT_LEVELS / blSteps ) ; i++ ){
backlight_decrease();
}
} else {
layer_off(_ONEHANDL);
}
return false;
break;
}
return true;
}
// LED breathing when a layer is locked
void matrix_scan_user(void) {
// Only breath if layer is locked
if (lockedBLLevel != 0 && (rlocked || llocked)){
// counter to slow down the breathing
if (counter >= breathPulse) {
counter = 0;
// iterate brightness up or down
if (breathUp){
backlight_increase();
} else {
backlight_decrease();
}
// figure out if we need to change directions
currentBL = get_backlight_level();
if (currentBL >= BACKLIGHT_LEVELS){
breathUp = false;
// make counter a big negative number to add some stall time
counter = ((BACKLIGHT_LEVELS * breathPulseStall) * (-1));
} else if (currentBL == 0){
breathUp = true;
// make counter a big negative number to add some stall time
counter = ((BACKLIGHT_LEVELS * breathPulseStall) * (-1));
}
// make not that we need to change the brightness back to when we started the breathing
resetBL = true;
} else {
counter++;
}
} else {
// get the brightness back to the level it started at
if (resetBL){
int i = 0;
// i is just there to make sure i don't get stuck in a loop if for some reason get_backlight_level isn't working as expected
while (get_backlight_level() != lockedBLLevel && i <= BACKLIGHT_LEVELS ){
backlight_step();
i++;
}
resetBL = false;
}
}
}

Loading…
Cancel
Save