#include QMK_KEYBOARD_H
enum layer_names {
_QW,
_RS,
_LW,
};
#define Z_SFT SFT_T(KC_Z)
#define SLSH_SFT SFT_T(KC_SLSH)
#define GRAVE_SFT SFT_T(KC_GRAVE)
#define RBRC_SFT SFT_T(KC_RBRC)
#define FN0 MO(_RS)
#define FN1 TG(_LW)
#define FN2 TO(_QW)
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QW] = LAYOUT(
KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P ,
KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN ,
Z_SFT, KC_X, KC_C, KC_V, KC_B, KC_GRAVE, KC_BSLS, KC_N, KC_M, KC_COMM, KC_DOT, SLSH_SFT,
KC_LCTRL, KC_ESC, KC_LGUI, KC_LALT, KC_SPC, FN0, FN0, KC_SPC, KC_LALT, KC_MINS, KC_QUOT, KC_LCTRL
),
[_RS] = LAYOUT(
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0 ,
KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN ,
GRAVE_SFT, KC_TILD, KC_NO, KC_NO, KC_NO, _______, _______, KC_PLUS, KC_MINS, KC_SLSH, KC_LBRC, RBRC_SFT,
_______, _______, _______, _______, _______, FN1, FN1, _______, _______, KC_EQL, _______, _______
),
[_LW] = LAYOUT(
KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10,
KC_NO, KC_NO, KC_NO, KC_NO, KC_F11, KC_F12, KC_NO, KC_NO, KC_NO, KC_NO ,
KC_NO, KC_NO, KC_NO, DEBUG, RESET, EEP_RST, _______, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO ,
_______, _______, _______, _______, _______, FN2, FN2, _______, _______, KC_NO, KC_ESC, _______
)
};
uint8_t mod_state;
bool substitute_keycode(uint16_t keycode, keyrecord_t *record, uint8_t mod_state, uint16_t substitute_keycode) {
static bool key_registered;
if ((mod_state & MOD_BIT(KC_LCTRL)) == MOD_BIT(KC_LCTRL)) {
if (record->event.pressed) {
unregister_code(KC_LCTRL);
register_code(substitute_keycode);
key_registered = true;
set_mods(mod_state);
return false;
} else {
if (key_registered) {
unregister_code(substitute_keycode);
key_registered = false;
return false;
}
}
}
return true;
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
mod_state = get_mods();
switch (keycode) {
case KC_I:
return substitute_keycode(keycode, record, mod_state, KC_TAB);
case KC_M:
return substitute_keycode(keycode, record, mod_state, KC_ENTER);
case KC_H:
return substitute_keycode(keycode, record, mod_state, KC_BSPC);
case KC_D:
return substitute_keycode(keycode, record, mod_state, KC_DEL);
case KC_N:
return substitute_keycode(keycode, record, mod_state, KC_DOWN);
case KC_P:
return substitute_keycode(keycode, record, mod_state, KC_UP);
}
return true;
};