aboutsummaryrefslogtreecommitdiff
path: root/keyboards/dmqdesign
diff options
context:
space:
mode:
authorgorbachev <tpp+github@iki.fi>2020-09-01 00:23:29 -0400
committerGitHub <noreply@github.com>2020-08-31 21:23:29 -0700
commit4286b81af016c2a566c06675dd5123fa83b74033 (patch)
tree5059b2c96d94997df87236451e19c223f0d723d1 /keyboards/dmqdesign
parentfa740c12861f77b1381fa2ee282fd57080c70502 (diff)
downloadqmk_firmware-4286b81af016c2a566c06675dd5123fa83b74033.tar.gz
qmk_firmware-4286b81af016c2a566c06675dd5123fa83b74033.zip
[Keymap] add dmqdesign/spin:gorbachev (#9919)
* Add keymap for DQM Design Spin macropad * changes from code review * state -> layer_state * Formatting fixes * Formatting fixes * Formatting fixes * Formatting fixes * Formatting fixes
Diffstat (limited to 'keyboards/dmqdesign')
-rw-r--r--keyboards/dmqdesign/spin/keymaps/gorbachev/config.h25
-rw-r--r--keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c247
-rw-r--r--keyboards/dmqdesign/spin/keymaps/gorbachev/readme.md7
-rw-r--r--keyboards/dmqdesign/spin/keymaps/gorbachev/rules.mk3
4 files changed, 282 insertions, 0 deletions
diff --git a/keyboards/dmqdesign/spin/keymaps/gorbachev/config.h b/keyboards/dmqdesign/spin/keymaps/gorbachev/config.h
new file mode 100644
index 000000000..10201015e
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/gorbachev/config.h
@@ -0,0 +1,25 @@
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
17#pragma once
18
19#define RGBLIGHT_ANIMATIONS
20#define RGBLIGHT_HUE_STEP 8
21
22// Use one or the other, determines the orientation of
23// the OLED display
24// #define RIGHT_HAND
25#define LEFT_HAND
diff --git a/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c b/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c
new file mode 100644
index 000000000..b9ad17386
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/gorbachev/keymap.c
@@ -0,0 +1,247 @@
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
64void 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}
139
140layer_state_t layer_state_set_user(layer_state_t state) { //This will run every time the layer is updated
141 switch (get_highest_layer(state)) {
142 case _NUMPAD:
143 setrgb(RGB_WHITE, &led[0]); //Set the top LED to white for the bottom layer
144 setrgb(0, 0, 0, &led[1]);
145 setrgb(0, 0, 0, &led[2]);
146 break;
147 case _RGB:
148 setrgb(0, 0, 0, &led[0]); //Set the middle LED to white for the middle layer
149 setrgb(RGB_WHITE, &led[1]);
150 setrgb(0, 0, 0, &led[2]);
151 break;
152 case _MACRO:
153 setrgb(0, 0, 0, &led[0]);
154 setrgb(0, 0, 0, &led[1]);
155 setrgb(RGB_WHITE, &led[2]); //Set the bottom LED to white for the top layer
156 break;
157 }
158 rgblight_set();
159 return state;
160}
161
162#ifdef OLED_DRIVER_ENABLE
163
164static const char *ANIMATION_NAMES[] = {
165 "unknown",
166 "static",
167 "breathing I",
168 "breathing II",
169 "breathing III",
170 "breathing IV",
171 "rainbow mood I",
172 "rainbow mood II",
173 "rainbow mood III",
174 "rainbow swirl I",
175 "rainbow swirl II",
176 "rainbow swirl III",
177 "rainbow swirl IV",
178 "rainbow swirl V",
179 "rainbow swirl VI",
180 "snake I",
181 "snake II",
182 "snake III",
183 "snake IV",
184 "snake V",
185 "snake VI",
186 "knight I",
187 "knight II",
188 "knight III",
189 "christmas",
190 "static gradient I",
191 "static gradient II",
192 "static gradient III",
193 "static gradient IV",
194 "static gradient V",
195 "static gradient VI",
196 "static gradient VII",
197 "static gradient VIII",
198 "static gradient IX",
199 "static gradient X",
200 "rgb test",
201 "alternating",
202 "twinkle I",
203 "twinkle II",
204 "twinkle III",
205 "twinkle IV",
206 "twinkle V",
207 "twinkle VI"
208};
209
210void rgblight_get_mode_name(uint8_t mode, size_t bufsize, char *buf) {
211 snprintf(buf, bufsize, "%-25s", ANIMATION_NAMES[mode]);
212}
213
214oled_rotation_t oled_init_user(oled_rotation_t rotation) {
215#ifdef LEFT_HAND
216 return OLED_ROTATION_180;
217#else
218 return OLED_ROTATION_0;
219#endif
220}
221
222void oled_task_user(void) {
223 // Host Keyboard Layer Status
224 oled_write_P(PSTR("Layer: "), false);
225
226 switch (get_highest_layer(layer_state)) {
227 case _NUMPAD:
228 oled_write_P(PSTR("Numpad\n"), false);
229 break;
230 case _RGB:
231 oled_write_P(PSTR("RGB\n"), false);
232 break;
233 case _MACRO:
234 oled_write_P(PSTR("Macro\n"), false);
235 break;
236 default:
237 // Or use the write_ln shortcut over adding '\n' to the end of your string
238 oled_write_ln_P(PSTR("Undefined"), false);
239 }
240
241 static char rgb_mode_name[30];
242 rgblight_get_mode_name(rgblight_get_mode(), sizeof(rgb_mode_name), rgb_mode_name);
243
244 oled_write_P(PSTR("Mode: "), false);
245 oled_write_ln(rgb_mode_name, false);
246}
247#endif
diff --git a/keyboards/dmqdesign/spin/keymaps/gorbachev/readme.md b/keyboards/dmqdesign/spin/keymaps/gorbachev/readme.md
new file mode 100644
index 000000000..451dae7ef
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/gorbachev/readme.md
@@ -0,0 +1,7 @@
1# Keymap for Spin
2
3* Encoder button push changes layers
4* First layer is a number pad
5* Second layer is RGB control layer
6* Third layer is macro layer
7* OLED support
diff --git a/keyboards/dmqdesign/spin/keymaps/gorbachev/rules.mk b/keyboards/dmqdesign/spin/keymaps/gorbachev/rules.mk
new file mode 100644
index 000000000..553adac19
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/gorbachev/rules.mk
@@ -0,0 +1,3 @@
1OLED_DRIVER_ENABLE = yes
2MOUSEKEY_ENABLE = no
3MIDI_ENABLE = no