aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/dmqdesign/spin/keymaps/spidey3_pad/config.h42
-rw-r--r--keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c237
-rw-r--r--keyboards/dmqdesign/spin/keymaps/spidey3_pad/readme.md1
-rw-r--r--keyboards/dmqdesign/spin/keymaps/spidey3_pad/rules.mk7
4 files changed, 287 insertions, 0 deletions
diff --git a/keyboards/dmqdesign/spin/keymaps/spidey3_pad/config.h b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/config.h
new file mode 100644
index 000000000..1851f07f1
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/config.h
@@ -0,0 +1,42 @@
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_HUE_STEP 8
20
21// place overrides here
22
23#define NO_ACTION_ONESHOT
24#undef LOCKING_SUPPORT_ENABLE
25
26#define LAYER_STATE_8BIT
27#define MAX_LAYER 4
28
29#undef RGBLIGHT_ANIMATIONS
30#define RGBLIGHT_EFFECT_BREATHING
31#define RGBLIGHT_EFFECT_RAINBOW_MOOD
32#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
33#define RGBLIGHT_EFFECT_SNAKE
34#define RGBLIGHT_EFFECT_KNIGHT
35#define RGBLIGHT_EFFECT_STATIC_GRADIENT
36#define RGBLIGHT_EFFECT_ALTERNATING
37#define RGBLIGHT_EFFECT_TWINKLE
38
39#define RGBLIGHT_SLEEP
40#define RGBLIGHT_LAYERS
41#define RGBLIGHT_LAYER_BLINK
42#define RGBLIGHT_LAYERS_OVERRIDE_RGB_OFF
diff --git a/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c
new file mode 100644
index 000000000..ba3aa96d4
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/keymap.c
@@ -0,0 +1,237 @@
1/* Copyright 2020 Joshua Moses Diamond
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
18#include "version.h"
19#include <stdlib.h>
20
21#define RGB_LAYER_ACK_DURATION 500
22
23enum layers { _MACRO, _NUMPAD, _RGB, _FN };
24
25enum layer_base {
26 LAYER_BASE = _MACRO,
27 LAYER_BASE_END = _FN + 1,
28};
29
30enum custom_keycodes {
31 HELLO = SAFE_RANGE,
32 CH_CPNL, // AL Control Panel
33 CH_ASST, // AL Context-aware Desktop Assistant
34 CH_SUSP, // Suspend
35};
36
37// clang-format off
38const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
39 [_MACRO] = LAYOUT(
40 A(S(KC_N)), HELLO, CH_SUSP, TO(_MACRO),
41 KC_MPRV, KC_MPLY, KC_MNXT, TO(_NUMPAD),
42 C(A(KC_COMM)), KC_F5, C(A(KC_DOT)), TO(_RGB),
43 MO(_FN), CH_ASST, CH_CPNL),
44
45 [_NUMPAD] = LAYOUT(
46 KC_KP_7, KC_KP_8, KC_KP_9, KC_TRNS,
47 KC_KP_4, KC_KP_5, KC_KP_6, KC_TRNS,
48 KC_KP_1, KC_KP_2, KC_KP_3, KC_TRNS,
49 KC_KP_0, KC_PDOT, KC_PENT),
50
51 [_RGB] = LAYOUT(
52 RGB_HUI, RGB_SAI, RGB_VAI, KC_TRNS,
53 RGB_HUD, RGB_SAD, RGB_VAD, KC_TRNS,
54 RGB_SPD, RGB_SPI, KC_NO, KC_TRNS,
55 RGB_RMOD, RGB_TOG, RGB_MOD),
56
57 [_FN] = LAYOUT(
58 KC_TRNS, DEBUG, RESET, KC_TRNS,
59 KC_NO, KC_NO, EEP_RST, KC_TRNS,
60 KC_NO, KC_NO, KC_NO, KC_TRNS,
61 KC_NO, KC_NO, KC_NO),
62};
63// clang-format on
64
65typedef enum layer_ack {
66 ACK_NO = 0,
67 ACK_YES,
68 ACK_MEH,
69} layer_ack_t;
70
71#define LAYER_OFFSET 0
72const rgblight_segment_t PROGMEM _macro_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 1, HSV_TEAL});
73const rgblight_segment_t PROGMEM _numpad_layer[] = RGBLIGHT_LAYER_SEGMENTS({1, 1, HSV_TEAL});
74const rgblight_segment_t PROGMEM _rgb_layer[] = RGBLIGHT_LAYER_SEGMENTS({2, 1, HSV_TEAL});
75const rgblight_segment_t PROGMEM _fn_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, HSV_PURPLE});
76
77#define ACK_OFFSET 4
78const rgblight_segment_t PROGMEM _no_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, HSV_RED});
79const rgblight_segment_t PROGMEM _yes_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, HSV_GREEN});
80const rgblight_segment_t PROGMEM _meh_layer[] = RGBLIGHT_LAYER_SEGMENTS({0, 3, HSV_YELLOW});
81
82// clang-format on
83const rgblight_segment_t *const PROGMEM _rgb_layers[] = {
84 [LAYER_OFFSET + 0] = _macro_layer,
85 [LAYER_OFFSET + 1] = _numpad_layer,
86 [LAYER_OFFSET + 2] = _rgb_layer,
87 [LAYER_OFFSET + 3] = _fn_layer,
88
89 [ACK_OFFSET + ACK_NO] = _no_layer,
90 [ACK_OFFSET + ACK_YES] = _yes_layer,
91 [ACK_OFFSET + ACK_MEH] = _meh_layer,
92
93 [ACK_OFFSET + ACK_MEH + 1] = NULL
94};
95// clang-format off
96
97const uint8_t PROGMEM _n_rgb_layers = sizeof(_rgb_layers) / sizeof(_rgb_layers[0]) - 1;
98
99void clear_rgb_layers(void) {
100 dprint("clear_rgb_layers()\n");
101 for (uint8_t i = 0; i < _n_rgb_layers; i++) {
102 rgblight_set_layer_state(i, false);
103 }
104}
105
106void do_rgb_layers(layer_state_t state, uint8_t start, uint8_t end) {
107 dprintf("start=%u, end=%u, LAYER_OFFSET=%u\n", start, end, LAYER_OFFSET);
108 for (uint8_t i = start; i < end; i++) {
109 bool is_on = layer_state_cmp(state, i);
110 uint8_t rl = LAYER_OFFSET + i;
111 dprintf("layer[%u]=%u, rl=%u\n", i, is_on, rl);
112 rgblight_set_layer_state(rl, is_on);
113 }
114}
115
116layer_state_t layer_state_set_user(layer_state_t state) {
117 do_rgb_layers(state, LAYER_BASE, LAYER_BASE_END);
118 return state;
119}
120
121void rgb_layer_ack(layer_ack_t n) {
122 uint8_t layer = ACK_OFFSET + n;
123 dprintf("rgb_layer_ack(%u) ==> %u\n", n, layer);
124 rgblight_blink_layer(layer, RGB_LAYER_ACK_DURATION);
125}
126
127void rgb_layer_ack_yn(bool yn) { rgb_layer_ack(yn ? ACK_YES : ACK_NO); }
128
129void keyboard_post_init_user(void) {
130 // Enable the LED layers
131 rgblight_layers = _rgb_layers;
132 do_rgb_layers(layer_state, LAYER_BASE, LAYER_BASE_END);
133}
134
135void shutdown_user() {
136 clear_rgb_layers();
137 rgblight_enable();
138 rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
139 rgblight_sethsv_noeeprom(HSV_RED);
140}
141
142void spidey_glow(void) {
143 rgblight_enable();
144 rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
145 rgblight_sethsv(255, 230, 128);
146}
147
148void eeconfig_init_user(void) { spidey_glow(); }
149
150bool process_record_user(uint16_t keycode, keyrecord_t *record) {
151 if (record->event.pressed) {
152 switch (keycode) {
153 // Re-implement this here, but fix the persistence!
154 case DEBUG:
155 if (!debug_enable) {
156 debug_enable = 1;
157 } else if (!debug_keyboard) {
158 debug_keyboard = 1;
159 } else if (!debug_matrix) {
160 debug_matrix = 1;
161 } else {
162 debug_enable = 0;
163 debug_keyboard = 0;
164 debug_matrix = 0;
165 }
166 uprintf("DEBUG: enable=%u, keyboard=%u, matrix=%u\n", debug_enable, debug_keyboard, debug_matrix);
167 uprintln(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE);
168 eeconfig_update_debug(debug_config.raw);
169 return false;
170
171 // clang-format off
172 case CH_CPNL: host_consumer_send(AL_CONTROL_PANEL); return false;
173 case CH_ASST: host_consumer_send(AL_ASSISTANT); return false;
174 case CH_SUSP: tap_code16(LGUI(LSFT(KC_L))); return true;
175 case HELLO: SEND_STRING("Hello, world!"); return true;
176 // clang-format on
177 }
178 } else {
179 switch (keycode) {
180 case CH_CPNL:
181 case CH_ASST:
182 host_consumer_send(0);
183 return false;
184 }
185 }
186
187 return true;
188};
189
190
191void post_process_record_user(uint16_t keycode, keyrecord_t *record) {
192 switch (keycode) {
193 // Acks follow...
194 case DEBUG:
195 rgb_layer_ack_yn(debug_enable);
196 break;
197 case RGB_TOG:
198 rgb_layer_ack_yn(rgblight_is_enabled());
199 break;
200 }
201}
202
203void encoder_update_user(uint8_t index, bool clockwise) {
204 switch (get_highest_layer(layer_state)) {
205 case _RGB:
206 if (index == 0) {
207 if (clockwise) {
208 rgblight_increase_hue();
209 } else {
210 rgblight_decrease_hue();
211 }
212 } else if (index == 1) {
213 if (clockwise) {
214 rgblight_increase_sat();
215 } else {
216 rgblight_decrease_sat();
217 }
218 } else if (index == 2) {
219 if (clockwise) {
220 rgblight_increase_val();
221 } else {
222 rgblight_decrease_val();
223 }
224 }
225 break;
226
227 default:
228 if (index == 0) {
229 tap_code16(C(S(clockwise ? KC_EQL : KC_MINS)));
230 } else if (index == 1) {
231 tap_code16(C(clockwise ? KC_EQL : KC_MINS));
232 } else if (index == 2) {
233 tap_code(clockwise ? KC_VOLU : KC_VOLD);
234 }
235 break;
236 }
237}
diff --git a/keyboards/dmqdesign/spin/keymaps/spidey3_pad/readme.md b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/readme.md
new file mode 100644
index 000000000..1abca2748
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/readme.md
@@ -0,0 +1 @@
spidey3 keymap for spin keypad
diff --git a/keyboards/dmqdesign/spin/keymaps/spidey3_pad/rules.mk b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/rules.mk
new file mode 100644
index 000000000..6df20e871
--- /dev/null
+++ b/keyboards/dmqdesign/spin/keymaps/spidey3_pad/rules.mk
@@ -0,0 +1,7 @@
1MOUSEKEY_ENABLE = no
2MIDI_ENABLE = no
3BOOTMAGIC_ENABLE = lite
4LTO_ENABLE = yes
5CONSOLE_ENABLE = yes # Console for debug
6GRAVE_ESC_ENABLE = no
7