Fix syntax, add laylock with backlight toggle on locked layer (#2940)
* Create config.h * Create rules.mk * Create keymap.c * fix syntax and add latest
This commit is contained in:
parent
69ec54f3a4
commit
5b503cc543
1 changed files with 88 additions and 18 deletions
|
@ -27,6 +27,8 @@ enum custom_keycodes {
|
||||||
ONEHANDL,
|
ONEHANDL,
|
||||||
RLAYER,
|
RLAYER,
|
||||||
LLAYER,
|
LLAYER,
|
||||||
|
RLOCK,
|
||||||
|
LLOCK,
|
||||||
DUAL,
|
DUAL,
|
||||||
CONFIG,
|
CONFIG,
|
||||||
};
|
};
|
||||||
|
@ -44,13 +46,15 @@ enum {
|
||||||
/* LAYERS */
|
/* LAYERS */
|
||||||
#define KC_LLAY LLAYER
|
#define KC_LLAY LLAYER
|
||||||
#define KC_RLAY RLAYER
|
#define KC_RLAY RLAYER
|
||||||
|
#define KC_RLOK RLOCK
|
||||||
|
#define KC_LLOK LLOCK
|
||||||
#define KC_QWER QWERTY
|
#define KC_QWER QWERTY
|
||||||
#define KC_DVOR DVORAK
|
#define KC_DVOR DVORAK
|
||||||
#define KC_COLE COLEMAK
|
#define KC_COLE COLEMAK
|
||||||
#define KC_ONER ONEHANDR
|
#define KC_ONER ONEHANDR
|
||||||
#define KC_ONEL ONEHANDL
|
#define KC_ONEL ONEHANDL
|
||||||
#define KC_DUAL DUAL
|
#define KC_DUAL DUAL
|
||||||
#define KC_CONF OSL(_CONFIG)
|
#define KC_CONF CONFIG
|
||||||
|
|
||||||
/* Custom Shortened Keys */
|
/* Custom Shortened Keys */
|
||||||
#define KC_MCTB LCTL(KC_TAB)
|
#define KC_MCTB LCTL(KC_TAB)
|
||||||
|
@ -71,7 +75,7 @@ enum {
|
||||||
#define KC_BLUP BL_INC
|
#define KC_BLUP BL_INC
|
||||||
#define KC_BLDN BL_DEC
|
#define KC_BLDN BL_DEC
|
||||||
#define KC_SYSR KC_SYSREQ
|
#define KC_SYSR KC_SYSREQ
|
||||||
#define KC_FLASH RESET
|
#define KC_REST RESET
|
||||||
|
|
||||||
/* Tap Dance */
|
/* Tap Dance */
|
||||||
#define KC_LGUA TD(TD_LGUIAPP)
|
#define KC_LGUA TD(TD_LGUIAPP)
|
||||||
|
@ -82,13 +86,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_QWERTY] = LAYOUT_kc(
|
[_QWERTY] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
LEAD, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
TAB , Q , W , E , R , T , Y , U , I , O , P ,DEL ,
|
TAB , Q , W , E , R , T , Y , U , I , O , P ,DEL ,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
CTEC, A , S , D , F , G , H , J , K , L ,SCLN,ENT ,
|
CTEC, A , S , D , F , G , H , J , K , L ,SCLN,ENT ,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
SHCL, Z , X , C , V , B ,XXXX, XXXX, N , M ,COMM,DOT ,SLSH,RSFT,
|
SHCL, Z , X , C , V , B ,LLOK, RLOK, N , M ,COMM,DOT ,SLSH,RSFT,
|
||||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||||
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
||||||
// `----+----+----' `----+----+----'
|
// `----+----+----' `----+----+----'
|
||||||
|
@ -96,13 +100,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_COLEMAK] = LAYOUT_kc(
|
[_COLEMAK] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
LEAD, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,DEL ,
|
TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,DEL ,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
CTEC, A , R , S , T , D , H , N , E , I ,SCLN,ENT ,
|
CTEC, A , R , S , T , D , H , N , E , I , O ,ENT ,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
SHCL, Z , X , C , V , B ,XXXX, XXXX, K , M ,COMM,DOT ,SLSH,RSFT,
|
SHCL, Z , X , C , V , B ,LLOK, RLOK, K , M ,COMM,DOT ,SLSH,RSFT,
|
||||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||||
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
||||||
// `----+----+----' `----+----+----'
|
// `----+----+----' `----+----+----'
|
||||||
|
@ -110,13 +114,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_DVORAK] = LAYOUT_kc(
|
[_DVORAK] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
LEAD, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
XXXX, 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,BSPC,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,SLSH,
|
TAB ,QUOT,COMM,DOT , P , Y , F , G , C , R , L ,SLSH,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
CTEC, A , O , E , U , I , D , H , T , N , S ,ENT ,
|
CTEC, A , O , E , U , I , D , H , T , N , S ,ENT ,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
SHCL,SCLN, Q , J , K , X ,XXXX, XXXX, B , M , W , V , Z ,EQL ,
|
SHCL,SCLN, Q , J , K , X ,LLOK, RLOK, B , M , W , V , Z ,EQL ,
|
||||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||||
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
LALT,LLAY,TAB , SPC ,RLAY,LGUA
|
||||||
// `----+----+----' `----+----+----'
|
// `----+----+----' `----+----+----'
|
||||||
|
@ -138,7 +142,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_ONEHANDL] = LAYOUT_kc(
|
[_ONEHANDL] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
XXXX,XXXX,XXXX,XXXX,XXXX,XXXX, 5 , 4 , 3 , 2 , 1 ,LEAD,
|
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, T , R , E , W , Q ,TAB ,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
|
@ -152,13 +156,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_RLAYER] = LAYOUT_kc(
|
[_RLAYER] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
,XXXX,XXXX,XXXX,XXXX,XXXX, MUTE,VOLD,VOLU,BLDN,BLUP, ,
|
,SLCK,SYSR,PSCR,INS ,PAUS, MUTE,VOLD,VOLU,BLDN,BLUP, ,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
,TILD,GRV ,EQL ,LBRC,RBRC, PGUP,ASTR, UP ,AMPR,CIRC, ,
|
,TILD,GRV ,EQL ,LBRC,RBRC, ASTR,HOME, UP ,PGUP,PLUS, ,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
,EXLM,PIPE,DLR ,LPRN,RPRN, HOME,LEFT,DOWN,RGHT,END ,QUOT,
|
,EXLM,PIPE,DLR ,LPRN,RPRN, AMPR,LEFT,DOWN,RGHT,MINS,QUOT,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
, AT ,HASH,PERC,LCBR,RCBR,LGUI, ,PGDN,UNDS,MINS,PLUS,BSLS, ,
|
, AT ,HASH,PERC,LCBR,RCBR, , ,CIRC,END ,UNDS,PGDN,BSLS, ,
|
||||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||||
, , , , ,
|
, , , , ,
|
||||||
// `----+----+----' `----+----+----'
|
// `----+----+----' `----+----+----'
|
||||||
|
@ -172,7 +176,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
,XXXX,MCST,DOWN,MCTB,ENT , SLSH, 4 , 5 , 6 ,MINS, ,
|
,XXXX,MCST,DOWN,MCTB,ENT , SLSH, 4 , 5 , 6 ,MINS, ,
|
||||||
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
//|----+----+----+----+----+----+----. ,----|----+----+----+----+----+----|
|
||||||
,XXXX,XXXX,BSPC,SPC ,SINS,F11 , F12 ,EQL , 1 , 2 , 3 ,DOT , ,
|
,XXXX,XXXX,BSPC,SINS,SPC ,F11 , F12 ,EQL , 1 , 2 , 3 ,DOT , ,
|
||||||
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
//`----+----+----+--+-+----+----+----/ \----+----+----+----+----+----+----'
|
||||||
, , , 0 , ,
|
, , , 0 , ,
|
||||||
// `----+----+----' `----+----+----'
|
// `----+----+----' `----+----+----'
|
||||||
|
@ -180,7 +184,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_DUAL] = LAYOUT_kc(
|
[_DUAL] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
,XXXX,XXXX,PSCR,INS ,XXXX, XXXX,SLEP,SLCK,PAUS,SYSR,XXXX,
|
,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,MCAD,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
|
@ -194,7 +198,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
|
|
||||||
[_CONFIG] = LAYOUT_kc(
|
[_CONFIG] = LAYOUT_kc(
|
||||||
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
//,----+----+----+----+----+----. ,----+----+----+----+----+----.
|
||||||
FLASH,XXXX,XXXX,XXXX,XXXX,XXXX, XXXX,XXXX,XXXX,XXXX,XXXX,XXXX,
|
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,ONER,XXXX,XXXX,
|
||||||
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
//|----+----+----+----+----+----| |----+----+----+----+----+----|
|
||||||
|
@ -237,6 +241,11 @@ void persistent_default_layer_set(uint16_t default_layer) {
|
||||||
default_layer_set(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) {
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
switch (keycode) {
|
switch (keycode) {
|
||||||
case QWERTY:
|
case QWERTY:
|
||||||
|
@ -263,14 +272,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
case CONFIG:
|
||||||
|
if (record->event.pressed) {
|
||||||
|
set_single_persistent_default_layer(_CONFIG);
|
||||||
|
backlight_toggle();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
case RLAYER:
|
case RLAYER:
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
layer_on(_RLAYER);
|
layer_on(_RLAYER);
|
||||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
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);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
unregister_code(KC_LGUI);
|
unregister_code(KC_LGUI);
|
||||||
|
rlocked = 0;
|
||||||
layer_off(_RLAYER);
|
layer_off(_RLAYER);
|
||||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
||||||
|
if ( llocked == 0 ) {
|
||||||
|
backlight_set(currentBL);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
@ -278,9 +306,51 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
||||||
if (record->event.pressed) {
|
if (record->event.pressed) {
|
||||||
layer_on(_LLAYER);
|
layer_on(_LLAYER);
|
||||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
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 {
|
} else {
|
||||||
|
backlight_set(0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
llocked = 0;
|
||||||
layer_off(_LLAYER);
|
layer_off(_LLAYER);
|
||||||
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
update_tri_layer(_RLAYER, _LLAYER, _DUAL);
|
||||||
|
if ( rlocked == 0 ) {
|
||||||
|
backlight_set(currentBL);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case RLOCK:
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case LLOCK:
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue