aboutsummaryrefslogtreecommitdiff
path: root/users/drashna/drashna.c
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/drashna.c')
-rw-r--r--users/drashna/drashna.c291
1 files changed, 8 insertions, 283 deletions
diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c
index 9c1233ed9..9128a89bc 100644
--- a/users/drashna/drashna.c
+++ b/users/drashna/drashna.c
@@ -1,18 +1,5 @@
1/* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 1// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
2 * 2// SPDX-License-Identifier: GPL-2.0-or-later
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 3
17#include "drashna.h" 4#include "drashna.h"
18 5
@@ -49,182 +36,6 @@ bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this
49 return false; 36 return false;
50} 37}
51 38
52__attribute__((weak)) void keyboard_pre_init_keymap(void) {}
53void keyboard_pre_init_user(void) {
54 userspace_config.raw = eeconfig_read_user();
55 keyboard_pre_init_keymap();
56}
57// Add reconfigurable functions here, for keymap customization
58// This allows for a global, userspace functions, and continued
59// customization of the keymap. Use _keymap instead of _user
60// functions in the keymaps
61// Call user matrix init, set default RGB colors and then
62// call the keymap's init function
63__attribute__((weak)) void matrix_init_keymap(void) {}
64__attribute__((weak)) void matrix_init_secret(void) {}
65void matrix_init_user(void) {
66#if defined(BOOTLOADER_CATERINA) && defined(__AVR__)
67 DDRD &= ~(1 << 5);
68 PORTD &= ~(1 << 5);
69
70 DDRB &= ~(1 << 0);
71 PORTB &= ~(1 << 0);
72#endif
73#ifdef CUSTOM_UNICODE_ENABLE
74 matrix_init_unicode();
75#endif
76 matrix_init_secret();
77 matrix_init_keymap();
78}
79
80__attribute__((weak)) void keyboard_post_init_keymap(void) {}
81void keyboard_post_init_user(void) {
82#if defined(RGBLIGHT_ENABLE)
83 keyboard_post_init_rgb_light();
84#endif
85#if defined(RGB_MATRIX_ENABLE)
86 keyboard_post_init_rgb_matrix();
87#endif
88#if defined(SPLIT_KEYBOARD) && defined(SPLIT_TRANSACTION_IDS_USER)
89 keyboard_post_init_transport_sync();
90#endif
91 keyboard_post_init_keymap();
92}
93
94#ifdef RGB_MATRIX_ENABLE
95void rgb_matrix_update_pwm_buffers(void);
96#endif
97
98__attribute__((weak)) void shutdown_keymap(void) {}
99void shutdown_user(void) {
100#ifdef RGBLIGHT_ENABLE
101 rgblight_enable_noeeprom();
102 rgblight_mode_noeeprom(1);
103 rgblight_setrgb_red();
104#endif // RGBLIGHT_ENABLE
105#ifdef RGB_MATRIX_ENABLE
106 rgb_matrix_set_color_all(0xFF, 0x00, 0x00);
107 rgb_matrix_update_pwm_buffers();
108#endif // RGB_MATRIX_ENABLE
109#ifdef OLED_ENABLE
110 oled_off();
111#endif
112
113 shutdown_keymap();
114}
115
116__attribute__((weak)) void suspend_power_down_keymap(void) {}
117
118void suspend_power_down_user(void) {
119#ifdef OLED_ENABLE
120 oled_off();
121#endif
122 suspend_power_down_keymap();
123}
124
125__attribute__((weak)) void suspend_wakeup_init_keymap(void) {}
126void suspend_wakeup_init_user(void) {
127 if (layer_state_is(_GAMEPAD)) {
128 layer_off(_GAMEPAD);
129 }
130 if (layer_state_is(_DIABLO)) {
131 layer_off(_DIABLO);
132 }
133 suspend_wakeup_init_keymap();
134}
135
136// No global matrix scan code, so just run keymap's matrix
137// scan function
138__attribute__((weak)) void matrix_scan_keymap(void) {}
139__attribute__((weak)) void matrix_scan_secret(void) {}
140void matrix_scan_user(void) {
141 static bool has_ran_yet;
142 if (!has_ran_yet) {
143 has_ran_yet = true;
144 startup_user();
145 }
146
147#ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code.
148 run_diablo_macro_check();
149#endif // TAP_DANCE_ENABLE
150
151#if defined(RGBLIGHT_ENABLE)
152 matrix_scan_rgb_light();
153#endif // RGBLIGHT_ENABLE
154#if defined(RGB_MATRIX_ENABLE)
155 matrix_scan_rgb_matrix();
156#endif
157#if defined(POINTING_DEVICE_ENABLE)
158 matrix_scan_pointing();
159#endif
160
161 matrix_scan_secret();
162
163 matrix_scan_keymap();
164}
165
166#ifdef AUDIO_ENABLE
167float doom_song[][2] = SONG(E1M1_DOOM);
168#endif
169
170// on layer change, no matter where the change was initiated
171// Then runs keymap's layer change check
172__attribute__((weak)) layer_state_t layer_state_set_keymap(layer_state_t state) { return state; }
173layer_state_t layer_state_set_user(layer_state_t state) {
174 if (!is_keyboard_master()) {
175 return state;
176 }
177
178 state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
179#if defined(POINTING_DEVICE_ENABLE)
180 state = layer_state_set_pointing(state);
181#endif
182#if defined(RGBLIGHT_ENABLE)
183 state = layer_state_set_rgb_light(state);
184#endif // RGBLIGHT_ENABLE
185#if defined(AUDIO_ENABLE) && !defined(__arm__)
186 static bool is_gamepad_on = false;
187 if (layer_state_cmp(state, _GAMEPAD) != is_gamepad_on) {
188 is_gamepad_on = layer_state_cmp(state, _GAMEPAD);
189 if (is_gamepad_on) {
190 PLAY_LOOP(doom_song);
191 } else {
192 stop_all_notes();
193 }
194 }
195#endif
196 state = layer_state_set_keymap(state);
197 return state;
198}
199
200// Runs state check and changes underglow color and animation
201__attribute__((weak)) layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; }
202layer_state_t default_layer_state_set_user(layer_state_t state) {
203 if (!is_keyboard_master()) {
204 return state;
205 }
206
207 state = default_layer_state_set_keymap(state);
208#if 0
209# if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
210 state = default_layer_state_set_rgb(state);
211# endif // RGBLIGHT_ENABLE
212#endif
213 return state;
214}
215
216__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {}
217void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); }
218
219__attribute__((weak)) void eeconfig_init_keymap(void) {}
220void eeconfig_init_user(void) {
221 userspace_config.raw = 0;
222 userspace_config.rgb_layer_change = true;
223 eeconfig_update_user(userspace_config.raw);
224 eeconfig_init_keymap();
225 keyboard_init();
226}
227
228bool hasAllBitsInMask(uint8_t value, uint8_t mask) { 39bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
229 value &= 0xF; 40 value &= 0xF;
230 mask &= 0xF; 41 mask &= 0xF;
@@ -232,96 +43,10 @@ bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
232 return (value & mask) == mask; 43 return (value & mask) == mask;
233} 44}
234 45
235#ifdef SPLIT_KEYBOARD 46void tap_code16_nomods(uint8_t kc) {
236__attribute__((weak)) void matrix_slave_scan_keymap(void) {} 47 uint8_t temp_mod = get_mods();
237void matrix_slave_scan_user(void) { 48 clear_mods();
238# if defined(AUDIO_ENABLE) 49 clear_oneshot_mods();
239# if !defined(NO_MUSIC_MODE) 50 tap_code16(kc);
240 music_task(); 51 set_mods(temp_mod);
241# endif
242# ifdef AUDIO_INIT_DELAY
243 if (!is_keyboard_master()) {
244 static bool delayed_tasks_run = false;
245 static uint16_t delayed_task_timer = 0;
246 if (!delayed_tasks_run) {
247 if (!delayed_task_timer) {
248 delayed_task_timer = timer_read();
249 } else if (timer_elapsed(delayed_task_timer) > 300) {
250 audio_startup();
251 delayed_tasks_run = true;
252 }
253 }
254 }
255# endif
256# endif
257# ifdef SEQUENCER_ENABLE
258 sequencer_task();
259# endif
260# ifdef LED_MATRIX_ENABLE
261 led_matrix_task();
262# endif
263# ifdef HAPTIC_ENABLE
264 haptic_task();
265# endif
266
267 matrix_slave_scan_keymap();
268}
269#endif
270
271__attribute__((weak)) uint16_t get_tapping_term(uint16_t keycode, keyrecord_t *record) {
272 switch (keycode) {
273 default:
274 return TAPPING_TERM;
275 }
276}
277
278__attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *record) {
279 // Immediately select the hold action when another key is tapped:
280 // return true;
281 // Do not select the hold action when another key is tapped.
282 // return false;
283 switch (keycode) {
284 default:
285 return false;
286 }
287}
288
289__attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
290 // Immediately select the hold action when another key is pressed.
291 // return true;
292 // Do not select the hold action when another key is pressed.
293 // return false;
294 switch (keycode) {
295 case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:
296 return true;
297 default:
298 return false;
299 }
300}
301
302__attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
303 // Do not force the mod-tap key press to be handled as a modifier
304 // if any other key was pressed while the mod-tap key is held down.
305 // return true;
306 // Force the mod-tap key press to be handled as a modifier if any
307 // other key was pressed while the mod-tap key is held down.
308 // return false;
309 switch (keycode) {
310 default:
311 return true;
312 }
313}
314
315__attribute__((weak)) bool get_tapping_force_hold(uint16_t keycode, keyrecord_t *record) {
316 switch (keycode) {
317 default:
318 return false;
319 }
320}
321
322__attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
323 switch (keycode) {
324 default:
325 return false;
326 }
327} 52}