2020-06-18 06:39:16 +02:00
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
|
|
|
|
// please change this value to the desired layer definitions
|
|
|
|
#define LAYERNUM 3
|
|
|
|
|
|
|
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|
|
|
|
|
|
|
/*
|
2020-06-21 23:59:43 +02:00
|
|
|
* | Knob: Layer +/- |
|
|
|
|
* .------------------------------------------------.
|
|
|
|
* | Volume Mute | Media Play/Pause | Hold: Layer 2 |
|
|
|
|
* |-------------|------------------|---------------|
|
|
|
|
* | Media Prev | Up | Media Next |
|
|
|
|
* |-------------|------------------|---------------|
|
|
|
|
* | Left | Down | Right |
|
|
|
|
* '------------------------------------------------'
|
2020-06-18 06:39:16 +02:00
|
|
|
*/
|
|
|
|
[0] =
|
|
|
|
LAYOUT(
|
2021-05-22 08:17:32 +02:00
|
|
|
KC_MUTE, KC_MPLY, MO(2) ,
|
|
|
|
KC_MPRV, KC_UP , KC_MNXT,
|
2020-06-18 06:39:16 +02:00
|
|
|
KC_LEFT, KC_DOWN , KC_RGHT
|
|
|
|
),
|
|
|
|
|
|
|
|
/*
|
2020-06-21 23:59:43 +02:00
|
|
|
* | Knob: Layer +/- |
|
|
|
|
* .---------------------------------------------------.
|
|
|
|
* | RGB Toggle | Media Play/Pause | Hold: Layer 2 |
|
|
|
|
* |----------------|------------------|---------------|
|
|
|
|
* | Media Previous | RGB Bright+ | Media Next |
|
|
|
|
* |----------------|------------------|---------------|
|
|
|
|
* | RGB Anim- | RGB Bright- | RGB Anim+ |
|
|
|
|
* '---------------------------------------------------'
|
2020-06-18 06:39:16 +02:00
|
|
|
*/
|
|
|
|
[1] =
|
|
|
|
LAYOUT(
|
2020-06-21 23:59:43 +02:00
|
|
|
RGB_TOG , KC_TRNS, KC_TRNS,
|
|
|
|
KC_TRNS , RGB_VAI, KC_TRNS,
|
|
|
|
RGB_RMOD, RGB_VAD, RGB_MOD
|
2020-06-18 06:39:16 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
/*
|
|
|
|
* | Knob: Volume +/- |
|
|
|
|
* .--------------------------------------.
|
|
|
|
* | N/A | N/A | Hold: Layer 2 |
|
|
|
|
* |--------------|-------|---------------|
|
|
|
|
* | RESET EEPROM | RESET | DEBUG MODE |
|
|
|
|
* |--------------|-------|---------------|
|
|
|
|
* | N/A | N/A | N/A |
|
|
|
|
* '--------------------------------------'
|
|
|
|
*/
|
|
|
|
[2] =
|
|
|
|
LAYOUT(
|
2021-05-22 08:17:32 +02:00
|
|
|
KC_NO , KC_NO, KC_TRNS,
|
|
|
|
EEP_RST, RESET, DEBUG ,
|
2020-06-18 06:39:16 +02:00
|
|
|
KC_NO , KC_NO, KC_NO
|
2020-06-21 23:59:43 +02:00
|
|
|
),
|
|
|
|
|
|
|
|
/*
|
|
|
|
* | Knob: N/A |
|
|
|
|
* .-----------------.
|
|
|
|
* | N/A | N/A | N/A |
|
|
|
|
* |-----------------|
|
|
|
|
* | N/A | N/A | N/A |
|
|
|
|
* |-----------------|
|
|
|
|
* | N/A | N/A | N/A |
|
|
|
|
* '-----------------'
|
|
|
|
*/
|
|
|
|
[3] =
|
|
|
|
LAYOUT(
|
|
|
|
KC_NO, KC_NO, KC_NO,
|
|
|
|
KC_NO, KC_NO, KC_NO,
|
|
|
|
KC_NO, KC_NO, KC_NO
|
2020-06-18 06:39:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const rgblight_segment_t PROGMEM _base_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
2020-06-21 23:59:43 +02:00
|
|
|
{0, RGBLED_NUM, HSV_BLUE}
|
2020-06-18 06:39:16 +02:00
|
|
|
);
|
|
|
|
const rgblight_segment_t PROGMEM _middle_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
|
|
|
{0, RGBLED_NUM, HSV_GREEN}
|
|
|
|
);
|
|
|
|
const rgblight_segment_t PROGMEM _top_layer[] = RGBLIGHT_LAYER_SEGMENTS(
|
|
|
|
{0, RGBLED_NUM, HSV_RED}
|
|
|
|
);
|
|
|
|
|
|
|
|
const rgblight_segment_t* const PROGMEM _rgb_layers[] =
|
|
|
|
RGBLIGHT_LAYERS_LIST(
|
|
|
|
_base_layer,
|
|
|
|
_middle_layer,
|
|
|
|
_top_layer
|
|
|
|
);
|
|
|
|
|
|
|
|
void keyboard_post_init_user(void) {
|
|
|
|
rgblight_layers = _rgb_layers;
|
|
|
|
}
|
|
|
|
|
|
|
|
layer_state_t layer_state_set_user(layer_state_t state) {
|
|
|
|
|
|
|
|
switch (get_highest_layer(state)) {
|
|
|
|
case 0:
|
|
|
|
rgblight_blink_layer(0, 500);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
rgblight_blink_layer(1, 500);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
rgblight_blink_layer(2, 500);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t selected_layer = 0;
|
2021-05-22 08:17:32 +02:00
|
|
|
bool encoder_update_user(uint8_t index, bool clockwise) {
|
2020-06-18 06:39:16 +02:00
|
|
|
if (index == 0) {
|
|
|
|
if (layer_state_is(2)) {
|
|
|
|
if (clockwise) {
|
|
|
|
tap_code(KC_VOLU);
|
|
|
|
} else {
|
|
|
|
tap_code(KC_VOLD);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (clockwise && selected_layer < (LAYERNUM-2)) { /* Prevent switch to layer 2 using encoder */
|
|
|
|
selected_layer++;
|
|
|
|
layer_move(selected_layer);
|
|
|
|
} else if (!clockwise && selected_layer > 0) {
|
|
|
|
selected_layer--;
|
|
|
|
layer_move(selected_layer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-22 08:17:32 +02:00
|
|
|
return true;
|
2020-06-18 06:39:16 +02:00
|
|
|
}
|