aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c')
-rw-r--r--keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c249
1 files changed, 249 insertions, 0 deletions
diff --git a/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c b/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c
new file mode 100644
index 000000000..b41359c5b
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c
@@ -0,0 +1,249 @@
1/* Copyright 2019-2020 DMQ Design
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#include QMK_KEYBOARD_H
17
18enum layers {
19 _NUMPAD,
20 _RGB,
21 _MACRO
22};
23
24enum custom_keycodes {
25 HELLO_WORLD = SAFE_RANGE,
26};
27
28//The below layers are intentionally empty in order to give a good starting point for how to configure multiple layers.
29const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
30 [_NUMPAD] = LAYOUT(/* Base */
31 KC_7, KC_8, KC_9, TO(_NUMPAD),
32 KC_4, KC_5, KC_6, TO(_RGB),
33 KC_1, KC_2, KC_3, TO(_MACRO),
34 KC_0, KC_DOT, KC_ENTER
35 ),
36
37 [_RGB] = LAYOUT(/* Base */
38 RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS,
39 RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS,
40 KC_NO, KC_NO, KC_NO, KC_TRNS,
41 RGB_RMOD, RGB_TOG, RGB_MOD
42 ),
43
44 [_MACRO] = LAYOUT(/* Base */
45 HELLO_WORLD, KC_NO, KC_NO, KC_TRNS,
46 KC_NO, KC_NO, KC_NO, KC_TRNS,
47 KC_NO, KC_NO, KC_NO, KC_TRNS,
48 KC_NO, KC_NO, KC_NO
49 )
50};
51
52bool process_record_user(uint16_t keycode, keyrecord_t *record) {
53 switch (keycode) {
54 case HELLO_WORLD:
55 if (record->event.pressed) {
56 SEND_STRING("Hello, world!");
57 }
58 break;
59 }
60
61 return true;
62};
63
64bool encoder_update_user(uint8_t index, bool clockwise) {
65 if (index == 0) { /* First encoder */
66 switch (get_highest_layer(layer_state)) { //break each encoder update into a switch statement for the current layer
67 case _NUMPAD:
68 if (clockwise) {
69 tap_code(KC_DOWN);
70 } else {
71 tap_code(KC_UP);
72 }
73 break;
74 case _RGB:
75 if (clockwise) {
76 rgblight_increase_hue();
77 } else {
78 rgblight_decrease_hue();
79 }
80 break;
81 case _MACRO:
82 if (clockwise) {
83 break;
84 } else {
85 break;
86 }
87 break;
88 }
89 } else if (index == 1) { /* Second encoder */
90 switch (get_highest_layer(layer_state)) {
91 case _NUMPAD:
92 if (clockwise) {
93 tap_code(KC_PGDN);
94 } else {
95 tap_code(KC_PGUP);
96 }
97 break;
98 case _RGB:
99 if (clockwise) {
100 rgblight_increase_sat();
101 } else {
102 rgblight_decrease_sat();
103 }
104 break;
105 case _MACRO:
106 if (clockwise) {
107 break;
108 } else {
109 break;
110 }
111 break;
112 }
113 } else if (index == 2) { /* Third encoder */
114 switch (get_highest_layer(layer_state)) {
115 case _NUMPAD:
116 if (clockwise) {
117 tap_code(KC_VOLU);
118 } else {
119 tap_code(KC_VOLD);
120 }
121 break;
122 case _RGB:
123 if (clockwise) {
124 rgblight_increase_val();
125 } else {
126 rgblight_decrease_val();
127 }
128 break;
129 case _MACRO:
130 if (clockwise) {
131 break;
132 } else {
133 break;
134 }
135 break;
136 }
137 }
138 return true;
139}
140
141layer_state_t layer_state_set_user(layer_state_t state) { //This will run every time the layer is updated
142 switch (get_highest_layer(state)) {
143 case _NUMPAD:
144 setrgb(RGB_WHITE, &led[0]); //Set the top LED to white for the bottom layer
145 setrgb(0, 0, 0, &led[1]);
146 setrgb(0, 0, 0, &led[2]);
147 break;
148 case _RGB:
149 setrgb(0, 0, 0, &led[0]); //Set the middle LED to white for the middle layer
150 setrgb(RGB_WHITE, &led[1]);
151 setrgb(0, 0, 0, &led[2]);
152 break;
153 case _MACRO:
154 setrgb(0, 0, 0, &led[0]);
155 setrgb(0, 0, 0, &led[1]);
156 setrgb(RGB_WHITE, &led[2]); //Set the bottom LED to white for the top layer
157 break;
158 }
159 rgblight_set();
160 return state;
161}
162
163#ifdef OLED_ENABLE
164
165static const char *ANIMATION_NAMES[] = {
166 "unknown",
167 "static",
168 "breathing I",
169 "breathing II",
170 "breathing III",
171 "breathing IV",
172 "rainbow mood I",
173 "rainbow mood II",
174 "rainbow mood III",
175 "rainbow swirl I",
176 "rainbow swirl II",
177 "rainbow swirl III",
178 "rainbow swirl IV",
179 "rainbow swirl V",
180 "rainbow swirl VI",
181 "snake I",
182 "snake II",
183 "snake III",
184 "snake IV",
185 "snake V",
186 "snake VI",
187 "knight I",
188 "knight II",
189 "knight III",
190 "christmas",
191 "static gradient I",
192 "static gradient II",
193 "static gradient III",
194 "static gradient IV",
195 "static gradient V",
196 "static gradient VI",
197 "static gradient VII",
198 "static gradient VIII",
199 "static gradient IX",
200 "static gradient X",
201 "rgb test",
202 "alternating",
203 "twinkle I",
204 "twinkle II",
205 "twinkle III",
206 "twinkle IV",
207 "twinkle V",
208 "twinkle VI"
209};
210
211void rgblight_get_mode_name(uint8_t mode, size_t bufsize, char *buf) {
212 snprintf(buf, bufsize, "%-25s", ANIMATION_NAMES[mode]);
213}
214
215oled_rotation_t oled_init_user(oled_rotation_t rotation) {
216#ifdef LEFT_HAND
217 return OLED_ROTATION_180;
218#else
219 return OLED_ROTATION_0;
220#endif
221}
222
223bool oled_task_user(void) {
224 // Host Keyboard Layer Status
225 oled_write_P(PSTR("Layer: "), false);
226
227 switch (get_highest_layer(layer_state)) {
228 case _NUMPAD:
229 oled_write_P(PSTR("Numpad\n"), false);
230 break;
231 case _RGB:
232 oled_write_P(PSTR("RGB\n"), false);
233 break;
234 case _MACRO:
235 oled_write_P(PSTR("Macro\n"), false);
236 break;
237 default:
238 // Or use the write_ln shortcut over adding '\n' to the end of your string
239 oled_write_ln_P(PSTR("Undefined"), false);
240 }
241
242 static char rgb_mode_name[30];
243 rgblight_get_mode_name(rgblight_get_mode(), sizeof(rgb_mode_name), rgb_mode_name);
244
245 oled_write_P(PSTR("Mode: "), false);
246 oled_write_ln(rgb_mode_name, false);
247 return false;
248}
249#endif