/* Copyright 2020 ninjonas
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ninjonas.h"
#ifdef ENCODER_ENABLE
void left_encoder_cw(void) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
tap_code16(LGUI(KC_TAB));
break;
case _RAISE:
tap_code(KC_PGDN);
case _ADJUST:
rgblight_decrease_hue();
default:
tap_code(KC_BRID);
}
void left_encoder_acw(void) {
tap_code16(SGUI(KC_TAB));
tap_code(KC_PGUP);
rgblight_increase_hue();
tap_code(KC_BRIU);
void right_encoder_cw(void) {
tap_code(KC_DOWN);
tap_code16(LCTL(LSFT(KC_TAB)));
rgblight_decrease_val();
tap_code(KC_VOLD);
void right_encoder_acw(void) {
tap_code(KC_UP);
tap_code16(LCTL(KC_TAB));
rgblight_increase_val();
tap_code(KC_VOLU);
bool encoder_update_user(uint8_t index, bool clockwise) {
encoder_rotated_timer = timer_read();
if (index == 0) {
left_encoder_rotated = true;
if (clockwise) {
left_encoder_cw();
} else {
left_encoder_acw();
else if (index == 1) {
right_encoder_rotated = true;
right_encoder_cw();
right_encoder_acw();
return true;
#endif