|
|
@ -1,17 +1,26 @@
|
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
|
|
|
|
|
|
|
|
//Layer definitions
|
|
|
|
// custom type to store stuff in EEPROM
|
|
|
|
|
|
|
|
typedef union {
|
|
|
|
|
|
|
|
uint32_t raw;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
|
|
|
bool layer_rgb :1;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} user_config_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user_config_t user_config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Layer definitions
|
|
|
|
#define _BL 0
|
|
|
|
#define _BL 0
|
|
|
|
#define _DL 1
|
|
|
|
#define _DL 1
|
|
|
|
#define _UL 2
|
|
|
|
#define _UL 2
|
|
|
|
#define _GL 3
|
|
|
|
#define _GL 3
|
|
|
|
#define _BK 4
|
|
|
|
#define _BK 4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Custom keycode to toggle normal RGB or per-layer RGB
|
|
|
|
//other variables
|
|
|
|
enum custom_keycodes {
|
|
|
|
int mCalled = 0;
|
|
|
|
CUSTRGB = SAFE_RANGE,
|
|
|
|
bool blockToggle = false;
|
|
|
|
};
|
|
|
|
bool lRGB = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
|
|
|
|
|
|
|
|
|
@ -30,111 +39,82 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
|
|
[_UL] = LAYOUT(
|
|
|
|
[_UL] = LAYOUT(
|
|
|
|
KC_GRV, KC_LBRC, KC_RBRC, KC_LCBR, KC_RCBR, KC_PIPE, KC_BSLS, KC_PLUS, KC_UNDS, KC_MINS, KC_EQL, KC_DEL,\
|
|
|
|
KC_GRV, KC_LBRC, KC_RBRC, KC_LCBR, KC_RCBR, KC_PIPE, KC_BSLS, KC_PLUS, KC_UNDS, KC_MINS, KC_EQL, KC_DEL,\
|
|
|
|
KC_TRNS, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_FN0, RGB_TOG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, \
|
|
|
|
KC_TRNS, CUSTRGB, RGB_TOG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, RGB_SAD, RGB_VAD, KC_TRNS, KC_TRNS, \
|
|
|
|
KC_TRNS, RGB_MOD, RGB_HUI, KC_TRNS, KC_TRNS, RGB_SAI, RGB_VAI),
|
|
|
|
KC_TRNS, RGB_MOD, RGB_HUI, KC_TRNS, KC_TRNS, RGB_SAI, RGB_VAI),
|
|
|
|
|
|
|
|
|
|
|
|
[_GL] = LAYOUT(
|
|
|
|
[_GL] = LAYOUT(
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, \
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_SPC, KC_SPC, KC_TRNS, KC_TRNS),
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_SPC, KC_SPC, KC_TRNS, KC_TRNS)
|
|
|
|
|
|
|
|
|
|
|
|
[_BK] = LAYOUT(
|
|
|
|
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
|
|
|
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,\
|
|
|
|
|
|
|
|
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_NO, KC_NO, KC_TRNS, KC_TRNS, \
|
|
|
|
|
|
|
|
KC_TRNS, KC_NO, KC_NO, KC_TRNS, KC_FN1, KC_NO, KC_NO),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void keyboard_post_init_user(void) {
|
|
|
|
//KC_MPLY, KC_VOLU, KC_VOLD, KC_TRNS, KC_TRNS, KC_MNXT, KC_MPRV
|
|
|
|
user_config.raw = eeconfig_read_user();
|
|
|
|
//function to toggle the interactive rgb variable
|
|
|
|
if(user_config.layer_rgb) {
|
|
|
|
bool toggleLayerRGB(void){
|
|
|
|
rgblight_enable_noeeprom();
|
|
|
|
if(lRGB == true){
|
|
|
|
rgblight_mode_noeeprom(1);
|
|
|
|
return false;
|
|
|
|
rgblight_sethsv_noeeprom(0,10,255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void matrix_init_user(void){
|
|
|
|
|
|
|
|
rgblight_enable();
|
|
|
|
|
|
|
|
rgblight_mode(1);
|
|
|
|
|
|
|
|
rgblight_sethsv(0,10,255);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//check for layer and if there was a keypress change underglow lighting
|
|
|
|
uint32_t layer_state_set_user(uint32_t state) {
|
|
|
|
void matrix_scan_kb(void){
|
|
|
|
// This code switches underglow color by active layer, if the user has enabled the feature
|
|
|
|
if(lRGB == true)
|
|
|
|
if(user_config.layer_rgb) {
|
|
|
|
{
|
|
|
|
switch (biton32(state)) {
|
|
|
|
|
|
|
|
case _BL:
|
|
|
|
|
|
|
|
rgblight_sethsv_noeeprom(0,10,255);
|
|
|
|
|
|
|
|
rgblight_mode_noeeprom(1);
|
|
|
|
//base layer
|
|
|
|
break;
|
|
|
|
if(layer_state == 0x00000000 && mCalled == 1 ){
|
|
|
|
case _DL:
|
|
|
|
rgblight_sethsv(0,10,255);
|
|
|
|
rgblight_sethsv_noeeprom(130,200,255);
|
|
|
|
mCalled = 0;
|
|
|
|
rgblight_mode_noeeprom(1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case _UL:
|
|
|
|
|
|
|
|
rgblight_sethsv_noeeprom(170,200,255);
|
|
|
|
|
|
|
|
rgblight_mode_noeeprom(1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case _GL:
|
|
|
|
|
|
|
|
rgblight_sethsv_noeeprom(0,180,255);
|
|
|
|
|
|
|
|
rgblight_mode_noeeprom(1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//down layer
|
|
|
|
|
|
|
|
else if(layer_state == 0x00000002 && mCalled == 1){
|
|
|
|
|
|
|
|
rgblight_sethsv(160,255,255);
|
|
|
|
|
|
|
|
mCalled = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool process_record_user (uint16_t keycode, keyrecord_t *record) {
|
|
|
|
//up layer with rgb access blocked
|
|
|
|
switch (keycode) {
|
|
|
|
else if(layer_state == 0x00000004 && mCalled == 1 && lRGB == true){
|
|
|
|
case CUSTRGB: // if the user toggled per-layer RGB, update the config and refresh the RGB color
|
|
|
|
//blockToggle = true;
|
|
|
|
if(record->event.pressed) {
|
|
|
|
layer_state = 0x00000014;
|
|
|
|
user_config.layer_rgb ^= 1;
|
|
|
|
rgblight_sethsv(180,255,255);
|
|
|
|
eeconfig_update_user(user_config.raw);
|
|
|
|
mCalled = 0;
|
|
|
|
if (user_config.layer_rgb) {
|
|
|
|
|
|
|
|
layer_state_set(layer_state);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//arrow cluster layer
|
|
|
|
|
|
|
|
else if(layer_state == 0x00000008 && mCalled == 1){
|
|
|
|
|
|
|
|
rgblight_sethsv(0,180,255);
|
|
|
|
|
|
|
|
mCalled = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
//if on blocked layer and the spacebar has been released reset to baselayer and set colours to white
|
|
|
|
break;
|
|
|
|
else if(layer_state == 0x00000014 && blockToggle == true )
|
|
|
|
case RGB_MOD:
|
|
|
|
{
|
|
|
|
case RGB_SAD:
|
|
|
|
blockToggle = false;
|
|
|
|
case RGB_SAI:
|
|
|
|
layer_state = 0x00000000;
|
|
|
|
case RGB_HUI:
|
|
|
|
rgblight_sethsv(0,10,255);
|
|
|
|
case RGB_VAD:
|
|
|
|
|
|
|
|
case RGB_VAI:
|
|
|
|
|
|
|
|
if(user_config.layer_rgb && record->event.pressed) {
|
|
|
|
|
|
|
|
return false; // if layer RGB is on, ignore attempts to change RGB settings
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//set mCalled to 1 when a button is pressed to make sure the leds aren't continuesly updated.
|
|
|
|
void eeconfig_init_user(void) { // in case EEPROM is reset, set up our custom config
|
|
|
|
bool process_record_user (uint16_t keycode, keyrecord_t *record) {
|
|
|
|
user_config.raw = 0;
|
|
|
|
mCalled = 1;
|
|
|
|
user_config.layer_rgb = true; // enable per-layer RGB by default
|
|
|
|
|
|
|
|
eeconfig_update_user(user_config.raw);
|
|
|
|
//uncommenting the line below causes the lights to flicker when typing on the keyboard.
|
|
|
|
|
|
|
|
//rgblight_sethsv(0,255,0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(keycode == KC_FN0 && record->event.pressed){
|
|
|
|
|
|
|
|
//set the toggle and make sure to set the colour back to white
|
|
|
|
|
|
|
|
lRGB = toggleLayerRGB();
|
|
|
|
|
|
|
|
rgblight_enable();
|
|
|
|
rgblight_enable();
|
|
|
|
|
|
|
|
rgblight_sethsv(0,10,255);
|
|
|
|
rgblight_mode(1);
|
|
|
|
rgblight_mode(1);
|
|
|
|
rgblight_sethsv(0,255,255);
|
|
|
|
|
|
|
|
layer_state =0x00000000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//check if spacebar is released when on a different layer
|
|
|
|
|
|
|
|
if(keycode == KC_FN1){
|
|
|
|
|
|
|
|
if(record ->event.pressed){
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
blockToggle = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|