#include QMK_KEYBOARD_H
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
TO(1), KC_MSTP, KC_MUTE,
KC_MPRV, KC_MPLY, KC_MNXT
),
[1] = LAYOUT(
TO(2), LGUI(KC_UP), LGUI(KC_D),
LGUI(KC_LEFT), LGUI(KC_DOWN), LGUI(KC_RIGHT)
),
[2] = LAYOUT(
TO(3), KC_ESC, LCTL(LSFT(KC_ESC)),
LCTL(KC_X), LCTL(KC_C), LCTL(KC_V)
),
[3] = LAYOUT(
TO(0), LSFT(KC_R), KC_DEL,
KC_LCTL, KC_SPC, KC_P
),
};
bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
switch (get_highest_layer(layer_state)) {
case 0:
if (clockwise) {
tap_code(KC_MNXT);
} else {
tap_code(KC_MPRV);
}
break;
case 1:
if (clockwise) {
tap_code16(LCTL(LGUI(KC_RIGHT)));
} else {
tap_code16(LCTL(LGUI(KC_LEFT)));
}
break;
case 2:
if (clockwise) {
tap_code16(LCTL(KC_Y));
} else {
tap_code16(LCTL(KC_Z));
}
break;
case 3:
if (clockwise) {
tap_code(KC_WH_R);
} else {
tap_code(KC_WH_L);
}
break;
}
} else if (index == 1) {
switch (get_highest_layer(layer_state)) {
case 0:
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
break;
case 1:
if (clockwise) {
tap_code16(LCTL(KC_TAB));
} else {
tap_code16(LALT(LSFT(KC_TAB)));
}
break;
case 2:
if (clockwise) {
tap_code(KC_WH_U);
} else {
tap_code(KC_WH_D);
}
break;
case 3:
if (clockwise) {
tap_code(KC_WH_U);
} else {
tap_code(KC_WH_D);
}
break;
}
}
return true;
}