| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- /* Copyright 2020 Sergi Meseguer <zigotica@gmail.com>
- 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 "zigotica.h"
- bool encoder_update_user(uint8_t index, bool clockwise) {
- switch(get_highest_layer(layer_state)){
- case _VIM:
- if (index == 0) { // LEFT
- // Cycle through buffers
- if (clockwise) {
- register_code(KC_ESC);
- SEND_STRING(":bprevious");
- register_code(KC_ENT);
- unregister_code(KC_ESC);
- unregister_code(KC_ENT);
- } else {
- register_code(KC_ESC);
- SEND_STRING(":bnext");
- register_code(KC_ENT);
- unregister_code(KC_ESC);
- unregister_code(KC_ENT);
- }
- } else { // RIGHT
- // Scroll
- if (clockwise) {
- tap_code(KC_PGDN);
- } else {
- tap_code(KC_PGUP);
- }
- }
- break;
- case _BROWSER:
- if (index == 0) { // LEFT
- // Cycle through Tabs
- if (clockwise) {
- tap_code16(C(KC_TAB));
- } else {
- tap_code16(S(C(KC_TAB)));
- }
- } else { // RIGHT
- // Scroll up/down
- if (clockwise) {
- register_code(KC_WH_U);
- unregister_code(KC_WH_U);
- } else {
- register_code(KC_WH_D);
- unregister_code(KC_WH_D);
- }
- }
- break;
- case _FIGMA:
- if (index == 0) { // LEFT
- // Cycle through Tabs
- if (clockwise) {
- tap_code16(C(KC_TAB));
- } else {
- tap_code16(S(C(KC_TAB)));
- }
- } else { // RIGHT
- // Zoom in/out
- if (clockwise) {
- register_code(KC_LGUI);
- register_code(KC_WH_D);
- unregister_code(KC_WH_D);
- unregister_code(KC_LGUI);
- } else {
- register_code(KC_LGUI);
- register_code(KC_WH_U);
- unregister_code(KC_WH_U);
- unregister_code(KC_LGUI);
- }
- }
- break;
- case _BASE:
- default:
- if (index == 0) { // LEFT
- // Volume control.
- if (clockwise) {
- tap_code(KC_VOLU);
- } else {
- tap_code(KC_VOLD);
- }
- } else { // RIGHT
- // Scroll
- if (clockwise) {
- tap_code(KC_PGDN);
- } else {
- tap_code(KC_PGUP);
- }
- }
- break;
- }
- return false;
- }
|