diff options
Diffstat (limited to 'keyboards/z12/keymaps/zigotica/encoder.c')
-rw-r--r-- | keyboards/z12/keymaps/zigotica/encoder.c | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/keyboards/z12/keymaps/zigotica/encoder.c b/keyboards/z12/keymaps/zigotica/encoder.c new file mode 100644 index 000000000..49a3d859b --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/encoder.c | |||
@@ -0,0 +1,114 @@ | |||
1 | /* Copyright 2020 Sergi Meseguer <zigotica@gmail.com> | ||
2 | |||
3 | This program is free software: you can redistribute it and/or modify | ||
4 | it under the terms of the GNU General Public License as published by | ||
5 | the Free Software Foundation, either version 2 of the License, or | ||
6 | (at your option) any later version. | ||
7 | |||
8 | This program is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | GNU General Public License for more details. | ||
12 | |||
13 | You should have received a copy of the GNU General Public License | ||
14 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include "zigotica.h" | ||
18 | |||
19 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
20 | switch(get_highest_layer(layer_state)){ | ||
21 | case _VIM: | ||
22 | if (index == 0) { // LEFT | ||
23 | // Cycle through buffers | ||
24 | if (clockwise) { | ||
25 | register_code(KC_ESC); | ||
26 | SEND_STRING(":bprevious"); | ||
27 | register_code(KC_ENT); | ||
28 | unregister_code(KC_ESC); | ||
29 | unregister_code(KC_ENT); | ||
30 | } else { | ||
31 | register_code(KC_ESC); | ||
32 | SEND_STRING(":bnext"); | ||
33 | register_code(KC_ENT); | ||
34 | unregister_code(KC_ESC); | ||
35 | unregister_code(KC_ENT); | ||
36 | } | ||
37 | } else { // RIGHT | ||
38 | // Scroll | ||
39 | if (clockwise) { | ||
40 | tap_code(KC_PGDN); | ||
41 | } else { | ||
42 | tap_code(KC_PGUP); | ||
43 | } | ||
44 | } | ||
45 | break; | ||
46 | case _BROWSER: | ||
47 | if (index == 0) { // LEFT | ||
48 | // Cycle through Tabs | ||
49 | if (clockwise) { | ||
50 | tap_code16(C(KC_TAB)); | ||
51 | /* register_code16(G(KC_RCBR)); */ | ||
52 | /* unregister_code16(G(KC_RCBR)); */ | ||
53 | } else { | ||
54 | tap_code16(S(C(KC_TAB))); | ||
55 | /* register_code16(G(KC_LCBR)); */ | ||
56 | /* unregister_code16(G(KC_LCBR)); */ | ||
57 | } | ||
58 | } else { // RIGHT | ||
59 | // Scroll up/down | ||
60 | if (clockwise) { | ||
61 | register_code(KC_WH_U); | ||
62 | unregister_code(KC_WH_U); | ||
63 | } else { | ||
64 | register_code(KC_WH_D); | ||
65 | unregister_code(KC_WH_D); | ||
66 | } | ||
67 | } | ||
68 | break; | ||
69 | case _FIGMA: | ||
70 | if (index == 0) { // LEFT | ||
71 | // Volume control. | ||
72 | if (clockwise) { | ||
73 | tap_code(KC_VOLU); | ||
74 | } else { | ||
75 | tap_code(KC_VOLD); | ||
76 | } | ||
77 | } else { // RIGHT | ||
78 | // Zoom in/out | ||
79 | if (clockwise) { | ||
80 | register_code(KC_LGUI); | ||
81 | register_code(KC_WH_D); | ||
82 | unregister_code(KC_WH_D); | ||
83 | unregister_code(KC_LGUI); | ||
84 | } else { | ||
85 | register_code(KC_LGUI); | ||
86 | register_code(KC_WH_U); | ||
87 | unregister_code(KC_WH_U); | ||
88 | unregister_code(KC_LGUI); | ||
89 | } | ||
90 | } | ||
91 | break; | ||
92 | case _TERMINAL: | ||
93 | default: | ||
94 | if (index == 0) { // LEFT | ||
95 | // Volume control. | ||
96 | if (clockwise) { | ||
97 | tap_code(KC_VOLU); | ||
98 | } else { | ||
99 | tap_code(KC_VOLD); | ||
100 | } | ||
101 | } else { // RIGHT | ||
102 | // Scroll | ||
103 | if (clockwise) { | ||
104 | tap_code(KC_PGDN); | ||
105 | } else { | ||
106 | tap_code(KC_PGUP); | ||
107 | } | ||
108 | } | ||
109 | break; | ||
110 | } | ||
111 | return false; | ||
112 | } | ||
113 | |||
114 | |||