1
0
Fork 0
qmk_firmware/keyboards/z12/keymaps/zigotica/encoder.c
Sergi Meseguer 07465c0ebb
zigotica userspace add raw_hid_receive (#14869)
* zigotica userspace add raw_hid_receive

* add 3 keys to figma keymap

* add 2 keys to vim keymap

* improve vim keys

* add 3 keys to browser keymap

* comment typo

* shorten SEND_STRING

Co-authored-by: Ryan <fauxpark@gmail.com>

Co-authored-by: Ryan <fauxpark@gmail.com>
2021-12-27 21:24:14 +11:00

110 lines
3.5 KiB
C

/* 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;
}