#include QMK_KEYBOARD_H
#define _QW 0
#define _FN 1
#define TD_ESCP TD(TD_GV_ESC)
#define TD_MINS TD(TD_MIN)
#define TD_BRAC TD(TD_BRC)
#define FN_SPC LT(_FN, KC_SPC)
#define LG_ZMIN LGUI(KC_EQUAL)
#define LG_ZMOT LGUI(KC_MINUS)
#define MT_SHFT MT(MOD_RSFT, KC_ENT)
enum {
TD_BRC = 0,
TD_MIN,
TD_GV_ESC,
TD_BS
};
qk_tap_dance_action_t tap_dance_actions[] = {
[TD_BRC] = ACTION_TAP_DANCE_DOUBLE(KC_LBRC, KC_RBRC),
[TD_MIN] = ACTION_TAP_DANCE_DOUBLE(KC_MINUS, KC_EQUAL),
[TD_GV_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_GRAVE, KC_ESCAPE)
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QW] = LAYOUT_ortho_5x15(
TD_ESCP, KC_1, KC_2, KC_3, KC_4, KC_5, KC_MINS, KC_GRV, KC_PIPE, KC_6, KC_7, KC_8, KC_9, KC_0, TD_MINS, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_LBRC, KC_BSLS, KC_RBRC, KC_Y, KC_U, KC_I, KC_O, KC_P, TD_BRAC, \
_______, KC_A, KC_S, KC_D, KC_F, KC_G, _______, _______, _______, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, _______, _______, _______, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, MT_SHFT, \
LG_ZMOT, LG_ZMIN, KC_LCTL, KC_LALT, KC_LGUI, KC_BSPC, _______, RESET, _______, FN_SPC, KC_ENT, KC_LEFT, KC_UP, KC_DOWN, KC_RGHT \
),
[_FN] = LAYOUT_ortho_5x15(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, _______, _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
_______, _______, _______, _______, _______, _______, RGB_HUD, RGB_HUI, _______, _______, _______, _______, _______, _______, _______, \
KC_ASTG, _______, _______, _______, _______, _______, RGB_SAD, RGB_SAI, _______, _______, KC_LEFT, KC_UP, KC_DOWN, KC_RGHT, _______, \
RGB_TOG, _______, _______, _______, _______, _______, RGB_VAD, RGB_VAI, _______, _______, _______, _______, _______, _______, _______, \
RESET, _______, _______, _______, _______, _______, RGB_RMOD,RGB_MOD, _______, _______, KC_MPLY, KC_MRWD, KC_VOLU, KC_VOLD, KC_MFFD \
),
};
uint8_t h = 170;
uint8_t s = 255;
uint8_t v;
uint8_t rgbMode = RGBLIGHT_MODE_STATIC_LIGHT;
uint8_t rgbBootMode = RGBLIGHT_MODE_SNAKE;
uint8_t bootComplete = 0;
int bootTimeoutDuration = 2000;
int bootTimeout;
void init_hsv(void) {
v = rgblight_get_val();
rgblight_sethsv(h,s,v);
}
void get_hsv(void) {
h = rgblight_get_hue();
s = rgblight_get_sat();
v = rgblight_get_val();
}
void reset_hsv(void) {
int currentV = rgblight_get_val();
rgblight_sethsv(h,s,currentV);
}
void bootupAnimation(void) {
bootComplete = (timer_elapsed(bootTimeout) > bootTimeoutDuration) ? 1 : 0;
if (bootComplete) {
rgblight_mode(rgbMode);
}
}
void keyboard_post_init_user(void) {
bootTimeout = timer_read();
init_hsv();
rgblight_enable();
rgblight_mode(rgbBootMode);
};
void matrix_scan_user(void) {
uint8_t layer = get_highest_layer(layer_state);
bootupAnimation();
v = rgblight_get_val();
switch (layer) {
case _FN:
rgblight_sethsv_noeeprom(h,0,v);
break;
default:
break;
}
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
uint8_t layer = get_highest_layer(layer_state);
switch (keycode) {
case FN_SPC:
(record->event.pressed) ? get_hsv() : reset_hsv();
return true;
default:
switch (layer) {
case _QW:
rgblight_increase_hue();
break;
default:
break;
}
return true; }
}